diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 21:08:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 21:08:58 +0300 |
commit | ed16c9434ed73f68f84935b3b283baeacc632200 (patch) | |
tree | 4a75983976d001d9bb275a345f9f5fcf40685c6b /spec/models | |
parent | 874c603d7a21724885ed24f15f457146aa1497c2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/concerns/noteable_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/concerns/noteable_spec.rb b/spec/models/concerns/noteable_spec.rb index 5c8c5425ca7..3fdd707420f 100644 --- a/spec/models/concerns/noteable_spec.rb +++ b/spec/models/concerns/noteable_spec.rb @@ -262,4 +262,44 @@ describe Noteable do end end end + + describe "#has_any_diff_note_positions?" do + let(:source_branch) { "compare-with-merge-head-source" } + let(:target_branch) { "compare-with-merge-head-target" } + let(:merge_request) { create(:merge_request, source_branch: source_branch, target_branch: target_branch) } + + let!(:note) do + path = "files/markdown/ruby-style-guide.md" + + position = Gitlab::Diff::Position.new( + old_path: path, + new_path: path, + new_line: 508, + diff_refs: merge_request.diff_refs + ) + + create(:diff_note_on_merge_request, project: merge_request.project, position: position, noteable: merge_request) + end + + before do + MergeRequests::MergeToRefService.new(merge_request.project, merge_request.author).execute(merge_request) + Discussions::CaptureDiffNotePositionsService.new(merge_request).execute + end + + it "returns true when it has diff note positions" do + expect(merge_request.has_any_diff_note_positions?).to be(true) + end + + it "returns false when it has notes but no diff note positions" do + DiffNotePosition.where(note: note).find_each(&:delete) + + expect(merge_request.has_any_diff_note_positions?).to be(false) + end + + it "returns false when it has no notes" do + merge_request.notes.find_each(&:destroy) + + expect(merge_request.has_any_diff_note_positions?).to be(false) + end + end end |