diff options
author | Valery Sizov <valery@gitlab.com> | 2016-10-28 13:55:33 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-11-01 11:17:04 +0300 |
commit | 921677782f09d7baf4b6655570d4efc16ab46779 (patch) | |
tree | aa2b8435b8b4c6ada18cb92146ccec3b8051fb8e /spec/services/members | |
parent | a60cc42b262cb63ce5d2284f1f3f41d6521daa14 (diff) |
Implement CreateMembers service to make controller thin
Diffstat (limited to 'spec/services/members')
-rw-r--r-- | spec/services/members/create_service_spec.rb | 25 |
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 |