Commit e443e147 authored by Brett Walker's avatar Brett Walker

Check for N+1 in UserReferenceFilter

parent 71dee555
......@@ -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