Commit 837a6eba authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sh-disable-store-mentions-import' into 'master'

Disable creating user mentions during import

See merge request gitlab-org/gitlab!66792
parents b6755388 d11191f1
......@@ -10,7 +10,9 @@ module Gitlab
# Using before_update here conflicts with elasticsearch-model somehow
before_create :refresh_markdown_cache, if: :invalidated_markdown_cache?
before_update :refresh_markdown_cache, if: :invalidated_markdown_cache?
after_save :store_mentions!, if: :mentionable_attributes_changed?
# The import case needs to be fixed to avoid large number of
# SQL queries: https://gitlab.com/gitlab-org/gitlab/-/issues/21801
after_save :store_mentions!, if: :mentionable_attributes_changed?, unless: ->(obj) { obj.is_a?(Importable) && obj.importing? }
end
# Always exclude _html fields from attributes (including serialization).
......
......@@ -178,4 +178,42 @@ RSpec.describe Gitlab::MarkdownCache::ActiveRecord::Extension do
thing.refresh_markdown_cache!
end
end
context 'with note' do
let(:klass) do
Class.new(ActiveRecord::Base) do
self.table_name = 'notes'
include CacheMarkdownField
include Importable
include Mentionable
attr_mentionable :note, pipeline: :note
cache_markdown_field :note, pipeline: :note
end
end
let(:thing) { klass.new(note: markdown) }
before do
thing.note = "hello world"
end
it 'calls store_mentions!' do
expect(thing).to receive(:store_mentions!).and_call_original
thing.save!
end
context 'during import' do
before do
thing.importing = true
end
it 'does not call store_mentions!' do
expect(thing).not_to receive(:store_mentions!)
thing.save!
end
end
end
end
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