diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-13 15:10:02 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-13 15:10:02 +0300 |
commit | 3748ae5cbbefd3de0111951e71e74b676c276d61 (patch) | |
tree | ec12be349757c64eafaafdacd0eb7699adff113b /spec/lib/banzai | |
parent | 19325d74c2a5e7f367c6d1d6a064650f90a5b3e7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/banzai')
-rw-r--r-- | spec/lib/banzai/filter/references/user_reference_filter_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/lib/banzai/filter/references/user_reference_filter_spec.rb b/spec/lib/banzai/filter/references/user_reference_filter_spec.rb index d9111903c7d..70cbdb080a4 100644 --- a/spec/lib/banzai/filter/references/user_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/references/user_reference_filter_spec.rb @@ -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 |