diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-30 15:32:09 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-03 14:47:21 -0500 |
commit | f8fabfcc6ff6be4e20e3cc9353be86b7cf53af47 (patch) | |
tree | 15816b09ecdebbd4eb797195b90cb4f46b6819c4 /spec/models/diff_note_spec.rb | |
parent | 185fd98fd4cb8f920558aea3795c4e1774cd39f5 (diff) | |
download | gitlab-ce-f8fabfcc6ff6be4e20e3cc9353be86b7cf53af47.tar.gz |
Allow commenting on older versions of the diff and comparisons between diff versionsdm-link-discussion-to-outdated-diff
Diffstat (limited to 'spec/models/diff_note_spec.rb')
-rw-r--r-- | spec/models/diff_note_spec.rb | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/spec/models/diff_note_spec.rb b/spec/models/diff_note_spec.rb index f32b6b99b3d..ab4c51a87b0 100644 --- a/spec/models/diff_note_spec.rb +++ b/spec/models/diff_note_spec.rb @@ -155,23 +155,6 @@ describe DiffNote, models: true do end end - describe '#latest_merge_request_diff' do - context 'when active' do - it 'returns the current merge request diff' do - expect(subject.latest_merge_request_diff).to eq(merge_request.merge_request_diff) - end - end - - context 'when outdated' do - let!(:old_merge_request_diff) { merge_request.merge_request_diff } - let!(:new_merge_request_diff) { merge_request.merge_request_diffs.create(diff_refs: commit.diff_refs) } - - it 'returns the latest merge request diff that this diff note applied to' do - expect(subject.latest_merge_request_diff).to eq(old_merge_request_diff) - end - end - end - describe "creation" do describe "updating of position" do context "when noteable is a commit" do @@ -256,4 +239,39 @@ describe DiffNote, models: true do end end end + + describe '#created_at_diff?' do + let(:diff_refs) { project.commit(sample_commit.id).diff_refs } + let(:position) do + Gitlab::Diff::Position.new( + old_path: "files/ruby/popen.rb", + new_path: "files/ruby/popen.rb", + old_line: nil, + new_line: 14, + diff_refs: diff_refs + ) + end + + context "when noteable is a commit" do + subject { build(:diff_note_on_commit, project: project, position: position) } + + it "returns true" do + expect(subject.created_at_diff?(diff_refs)).to be true + end + end + + context "when noteable is a merge request" do + context "when the diff refs match the original one of the diff note" do + it "returns true" do + expect(subject.created_at_diff?(diff_refs)).to be true + end + end + + context "when the diff refs don't match the original one of the diff note" do + it "returns false" do + expect(subject.created_at_diff?(merge_request.diff_refs)).to be false + end + end + end + end end |