diff options
author | Bob Van Landuyt <bob@gitlab.com> | 2017-03-09 13:38:53 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@gitlab.com> | 2017-03-13 10:27:51 +0300 |
commit | 67bd277ae6e7246543b2aeaf83a9c39412e18d05 (patch) | |
tree | e2e18350329f3ea93b62b97acf59f210f68aa12b /spec/services/issues | |
parent | 5681104925be658aad97ea37896428d9618f772f (diff) |
Make sure the for a merge request only gets executed once.
Diffstat (limited to 'spec/services/issues')
-rw-r--r-- | spec/services/issues/resolve_discussions_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/services/issues/resolve_discussions_spec.rb b/spec/services/issues/resolve_discussions_spec.rb index 332927d10ad..a7175398aa1 100644 --- a/spec/services/issues/resolve_discussions_spec.rb +++ b/spec/services/issues/resolve_discussions_spec.rb @@ -22,6 +22,25 @@ describe DummyService, services: true do let(:merge_request) { discussion.noteable } let(:other_merge_request) { create(:merge_request, source_project: project, source_branch: "other") } + describe "#merge_request_for_resolving_discussion" do + let(:service) { described_class.new(project, user, merge_request_for_resolving_discussions: merge_request.iid) } + + it "finds the merge request" do + expect(service.merge_request_for_resolving_discussions).to eq(merge_request) + end + + it "only queries for the merge request once" do + fake_finder = double + fake_results = double + + expect(fake_finder).to receive(:execute).and_return(fake_results).exactly(1) + expect(fake_results).to receive(:find_by).exactly(1) + expect(MergeRequestsFinder).to receive(:new).and_return(fake_finder).exactly(1) + + 2.times { service.merge_request_for_resolving_discussions } + end + end + describe "#discussions_to_resolve" do it "contains a single discussion when matching merge request and discussion are passed" do service = described_class.new( |