Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/search_controller_spec.rb')
-rw-r--r--spec/controllers/search_controller_spec.rb67
1 files changed, 23 insertions, 44 deletions
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index b4d4e01e972..14b198dbefe 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -12,47 +12,6 @@ RSpec.describe SearchController do
sign_in(user)
end
- shared_examples_for 'when the user cannot read cross project' do |action, params|
- before do
- allow(Ability).to receive(:allowed?).and_call_original
- allow(Ability).to receive(:allowed?)
- .with(user, :read_cross_project, :global) { false }
- end
-
- it 'blocks access without a project_id' do
- get action, params: params
-
- expect(response).to have_gitlab_http_status(:forbidden)
- end
-
- it 'allows access with a project_id' do
- get action, params: params.merge(project_id: create(:project, :public).id)
-
- expect(response).to have_gitlab_http_status(:ok)
- end
- end
-
- shared_examples_for 'with external authorization service enabled' do |action, params|
- let(:project) { create(:project, namespace: user.namespace) }
- let(:note) { create(:note_on_issue, project: project) }
-
- before do
- enable_external_authorization_service_check
- end
-
- it 'renders a 403 when no project is given' do
- get action, params: params
-
- expect(response).to have_gitlab_http_status(:forbidden)
- end
-
- it 'renders a 200 when a project was set' do
- get action, params: params.merge(project_id: project.id)
-
- expect(response).to have_gitlab_http_status(:ok)
- end
- end
-
shared_examples_for 'support for active record query timeouts' do |action, params, method_to_stub, format|
before do
allow_next_instance_of(SearchService) do |service|
@@ -133,10 +92,11 @@ RSpec.describe SearchController do
{
chars_under_limit: (('a' * (term_char_limit - 1) + ' ') * (term_limit - 1))[0, char_limit],
chars_over_limit: (('a' * (term_char_limit - 1) + ' ') * (term_limit - 1))[0, char_limit + 1],
- terms_under_limit: ('abc ' * (term_limit - 1)),
+ terms_under_limit: ('abc ' * (term_limit - 1)),
terms_over_limit: ('abc ' * (term_limit + 1)),
term_length_over_limit: ('a' * (term_char_limit + 1)),
- term_length_under_limit: ('a' * (term_char_limit - 1))
+ term_length_under_limit: ('a' * (term_char_limit - 1)),
+ blank: ''
}
end
@@ -147,6 +107,7 @@ RSpec.describe SearchController do
:terms_over_limit | :set_terms_flash
:term_length_under_limit | :not_to_set_flash
:term_length_over_limit | :not_to_set_flash # abuse, so do nothing.
+ :blank | :not_to_set_flash
end
with_them do
@@ -393,6 +354,13 @@ RSpec.describe SearchController do
get(:autocomplete, params: { term: 'foo@bar.com', scope: 'users' })
end
end
+
+ it 'can be filtered with params[:filter]' do
+ get :autocomplete, params: { term: 'setting', filter: 'generic' }
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(json_response.count).to eq(1)
+ expect(json_response.first['label']).to match(/User settings/)
+ end
end
describe '#append_info_to_payload' do
@@ -410,9 +378,20 @@ RSpec.describe SearchController do
expect(payload[:metadata]['meta.search.project_ids']).to eq(%w(456 789))
expect(payload[:metadata]['meta.search.type']).to eq('basic')
expect(payload[:metadata]['meta.search.level']).to eq('global')
+ expect(payload[:metadata]['meta.search.filters.language']).to eq('ruby')
end
- get :show, params: { scope: 'issues', search: 'hello world', group_id: '123', project_id: '456', project_ids: %w(456 789), confidential: true, state: true, force_search_results: true }
+ get :show, params: {
+ scope: 'issues',
+ search: 'hello world',
+ group_id: '123',
+ project_id: '456',
+ project_ids: %w(456 789),
+ confidential: true,
+ state: true,
+ force_search_results: true,
+ language: 'ruby'
+ }
end
it 'appends the default scope in meta.search.scope' do