summaryrefslogtreecommitdiff
path: root/spec/controllers/search_controller_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-18 20:02:30 +0000
commit41fe97390ceddf945f3d967b8fdb3de4c66b7dea (patch)
tree9c8d89a8624828992f06d892cd2f43818ff5dcc8 /spec/controllers/search_controller_spec.rb
parent0804d2dc31052fb45a1efecedc8e06ce9bc32862 (diff)
downloadgitlab-ce-41fe97390ceddf945f3d967b8fdb3de4c66b7dea.tar.gz
Add latest changes from gitlab-org/gitlab@14-9-stable-eev14.9.0-rc42
Diffstat (limited to 'spec/controllers/search_controller_spec.rb')
-rw-r--r--spec/controllers/search_controller_spec.rb30
1 files changed, 25 insertions, 5 deletions
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index 0f1501d4c3c..9482448fc03 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -251,8 +251,8 @@ RSpec.describe SearchController do
it_behaves_like 'tracking unique hll events' do
subject(:request) { get :show, params: { scope: 'projects', search: 'term' } }
- let(:target_id) { 'i_search_total' }
- let(:expected_type) { instance_of(String) }
+ let(:target_event) { 'i_search_total' }
+ let(:expected_value) { instance_of(String) }
end
end
@@ -291,7 +291,7 @@ RSpec.describe SearchController do
end
end
- it_behaves_like 'rate limited endpoint', rate_limit_key: :user_email_lookup do
+ it_behaves_like 'rate limited endpoint', rate_limit_key: :search_rate_limit do
let(:current_user) { user }
def request
@@ -355,7 +355,7 @@ RSpec.describe SearchController do
expect(json_response).to eq({ 'count' => '0' })
end
- it_behaves_like 'rate limited endpoint', rate_limit_key: :user_email_lookup do
+ it_behaves_like 'rate limited endpoint', rate_limit_key: :search_rate_limit do
let(:current_user) { user }
def request
@@ -375,7 +375,7 @@ RSpec.describe SearchController do
expect(json_response).to match_array([])
end
- it_behaves_like 'rate limited endpoint', rate_limit_key: :user_email_lookup do
+ it_behaves_like 'rate limited endpoint', rate_limit_key: :search_rate_limit do
let(:current_user) { user }
def request
@@ -445,6 +445,26 @@ RSpec.describe SearchController do
end
context 'unauthorized user' do
+ describe 'search rate limits' do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:project) { create(:project, :public) }
+
+ where(:endpoint, :params) do
+ :show | { search: 'hello', scope: 'projects' }
+ :count | { search: 'hello', scope: 'projects' }
+ :autocomplete | { term: 'hello', scope: 'projects' }
+ end
+
+ with_them do
+ it_behaves_like 'rate limited endpoint', rate_limit_key: :search_rate_limit_unauthenticated do
+ def request
+ get endpoint, params: params.merge(project_id: project.id)
+ end
+ end
+ end
+ end
+
describe 'GET #opensearch' do
render_views