From aefefbf11701042ae59a60818e3f957b30831dfd Mon Sep 17 00:00:00 2001 From: Felipe Artur Date: Mon, 13 Nov 2017 16:38:15 -0200 Subject: [PATCH] Prevents position update for image diff notes --- app/models/diff_note.rb | 3 ++- changelogs/unreleased/issue_40058.yml | 5 +++++ spec/models/diff_note_spec.rb | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/issue_40058.yml diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb index d88a92dc027..ae5f138a920 100644 --- a/app/models/diff_note.rb +++ b/app/models/diff_note.rb @@ -18,7 +18,8 @@ class DiffNote < Note validate :positions_complete validate :verify_supported - before_validation :set_original_position, :update_position, on: :create + before_validation :set_original_position, on: :create + before_validation :update_position, on: :create, if: :on_text? before_validation :set_line_code after_save :keep_around_commits diff --git a/changelogs/unreleased/issue_40058.yml b/changelogs/unreleased/issue_40058.yml new file mode 100644 index 00000000000..46e83d947ba --- /dev/null +++ b/changelogs/unreleased/issue_40058.yml @@ -0,0 +1,5 @@ +--- +title: Prevents position update for image diff notes +merge_request: +author: +type: fixed diff --git a/spec/models/diff_note_spec.rb b/spec/models/diff_note_spec.rb index da972d2d86a..8389d5c5430 100644 --- a/spec/models/diff_note_spec.rb +++ b/spec/models/diff_note_spec.rb @@ -283,6 +283,12 @@ describe DiffNote do expect(diff_line).to be nil expect(subject).to be_valid end + + it "does not update the position" do + expect(subject).not_to receive(:update_position) + + subject.save + end end it "returns true for on_image?" do