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-04-08 21:09:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-08 21:09:32 +0300
commit383ec6808b2e5385ccdc0ff7fef8f537635f9bff (patch)
tree93977ed73841bf36c8f07020f0d2dfab74162a02 /spec/services/issues
parent7a4a8bd5abf6ed6519f252abd79e5f528b8d29d6 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/issues')
-rw-r--r--spec/services/issues/after_create_service_spec.rb52
-rw-r--r--spec/services/issues/create_service_spec.rb49
2 files changed, 78 insertions, 23 deletions
diff --git a/spec/services/issues/after_create_service_spec.rb b/spec/services/issues/after_create_service_spec.rb
new file mode 100644
index 00000000000..bc9be3211d3
--- /dev/null
+++ b/spec/services/issues/after_create_service_spec.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Issues::AfterCreateService do
+ include AfterNextHelpers
+
+ let_it_be(:project) { create(:project) }
+ let_it_be(:current_user) { create(:user) }
+ let_it_be(:assignee) { create(:user) }
+ let_it_be(:milestone) { create(:milestone, project: project) }
+ let_it_be(:issue) { create(:issue, project: project, author: current_user, milestone: milestone, assignee_ids: [assignee.id]) }
+
+ subject(:after_create_service) { described_class.new(project, current_user) }
+
+ describe '#execute' do
+ it 'creates a pending todo for new assignee' do
+ attributes = {
+ project: project,
+ author: current_user,
+ user: assignee,
+ target_id: issue.id,
+ target_type: issue.class.name,
+ action: Todo::ASSIGNED,
+ state: :pending
+ }
+
+ expect { after_create_service.execute(issue) }.to change { Todo.where(attributes).count }.by(1)
+ end
+
+ it 'deletes milestone issues count cache' do
+ expect_next(Milestones::IssuesCountService, milestone)
+ .to receive(:delete_cache).and_call_original
+
+ after_create_service.execute(issue)
+ end
+
+ context 'with a regular issue' do
+ it_behaves_like 'does not track incident management event', :incident_management_incident_created do
+ subject { after_create_service.execute(issue) }
+ end
+ end
+
+ context 'with an incident issue' do
+ let(:issue) { create(:issue, :incident, project: project, author: current_user) }
+
+ it_behaves_like 'an incident management tracked event', :incident_management_incident_created do
+ subject { after_create_service.execute(issue) }
+ end
+ end
+ end
+end
diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb
index d548e5ee74a..a1ca5ad3c2f 100644
--- a/spec/services/issues/create_service_spec.rb
+++ b/spec/services/issues/create_service_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe Issues::CreateService do
+ include AfterNextHelpers
+
let_it_be_with_reload(:project) { create(:project) }
let_it_be(:user) { create(:user) }
@@ -64,7 +66,6 @@ RSpec.describe Issues::CreateService do
it_behaves_like 'incident issue'
it_behaves_like 'has incident label'
- it_behaves_like 'an incident management tracked event', :incident_management_incident_created
it 'does create an incident label' do
expect { subject }
@@ -112,26 +113,36 @@ RSpec.describe Issues::CreateService do
end
end
- it 'creates a pending todo for new assignee' do
- attributes = {
- project: project,
- author: user,
- user: assignee,
- target_id: issue.id,
- target_type: issue.class.name,
- action: Todo::ASSIGNED,
- state: :pending
- }
-
- expect(Todo.where(attributes).count).to eq 1
- end
-
it 'moves the issue to the end, in an asynchronous worker' do
expect(IssuePlacementWorker).to receive(:perform_async).with(be_nil, Integer)
described_class.new(project, user, opts).execute
end
+ context 'with issue_perform_after_creation_tasks_async feature disabled' do
+ before do
+ stub_feature_flags(issue_perform_after_creation_tasks_async: false)
+ end
+
+ it 'calls Issues::AfterCreateService' do
+ expect_next(::Issues::AfterCreateService, project, user).to receive(:execute)
+
+ described_class.new(project, user, opts).execute
+ end
+ end
+
+ context 'with issue_perform_after_creation_tasks_async feature enabled' do
+ before do
+ stub_feature_flags(issue_perform_after_creation_tasks_async: true)
+ end
+
+ it 'does not call Issues::AfterCreateService' do
+ expect(::Issues::AfterCreateService).not_to receive(:new)
+
+ described_class.new(project, user, opts).execute
+ end
+ end
+
context 'when label belongs to project group' do
let(:group) { create(:group) }
let(:group_labels) { create_pair(:group_label, group: group) }
@@ -279,14 +290,6 @@ RSpec.describe Issues::CreateService do
end
end
- it 'deletes milestone issues count cache' do
- expect_next_instance_of(Milestones::IssuesCountService, milestone) do |service|
- expect(service).to receive(:delete_cache).and_call_original
- end
-
- issue
- end
-
it 'schedules a namespace onboarding create action worker' do
expect(Namespaces::OnboardingIssueCreatedWorker).to receive(:perform_async).with(project.namespace.id)