summaryrefslogtreecommitdiff
path: root/spec/services/milestones
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/milestones')
-rw-r--r--spec/services/milestones/destroy_service_spec.rb14
-rw-r--r--spec/services/milestones/merge_requests_count_service_spec.rb21
-rw-r--r--spec/services/milestones/transfer_service_spec.rb8
3 files changed, 36 insertions, 7 deletions
diff --git a/spec/services/milestones/destroy_service_spec.rb b/spec/services/milestones/destroy_service_spec.rb
index dd68471d927..6c08b7db43a 100644
--- a/spec/services/milestones/destroy_service_spec.rb
+++ b/spec/services/milestones/destroy_service_spec.rb
@@ -22,14 +22,16 @@ RSpec.describe Milestones::DestroyService do
expect { milestone.reload }.to raise_error ActiveRecord::RecordNotFound
end
- it 'deletes milestone id from issuables' do
- issue = create(:issue, project: project, milestone: milestone)
- merge_request = create(:merge_request, source_project: project, milestone: milestone)
+ context 'with an existing merge request' do
+ let!(:issue) { create(:issue, project: project, milestone: milestone) }
+ let!(:merge_request) { create(:merge_request, source_project: project, milestone: milestone) }
- service.execute(milestone)
+ it 'deletes milestone id from issuables' do
+ service.execute(milestone)
- expect(issue.reload.milestone).to be_nil
- expect(merge_request.reload.milestone).to be_nil
+ expect(issue.reload.milestone).to be_nil
+ expect(merge_request.reload.milestone).to be_nil
+ end
end
it 'logs destroy event' do
diff --git a/spec/services/milestones/merge_requests_count_service_spec.rb b/spec/services/milestones/merge_requests_count_service_spec.rb
new file mode 100644
index 00000000000..aecc7d5ef52
--- /dev/null
+++ b/spec/services/milestones/merge_requests_count_service_spec.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Milestones::MergeRequestsCountService, :use_clean_rails_memory_store_caching do
+ let_it_be(:project) { create(:project, :empty_repo) }
+ let_it_be(:milestone) { create(:milestone, project: project) }
+
+ before_all do
+ create(:merge_request, milestone: milestone, source_project: project)
+ create(:merge_request, :closed, milestone: milestone, source_project: project)
+ end
+
+ subject { described_class.new(milestone) }
+
+ it_behaves_like 'a counter caching service'
+
+ it 'counts all merge requests' do
+ expect(subject.count).to eq(2)
+ end
+end
diff --git a/spec/services/milestones/transfer_service_spec.rb b/spec/services/milestones/transfer_service_spec.rb
index 6f4f55b2bd0..afbc9c7dca2 100644
--- a/spec/services/milestones/transfer_service_spec.rb
+++ b/spec/services/milestones/transfer_service_spec.rb
@@ -50,7 +50,7 @@ RSpec.describe Milestones::TransferService do
end
end
- it 'deletes milestone issue counters cache for both milestones' do
+ it 'deletes milestone 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|
@@ -59,12 +59,18 @@ RSpec.describe Milestones::TransferService do
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::MergeRequestsCountService, 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
+ expect_next_instance_of(Milestones::MergeRequestsCountService, new_milestone) do |service|
+ expect(service).to receive(:delete_cache).and_call_original
+ end
service.execute
end