diff options
Diffstat (limited to 'spec/services/milestones')
3 files changed, 67 insertions, 0 deletions
diff --git a/spec/services/milestones/closed_issues_count_service_spec.rb b/spec/services/milestones/closed_issues_count_service_spec.rb new file mode 100644 index 00000000000..b86eede2e22 --- /dev/null +++ b/spec/services/milestones/closed_issues_count_service_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Milestones::ClosedIssuesCountService, :use_clean_rails_memory_store_caching do + let(:project) { create(:project) } + let(:milestone) { create(:milestone, project: project) } + + before do + create(:issue, milestone: milestone, project: project) + create(:issue, :confidential, milestone: milestone, project: project) + + create(:issue, :closed, milestone: milestone, project: project) + create(:issue, :closed, :confidential, milestone: milestone, project: project) + end + + subject { described_class.new(milestone) } + + it_behaves_like 'a counter caching service' + + it 'counts closed issues including confidential' do + expect(subject.count).to eq(2) + end +end diff --git a/spec/services/milestones/issues_count_service_spec.rb b/spec/services/milestones/issues_count_service_spec.rb new file mode 100644 index 00000000000..22aea884424 --- /dev/null +++ b/spec/services/milestones/issues_count_service_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Milestones::IssuesCountService, :use_clean_rails_memory_store_caching do + let(:project) { create(:project) } + let(:milestone) { create(:milestone, project: project) } + + before do + create(:issue, milestone: milestone, project: project) + create(:issue, :confidential, milestone: milestone, project: project) + + create(:issue, :closed, milestone: milestone, project: project) + create(:issue, :closed, milestone: milestone, project: project) + end + + subject { described_class.new(milestone) } + + it_behaves_like 'a counter caching service' + + it 'counts all issues including confidential' do + expect(subject.count).to eq(4) + end +end diff --git a/spec/services/milestones/transfer_service_spec.rb b/spec/services/milestones/transfer_service_spec.rb index 711969ce504..9b087b07cea 100644 --- a/spec/services/milestones/transfer_service_spec.rb +++ b/spec/services/milestones/transfer_service_spec.rb @@ -40,6 +40,25 @@ describe Milestones::TransferService do expect(new_milestone.project_milestone?).to be_truthy end + it 'deletes milestone issue counters cache for both milestones' do + new_milestone = create(:milestone, project: project, title: group_milestone.title) + + expect_next_instance_of(Milestones::IssuesCountService, group_milestone) do |service| + expect(service).to receive(:delete_cache).and_call_original + end + expect_next_instance_of(Milestones::ClosedIssuesCountService, group_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 + + service.execute + end + it 'does not apply new project milestone to issues with project milestone' do service.execute |