diff options
Diffstat (limited to 'spec/lib/gitlab/search/params_spec.rb')
-rw-r--r-- | spec/lib/gitlab/search/params_spec.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/lib/gitlab/search/params_spec.rb b/spec/lib/gitlab/search/params_spec.rb index 3235a0b2126..3c64082aeeb 100644 --- a/spec/lib/gitlab/search/params_spec.rb +++ b/spec/lib/gitlab/search/params_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Gitlab::Search::Params, feature_category: :global_search do end it 'uses AbuseDetection by default' do - expect(Gitlab::Search::AbuseDetection).to receive(:new).and_call_original + expect(Gitlab::Search::AbuseDetection).to receive(:new).at_least(:once).and_call_original described_class.new(params) end end @@ -73,9 +73,21 @@ RSpec.describe Gitlab::Search::Params, feature_category: :global_search do end it 'validates AbuseDetector on validation' do - expect(Gitlab::Search::AbuseDetection).to receive(:new).and_call_original + expect(Gitlab::Search::AbuseDetection).to receive(:new).at_least(:once).and_call_original subject.validate end + + context 'when query has too many terms' do + let(:search) { Array.new((::Gitlab::Search::Params::SEARCH_TERM_LIMIT + 1), 'a').join(' ') } + + it { is_expected.not_to be_valid } + end + + context 'when query is too long' do + let(:search) { 'a' * (::Gitlab::Search::Params::SEARCH_CHAR_LIMIT + 1) } + + it { is_expected.not_to be_valid } + end end describe '#valid?' do @@ -89,7 +101,7 @@ RSpec.describe Gitlab::Search::Params, feature_category: :global_search do end it 'validates AbuseDetector on validation' do - expect(Gitlab::Search::AbuseDetection).to receive(:new).and_call_original + expect(Gitlab::Search::AbuseDetection).to receive(:new).at_least(:once).and_call_original subject.valid? end end |