summaryrefslogtreecommitdiff
path: root/spec/services/members
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/services/members
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/services/members')
-rw-r--r--spec/services/members/create_service_spec.rb51
1 files changed, 33 insertions, 18 deletions
diff --git a/spec/services/members/create_service_spec.rb b/spec/services/members/create_service_spec.rb
index e8a4a798b20..50efee9f43c 100644
--- a/spec/services/members/create_service_spec.rb
+++ b/spec/services/members/create_service_spec.rb
@@ -2,26 +2,41 @@
require 'spec_helper'
-RSpec.describe Members::CreateService do
- let_it_be(:project) { create(:project) }
+RSpec.describe Members::CreateService, :clean_gitlab_redis_shared_state, :sidekiq_inline do
+ let_it_be(:source) { create(:project) }
let_it_be(:user) { create(:user) }
- let_it_be(:project_user) { create(:user) }
- let_it_be(:user_ids) { project_user.id.to_s }
+ let_it_be(:member) { create(:user) }
+ let_it_be(:user_ids) { member.id.to_s }
let_it_be(:access_level) { Gitlab::Access::GUEST }
let(:params) { { user_ids: user_ids, access_level: access_level } }
- subject(:execute_service) { described_class.new(user, params).execute(project) }
+ subject(:execute_service) { described_class.new(user, params).execute(source) }
before do
- project.add_maintainer(user)
- allow(Namespaces::OnboardingUserAddedWorker).to receive(:idempotent?).and_return(false)
+ if source.is_a?(Project)
+ source.add_maintainer(user)
+ OnboardingProgress.onboard(source.namespace)
+ else
+ source.add_owner(user)
+ OnboardingProgress.onboard(source)
+ end
end
context 'when passing valid parameters' do
it 'adds a user to members' do
expect(execute_service[:status]).to eq(:success)
- expect(project.users).to include project_user
- expect(Namespaces::OnboardingUserAddedWorker.jobs.last['args'][0]).to eq(project.id)
+ expect(source.users).to include member
+ expect(OnboardingProgress.completed?(source.namespace, :user_added)).to be(true)
+ end
+
+ context 'when executing on a group' do
+ let_it_be(:source) { create(:group) }
+
+ it 'adds a user to members' do
+ expect(execute_service[:status]).to eq(:success)
+ expect(source.users).to include member
+ expect(OnboardingProgress.completed?(source, :user_added)).to be(true)
+ end
end
end
@@ -31,8 +46,8 @@ RSpec.describe Members::CreateService do
it 'does not add a member' do
expect(execute_service[:status]).to eq(:error)
expect(execute_service[:message]).to be_present
- expect(project.users).not_to include project_user
- expect(Namespaces::OnboardingUserAddedWorker.jobs.size).to eq(0)
+ expect(source.users).not_to include member
+ expect(OnboardingProgress.completed?(source.namespace, :user_added)).to be(false)
end
end
@@ -42,8 +57,8 @@ RSpec.describe Members::CreateService do
it 'limits the number of users to 100' do
expect(execute_service[:status]).to eq(:error)
expect(execute_service[:message]).to be_present
- expect(project.users).not_to include project_user
- expect(Namespaces::OnboardingUserAddedWorker.jobs.size).to eq(0)
+ expect(source.users).not_to include member
+ expect(OnboardingProgress.completed?(source.namespace, :user_added)).to be(false)
end
end
@@ -52,19 +67,19 @@ RSpec.describe Members::CreateService do
it 'does not add a member' do
expect(execute_service[:status]).to eq(:error)
- expect(execute_service[:message]).to include("#{project_user.username}: Access level is not included in the list")
- expect(project.users).not_to include project_user
- expect(Namespaces::OnboardingUserAddedWorker.jobs.size).to eq(0)
+ expect(execute_service[:message]).to include("#{member.username}: Access level is not included in the list")
+ expect(source.users).not_to include member
+ expect(OnboardingProgress.completed?(source.namespace, :user_added)).to be(false)
end
end
context 'when passing an existing invite user id' do
- let(:user_ids) { create(:project_member, :invited, project: project).invite_email }
+ let(:user_ids) { create(:project_member, :invited, project: source).invite_email }
it 'does not add a member' do
expect(execute_service[:status]).to eq(:error)
expect(execute_service[:message]).to eq('Invite email has already been taken')
- expect(Namespaces::OnboardingUserAddedWorker.jobs.size).to eq(0)
+ expect(OnboardingProgress.completed?(source.namespace, :user_added)).to be(false)
end
end
end