summaryrefslogtreecommitdiff
path: root/spec/services
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/services
parenta60cc42b262cb63ce5d2284f1f3f41d6521daa14 (diff)
downloadgitlab-ce-921677782f09d7baf4b6655570d4efc16ab46779.tar.gz
Implement CreateMembers service to make controller thinrefactor_group_members
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/members/create_service_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/services/members/create_service_spec.rb b/spec/services/members/create_service_spec.rb
new file mode 100644
index 00000000000..0670ac2faa2
--- /dev/null
+++ b/spec/services/members/create_service_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper'
+
+describe Members::CreateService, services: true do
+ let(:project) { create(:empty_project) }
+ let(:user) { create(:user) }
+ let(:project_user) { create(:user) }
+
+ before { project.team << [user, :master] }
+
+ it 'adds user to members' do
+ params = { user_ids: project_user.id.to_s, access_level: Gitlab::Access::GUEST }
+ result = described_class.new(project, user, params).execute
+
+ expect(result).to be_truthy
+ expect(project.users).to include project_user
+ end
+
+ it 'adds no user to members' do
+ params = { user_ids: '', access_level: Gitlab::Access::GUEST }
+ result = described_class.new(project, user, params).execute
+
+ expect(result).to be_falsey
+ expect(project.users).not_to include project_user
+ end
+end