Commit 1545e679 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '226924-gitaly-n-1-queries-in-mergerequests-draftscontroller-3' into 'master'

Remove a "keep around commit" callback for the Note model

See merge request gitlab-org/gitlab!69910
parents 50d889ba 6da02525
...@@ -149,7 +149,7 @@ class Note < ApplicationRecord ...@@ -149,7 +149,7 @@ class Note < ApplicationRecord
scope :like_note_or_capitalized_note, ->(text) { where('(note LIKE ? OR note LIKE ?)', text, text.capitalize) } scope :like_note_or_capitalized_note, ->(text) { where('(note LIKE ? OR note LIKE ?)', text, text.capitalize) }
before_validation :nullify_blank_type, :nullify_blank_line_code before_validation :nullify_blank_type, :nullify_blank_line_code
after_save :keep_around_commit, if: :for_project_noteable?, unless: :importing? after_save :keep_around_commit, if: :for_project_noteable?, unless: -> { importing? || skip_keep_around_commits }
after_save :expire_etag_cache, unless: :importing? after_save :expire_etag_cache, unless: :importing?
after_save :touch_noteable, unless: :importing? after_save :touch_noteable, unless: :importing?
after_destroy :expire_etag_cache after_destroy :expire_etag_cache
......
...@@ -108,6 +108,34 @@ RSpec.describe Note do ...@@ -108,6 +108,34 @@ RSpec.describe Note do
end end
describe 'callbacks' do describe 'callbacks' do
describe '#keep_around_commit' do
let!(:noteable) { create(:issue) }
it "calls #keep_around_commit normally" do
note = build(:note, project: noteable.project, noteable: noteable)
expect(note).to receive(:keep_around_commit)
note.save!
end
it "skips #keep_around_commit if 'skip_keep_around_commits' is true" do
note = build(:note, project: noteable.project, noteable: noteable, skip_keep_around_commits: true)
expect(note).not_to receive(:keep_around_commit)
note.save!
end
it "skips #keep_around_commit if 'importing' is true" do
note = build(:note, project: noteable.project, noteable: noteable, importing: true)
expect(note).not_to receive(:keep_around_commit)
note.save!
end
end
describe '#notify_after_create' do describe '#notify_after_create' do
it 'calls #after_note_created on the noteable' do it 'calls #after_note_created on the noteable' do
noteable = create(:issue) noteable = create(:issue)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment