2016-10-28 06:55:33 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 10:24:02 -04:00
|
|
|
describe Members::CreateService do
|
2016-10-28 06:55:33 -04:00
|
|
|
let(:project) { create(:empty_project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project_user) { create(:user) }
|
|
|
|
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
|
|
|
end
|
2016-10-28 06:55:33 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-06-06 10:55:12 -04:00
|
|
|
expect(result[:status]).to eq(:success)
|
2016-10-28 06:55:33 -04:00
|
|
|
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
|
|
|
|
|
2017-06-06 10:55:12 -04:00
|
|
|
expect(result[:status]).to eq(:error)
|
|
|
|
expect(result[:message]).to be_present
|
|
|
|
expect(project.users).not_to include project_user
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'limits the number of users to 100' do
|
|
|
|
user_ids = 1.upto(101).to_a.join(',')
|
|
|
|
params = { user_ids: user_ids, access_level: Gitlab::Access::GUEST }
|
|
|
|
|
|
|
|
result = described_class.new(project, user, params).execute
|
|
|
|
|
|
|
|
expect(result[:status]).to eq(:error)
|
|
|
|
expect(result[:message]).to be_present
|
2016-10-28 06:55:33 -04:00
|
|
|
expect(project.users).not_to include project_user
|
|
|
|
end
|
|
|
|
end
|