From 85ba75aad3be26423af59e393c1d0dc98fe0daf3 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Mon, 30 Mar 2015 20:09:45 +0500 Subject: [PATCH] [#465] update & fix collaborators specs --- .../projects/collaborators_controller_spec.rb | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/spec/controllers/projects/collaborators_controller_spec.rb b/spec/controllers/projects/collaborators_controller_spec.rb index d59c686c2..951d0db59 100644 --- a/spec/controllers/projects/collaborators_controller_spec.rb +++ b/spec/controllers/projects/collaborators_controller_spec.rb @@ -34,44 +34,44 @@ end shared_examples_for 'project admin user' do it 'should be able to view collaborators list' do get :index, name_with_owner: @project.name_with_owner - response.should be_success + expect(response).to be_success end it 'should be able to perform update action' do put :update, {id: @collaborator.id}.merge(@update_params) - response.should be_success + expect(response).to be_success end it 'should add new collaborator with reader role' do post :create, @create_params.merge(collaborator: @user_params) - @project.relations.exists?(actor_type: 'User', actor_id: @another_user.id, role: 'reader').should be_truthy + expect(@project.relations.exists?(actor_type: 'User', actor_id: @another_user.id, role: 'reader')).to be true end it 'should add new group with reader role' do post :create, @create_params.merge(collaborator: @group_params) - @project.relations.exists?(actor_type: 'Group', actor_id: @group.id, role: 'reader').should be_truthy + expect(@project.relations.exists?(actor_type: 'Group', actor_id: @group.id, role: 'reader')).to be true end it 'should be able to set reader role for any user' do put :update, {id: @collaborator.id}.merge(@update_params) - @another_user.relations.exists? target_id: @project.id, target_type: 'Project', role: 'read' + expect(@collaborator.actor.relations.exists? target_id: @project.id, target_type: 'Project', role: 'reader').to be true end end shared_examples_for 'user with no rights for this project' do it 'should not be able to view collaborators list' do get :index, name_with_owner: @project.name_with_owner - response.should redirect_to(forbidden_path) + expect(response).to redirect_to(forbidden_path) end it 'should not be able to perform update action' do put :update, {id: @collaborator.id}.merge(@update_params) - response.should redirect_to(forbidden_path) + expect(response).to redirect_to(forbidden_path) end it 'should not be able to set reader role for any user' do put :update, {id: @collaborator.id}.merge(@update_params) - !@another_user.relations.exists? target_id: @project.id, target_type: 'Project', role: 'read' + expect(@another_user.relations.exists? target_id: @project.id, target_type: 'Project', role: 'read').to be false end end @@ -84,12 +84,12 @@ describe Projects::CollaboratorsController, type: :controller do end it 'should not be able to perform index action' do get :index, name_with_owner: @project.name_with_owner - response.should redirect_to(new_user_session_path) + expect(response).to redirect_to(new_user_session_path) end it 'should not be able to perform update action' do put :update, {id: @collaborator.id}.merge(@update_params) - response.code.should == '401' + expect(response.code).to eq '401' end end @@ -134,4 +134,8 @@ describe Projects::CollaboratorsController, type: :controller do it_should_behave_like 'user with no rights for this project' end + + context 'for another user' do + it_should_behave_like 'user with no rights for this project' + end end