diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-05 00:07:49 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-05 00:07:49 +0000 |
commit | 77237c5a6b9044f58beabc54d3589e5fa09cbfba (patch) | |
tree | f43188047fe8955f6cf78e05ae9c2e8f6a019e0b /spec/services/issues | |
parent | 2fd92f2dc784ade9cb4e1c33dd60cbfad7b86818 (diff) | |
download | gitlab-ce-77237c5a6b9044f58beabc54d3589e5fa09cbfba.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/issues')
-rw-r--r-- | spec/services/issues/close_service_spec.rb | 22 | ||||
-rw-r--r-- | spec/services/issues/create_service_spec.rb | 8 | ||||
-rw-r--r-- | spec/services/issues/reopen_service_spec.rb | 10 | ||||
-rw-r--r-- | spec/services/issues/update_service_spec.rb | 54 |
4 files changed, 92 insertions, 2 deletions
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index eb3b1d7c754..141567045a2 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -178,35 +178,55 @@ describe Issues::CloseService do end context "valid params" do - before do + def close_issue perform_enqueued_jobs do described_class.new(project, user).close_issue(issue) end end it 'closes the issue' do + close_issue + expect(issue).to be_valid expect(issue).to be_closed end it 'records closed user' do + close_issue + expect(issue.closed_by_id).to be(user.id) end it 'sends email to user2 about assign of new issue', :sidekiq_might_not_need_inline do + close_issue + email = ActionMailer::Base.deliveries.last expect(email.to.first).to eq(user2.email) expect(email.subject).to include(issue.title) end it 'creates system note about issue reassign' do + close_issue + note = issue.notes.last expect(note.note).to include "closed" end it 'marks todos as done' do + close_issue + expect(todo.reload).to be_done end + + it 'deletes milestone issue counters cache' do + issue.update(milestone: create(:milestone, project: project)) + + expect_next_instance_of(Milestones::ClosedIssuesCountService, issue.milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + + close_issue + end end context 'when issue is not confidential' do diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index c9701e5d194..09fff389cec 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -196,6 +196,14 @@ describe Issues::CreateService do end 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 end context 'issue create service' do diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb index f04029e64aa..ca878ee947a 100644 --- a/spec/services/issues/reopen_service_spec.rb +++ b/spec/services/issues/reopen_service_spec.rb @@ -43,6 +43,16 @@ describe Issues::ReopenService do .to change { project.open_issues_count }.from(0).to(1) end + it 'deletes milestone issue counters cache' do + issue.update(milestone: create(:milestone, project: project)) + + expect_next_instance_of(Milestones::ClosedIssuesCountService, issue.milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + + described_class.new(project, user).execute(issue) + end + context 'when issue is not confidential' do it 'executes issue hooks' do expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks) diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 5da77dd914c..69e47d890a5 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -412,9 +412,24 @@ describe Issues::UpdateService, :mailer do should_email(subscriber) should_not_email(non_subscriber) end + + it 'clears milestone issue counters cache' do + issue.milestone = create(:milestone, project: project) + + issue.save + + expect_next_instance_of(Milestones::IssuesCountService, issue.milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + expect_next_instance_of(Milestones::ClosedIssuesCountService, issue.milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + + update_issue(milestone_id: "") + end end - context 'when the milestone is changed' do + context 'when the milestone is assigned' do before do stub_feature_flags(track_resource_milestone_change_events: false) end @@ -444,6 +459,43 @@ describe Issues::UpdateService, :mailer do should_email(subscriber) should_not_email(non_subscriber) end + + it 'deletes issue counters cache for the milestone' do + milestone = create(:milestone, project: project) + + expect_next_instance_of(Milestones::IssuesCountService, milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + expect_next_instance_of(Milestones::ClosedIssuesCountService, milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + + update_issue(milestone: milestone) + end + end + + context 'when the milestone is changed' do + it 'deletes issue counters cache for both milestones' do + old_milestone = create(:milestone, project: project) + new_milestone = create(:milestone, project: project) + + issue.update!(milestone: old_milestone) + + expect_next_instance_of(Milestones::IssuesCountService, old_milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + expect_next_instance_of(Milestones::ClosedIssuesCountService, old_milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + expect_next_instance_of(Milestones::IssuesCountService, new_milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + expect_next_instance_of(Milestones::ClosedIssuesCountService, new_milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + + update_issue(milestone: new_milestone) + end end context 'when the labels change' do |