diff options
author | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2019-01-17 19:27:20 +0100 |
---|---|---|
committer | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2019-03-14 18:39:54 +0100 |
commit | b0981097c302dd04df23ec557b4dcce5c952f2bf (patch) | |
tree | eabd150a7f7ad5ce71ac25470e8ad946084bfc18 /spec/requests/api/search_spec.rb | |
parent | 6385c7229cd61eb46b75bcd7441782954a46f1b7 (diff) | |
download | gitlab-ce-b0981097c302dd04df23ec557b4dcce5c952f2bf.tar.gz |
return 400 on users search and feature is disabled
as the params block is evaluated when loading the class and the db
connection is not available yet we can't use the feature toggle inside
that block.
Diffstat (limited to 'spec/requests/api/search_spec.rb')
-rw-r--r-- | spec/requests/api/search_spec.rb | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb index 0f539fb6c60..49672591b3b 100644 --- a/spec/requests/api/search_spec.rb +++ b/spec/requests/api/search_spec.rb @@ -81,10 +81,22 @@ describe API::Search do before do create(:user, name: 'billy') - get api('/search', user), scope: 'users', search: 'billy' + get api('/search', user), params: { scope: 'users', search: 'billy' } end it_behaves_like 'response is correct', schema: 'public_api/v4/user/basics' + + context 'when users search feature is disabled' do + before do + allow(Feature).to receive(:disabled?).with(:users_search, default_enabled: true).and_return(true) + + get api('/search', user), params: { scope: 'users', search: 'billy' } + end + + it 'returns 400 error' do + expect(response).to have_gitlab_http_status(400) + end + end end context 'for snippet_titles scope' do @@ -203,15 +215,27 @@ describe API::Search do it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' end - context 'for user scope' do + context 'for users scope' do before do user = create(:user, name: 'billy') create(:group_member, :developer, user: user, group: group) - get api("/groups/#{group.id}/search", user), scope: 'users', search: 'billy' + get api("/groups/#{group.id}/search", user), params: { scope: 'users', search: 'billy' } end it_behaves_like 'response is correct', schema: 'public_api/v4/user/basics' + + context 'when users search feature is disabled' do + before do + allow(Feature).to receive(:disabled?).with(:users_search, default_enabled: true).and_return(true) + + get api("/groups/#{group.id}/search", user), params: { scope: 'users', search: 'billy' } + end + + it 'returns 400 error' do + expect(response).to have_gitlab_http_status(400) + end + end end context 'for users scope with group path as id' do @@ -219,7 +243,7 @@ describe API::Search do user1 = create(:user, name: 'billy') create(:group_member, :developer, user: user1, group: group) - get api("/groups/#{CGI.escape(group.full_path)}/search", user), scope: 'users', search: 'billy' + get api("/groups/#{CGI.escape(group.full_path)}/search", user), params: { scope: 'users', search: 'billy' } end it_behaves_like 'response is correct', schema: 'public_api/v4/user/basics' @@ -306,10 +330,22 @@ describe API::Search do user1 = create(:user, name: 'billy') create(:project_member, :developer, user: user1, project: project) - get api("/projects/#{project.id}/search", user), scope: 'users', search: 'billy' + get api("/projects/#{project.id}/search", user), params: { scope: 'users', search: 'billy' } end it_behaves_like 'response is correct', schema: 'public_api/v4/user/basics' + + context 'when users search feature is disabled' do + before do + allow(Feature).to receive(:disabled?).with(:users_search, default_enabled: true).and_return(true) + + get api("/projects/#{project.id}/search", user), params: { scope: 'users', search: 'billy' } + end + + it 'returns 400 error' do + expect(response).to have_gitlab_http_status(400) + end + end end context 'for notes scope' do |