Commit aa389f6a authored by James Lopez's avatar James Lopez

Merge branch 'bw-reference-user-caching' into 'master'

Check for N+1 in UserReferenceFilter

See merge request gitlab-org/gitlab!61514
parents 206d96ac e443e147
......@@ -201,4 +201,25 @@ RSpec.describe Banzai::Filter::References::UserReferenceFilter do
expect(filter.send(:usernames)).to eq([user.username])
end
end
context 'checking N+1' do
let(:user2) { create(:user) }
let(:group) { create(:group) }
let(:reference2) { user2.to_reference }
let(:reference3) { group.to_reference }
it 'does not have N+1 per multiple user references', :use_sql_query_cache do
markdown = "#{reference}"
control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
reference_filter(markdown)
end.count
markdown = "#{reference} @qwertyuiopzx @wertyuio @ertyu @rtyui #{reference2} #{reference3}"
expect do
reference_filter(markdown)
end.not_to exceed_all_query_limit(control_count)
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