summaryrefslogtreecommitdiff
path: root/spec/controllers/projects
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2016-10-28 13:55:33 +0300
committerValery Sizov <valery@gitlab.com>2016-11-01 10:17:04 +0200
commit921677782f09d7baf4b6655570d4efc16ab46779 (patch)
treeaa2b8435b8b4c6ada18cb92146ccec3b8051fb8e /spec/controllers/projects
parenta60cc42b262cb63ce5d2284f1f3f41d6521daa14 (diff)
downloadgitlab-ce-921677782f09d7baf4b6655570d4efc16ab46779.tar.gz
Implement CreateMembers service to make controller thinrefactor_group_members
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r--spec/controllers/projects/project_members_controller_spec.rb68
1 files changed, 34 insertions, 34 deletions
diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb
index b4f066d8600..2a7523c6512 100644
--- a/spec/controllers/projects/project_members_controller_spec.rb
+++ b/spec/controllers/projects/project_members_controller_spec.rb
@@ -14,49 +14,49 @@ describe Projects::ProjectMembersController do
end
describe 'POST create' do
- context 'when users are added' do
- let(:project_user) { create(:user) }
+ let(:project_user) { create(:user) }
- before { sign_in(user) }
+ before { sign_in(user) }
- context 'when user does not have enough rights' do
- before { project.team << [user, :developer] }
+ context 'when user does not have enough rights' do
+ before { project.team << [user, :developer] }
- it 'returns 404' do
- post :create, namespace_id: project.namespace,
- project_id: project,
- user_ids: project_user.id,
- access_level: Gitlab::Access::GUEST
+ it 'returns 404' do
+ post :create, namespace_id: project.namespace,
+ project_id: project,
+ user_ids: project_user.id,
+ access_level: Gitlab::Access::GUEST
- expect(response).to have_http_status(404)
- expect(project.users).not_to include project_user
- end
+ expect(response).to have_http_status(404)
+ expect(project.users).not_to include project_user
end
+ end
- context 'when user has enough rights' do
- before { project.team << [user, :master] }
+ context 'when user has enough rights' do
+ before { project.team << [user, :master] }
- it 'adds user to members' do
- post :create, namespace_id: project.namespace,
- project_id: project,
- user_ids: project_user.id,
- access_level: Gitlab::Access::GUEST
-
- expect(response).to set_flash.to 'Users were successfully added.'
- expect(response).to redirect_to(namespace_project_project_members_path(project.namespace, project))
- expect(project.users).to include project_user
- end
+ it 'adds user to members' do
+ expect_any_instance_of(Members::CreateService).to receive(:execute).and_return(true)
- it 'adds no user to members' do
- post :create, namespace_id: project.namespace,
- project_id: project,
- user_ids: '',
- access_level: Gitlab::Access::GUEST
+ post :create, namespace_id: project.namespace,
+ project_id: project,
+ user_ids: project_user.id,
+ access_level: Gitlab::Access::GUEST
- expect(response).to set_flash.to 'No users or groups specified.'
- expect(response).to redirect_to(namespace_project_project_members_path(project.namespace, project))
- expect(project.users).not_to include project_user
- end
+ expect(response).to set_flash.to 'Users were successfully added.'
+ expect(response).to redirect_to(namespace_project_project_members_path(project.namespace, project))
+ end
+
+ it 'adds no user to members' do
+ expect_any_instance_of(Members::CreateService).to receive(:execute).and_return(false)
+
+ post :create, namespace_id: project.namespace,
+ project_id: project,
+ user_ids: '',
+ access_level: Gitlab::Access::GUEST
+
+ expect(response).to set_flash.to 'No users or groups specified.'
+ expect(response).to redirect_to(namespace_project_project_members_path(project.namespace, project))
end
end
end