Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-10-25 15:10:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-25 15:10:19 +0300
commite5d3d8c323872cb5dee33c5388b3157294c30343 (patch)
tree8d954820c1f876c9df58fc7ac06a181782822db4 /spec/services/members
parent45760607bc053b7379f81edd5ea91dd2a6471522 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/members')
-rw-r--r--spec/services/members/create_service_spec.rb106
-rw-r--r--spec/services/members/invite_service_spec.rb5
2 files changed, 111 insertions, 0 deletions
diff --git a/spec/services/members/create_service_spec.rb b/spec/services/members/create_service_spec.rb
index 2e6e6041fc3..1c71715d922 100644
--- a/spec/services/members/create_service_spec.rb
+++ b/spec/services/members/create_service_spec.rb
@@ -196,4 +196,110 @@ RSpec.describe Members::CreateService, :aggregate_failures, :clean_gitlab_redis_
end
end
end
+
+ context 'when assigning tasks to be done' do
+ let(:additional_params) do
+ { invite_source: '_invite_source_', tasks_to_be_done: %w(ci code), tasks_project_id: source.id }
+ end
+
+ before do
+ stub_experiments(invite_members_for_task: true)
+ end
+
+ it 'creates 2 task issues', :aggregate_failures do
+ expect(TasksToBeDone::CreateWorker)
+ .to receive(:perform_async)
+ .with(anything, user.id, [member.id])
+ .once
+ .and_call_original
+ expect { execute_service }.to change { source.issues.count }.by(2)
+
+ expect(source.issues).to all have_attributes(
+ project: source,
+ author: user,
+ assignees: array_including(member)
+ )
+ end
+
+ context 'when passing many user ids' do
+ before do
+ stub_licensed_features(multiple_issue_assignees: false)
+ end
+
+ let(:another_user) { create(:user) }
+ let(:user_ids) { [member.id, another_user.id].join(',') }
+
+ it 'still creates 2 task issues', :aggregate_failures do
+ expect(TasksToBeDone::CreateWorker)
+ .to receive(:perform_async)
+ .with(anything, user.id, array_including(member.id, another_user.id))
+ .once
+ .and_call_original
+ expect { execute_service }.to change { source.issues.count }.by(2)
+
+ expect(source.issues).to all have_attributes(
+ project: source,
+ author: user,
+ assignees: array_including(member)
+ )
+ end
+ end
+
+ context 'when a `tasks_project_id` is missing' do
+ let(:additional_params) do
+ { invite_source: '_invite_source_', tasks_to_be_done: %w(ci code) }
+ end
+
+ it 'does not create task issues' do
+ expect(TasksToBeDone::CreateWorker).not_to receive(:perform_async)
+ execute_service
+ end
+ end
+
+ context 'when `tasks_to_be_done` are missing' do
+ let(:additional_params) do
+ { invite_source: '_invite_source_', tasks_project_id: source.id }
+ end
+
+ it 'does not create task issues' do
+ expect(TasksToBeDone::CreateWorker).not_to receive(:perform_async)
+ execute_service
+ end
+ end
+
+ context 'when invalid `tasks_to_be_done` are passed' do
+ let(:additional_params) do
+ { invite_source: '_invite_source_', tasks_project_id: source.id, tasks_to_be_done: %w(invalid_task) }
+ end
+
+ it 'does not create task issues' do
+ expect(TasksToBeDone::CreateWorker).not_to receive(:perform_async)
+ execute_service
+ end
+ end
+
+ context 'when invalid `tasks_project_id` is passed' do
+ let(:another_project) { create(:project) }
+ let(:additional_params) do
+ { invite_source: '_invite_source_', tasks_project_id: another_project.id, tasks_to_be_done: %w(ci code) }
+ end
+
+ it 'does not create task issues' do
+ expect(TasksToBeDone::CreateWorker).not_to receive(:perform_async)
+ execute_service
+ end
+ end
+
+ context 'when a member was already invited' do
+ let(:user_ids) { create(:project_member, :invited, project: source).invite_email }
+ let(:additional_params) do
+ { invite_source: '_invite_source_', tasks_project_id: source.id, tasks_to_be_done: %w(ci code) }
+ end
+
+ it 'does not create task issues' do
+ expect(TasksToBeDone::CreateWorker).not_to receive(:perform_async)
+ execute_service
+ end
+ end
+ end
end
diff --git a/spec/services/members/invite_service_spec.rb b/spec/services/members/invite_service_spec.rb
index 478733e8aa0..7b9ae19f038 100644
--- a/spec/services/members/invite_service_spec.rb
+++ b/spec/services/members/invite_service_spec.rb
@@ -22,6 +22,11 @@ RSpec.describe Members::InviteService, :aggregate_failures, :clean_gitlab_redis_
end
it_behaves_like 'records an onboarding progress action', :user_added
+
+ it 'does not create task issues' do
+ expect(TasksToBeDone::CreateWorker).not_to receive(:perform_async)
+ expect { result }.not_to change { project.issues.count }
+ end
end
context 'when email belongs to an existing user as a secondary email' do