diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-12-18 01:52:17 +0300 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-12-19 02:04:31 +0300 |
commit | b44a2c801a64fb282cea794871fcfcf81e4ec539 (patch) | |
tree | 32e699b6efa548048abe11f29f84e85e3d2a034f /spec/requests | |
parent | 5d68c23792e87e710877e4baf57605bcf11a6cb5 (diff) |
Update specs to rails5 format
Updates specs to use new rails5 format.
The old format:
`get :show, { some: params }, { some: headers }`
The new format:
`get :show, params: { some: params }, headers: { some: headers }`
Diffstat (limited to 'spec/requests')
68 files changed, 1341 insertions, 1197 deletions
diff --git a/spec/requests/api/access_requests_spec.rb b/spec/requests/api/access_requests_spec.rb index e13129967b2..1af6602ea9e 100644 --- a/spec/requests/api/access_requests_spec.rb +++ b/spec/requests/api/access_requests_spec.rb @@ -145,7 +145,7 @@ describe API::AccessRequests do it 'returns 201' do expect do put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", maintainer), - access_level: Member::MAINTAINER + params: { access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) diff --git a/spec/requests/api/applications_spec.rb b/spec/requests/api/applications_spec.rb index 6154be5c425..e47166544d9 100644 --- a/spec/requests/api/applications_spec.rb +++ b/spec/requests/api/applications_spec.rb @@ -11,7 +11,7 @@ describe API::Applications, :api do context 'authenticated and authorized user' do it 'creates and returns an OAuth application' do expect do - post api('/applications', admin_user), name: 'application_name', redirect_uri: 'http://application.url', scopes: '' + post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://application.url', scopes: '' } end.to change { Doorkeeper::Application.count }.by 1 application = Doorkeeper::Application.find_by(name: 'application_name', redirect_uri: 'http://application.url') @@ -25,7 +25,7 @@ describe API::Applications, :api do it 'does not allow creating an application with the wrong redirect_uri format' do expect do - post api('/applications', admin_user), name: 'application_name', redirect_uri: 'http://', scopes: '' + post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://', scopes: '' } end.not_to change { Doorkeeper::Application.count } expect(response).to have_gitlab_http_status(400) @@ -35,7 +35,7 @@ describe API::Applications, :api do it 'does not allow creating an application with a forbidden URI format' do expect do - post api('/applications', admin_user), name: 'application_name', redirect_uri: 'javascript://alert()', scopes: '' + post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'javascript://alert()', scopes: '' } end.not_to change { Doorkeeper::Application.count } expect(response).to have_gitlab_http_status(400) @@ -45,7 +45,7 @@ describe API::Applications, :api do it 'does not allow creating an application without a name' do expect do - post api('/applications', admin_user), redirect_uri: 'http://application.url', scopes: '' + post api('/applications', admin_user), params: { redirect_uri: 'http://application.url', scopes: '' } end.not_to change { Doorkeeper::Application.count } expect(response).to have_gitlab_http_status(400) @@ -55,7 +55,7 @@ describe API::Applications, :api do it 'does not allow creating an application without a redirect_uri' do expect do - post api('/applications', admin_user), name: 'application_name', scopes: '' + post api('/applications', admin_user), params: { name: 'application_name', scopes: '' } end.not_to change { Doorkeeper::Application.count } expect(response).to have_gitlab_http_status(400) @@ -65,7 +65,7 @@ describe API::Applications, :api do it 'does not allow creating an application without scopes' do expect do - post api('/applications', admin_user), name: 'application_name', redirect_uri: 'http://application.url' + post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://application.url' } end.not_to change { Doorkeeper::Application.count } expect(response).to have_gitlab_http_status(400) @@ -77,7 +77,7 @@ describe API::Applications, :api do context 'authorized user without authorization' do it 'does not create application' do expect do - post api('/applications', user), name: 'application_name', redirect_uri: 'http://application.url', scopes: '' + post api('/applications', user), params: { name: 'application_name', redirect_uri: 'http://application.url', scopes: '' } end.not_to change { Doorkeeper::Application.count } expect(response).to have_gitlab_http_status(403) @@ -87,7 +87,7 @@ describe API::Applications, :api do context 'non-authenticated user' do it 'does not create application' do expect do - post api('/applications'), name: 'application_name', redirect_uri: 'http://application.url' + post api('/applications'), params: { name: 'application_name', redirect_uri: 'http://application.url' } end.not_to change { Doorkeeper::Application.count } expect(response).to have_gitlab_http_status(401) diff --git a/spec/requests/api/avatar_spec.rb b/spec/requests/api/avatar_spec.rb index 26e0435a6d5..17e66725dc9 100644 --- a/spec/requests/api/avatar_spec.rb +++ b/spec/requests/api/avatar_spec.rb @@ -13,7 +13,7 @@ describe API::Avatar do end it 'returns the avatar url' do - get api('/avatar'), { email: 'public@example.com' } + get api('/avatar'), params: { email: 'public@example.com' } expect(response.status).to eq 200 expect(json_response['avatar_url']).to eql("#{::Settings.gitlab.base_url}#{user.avatar.local_url}") @@ -30,7 +30,7 @@ describe API::Avatar do end it 'returns the avatar url from Gravatar' do - get api('/avatar'), { email: 'private@example.com' } + get api('/avatar'), params: { email: 'private@example.com' } expect(response.status).to eq 200 expect(json_response['avatar_url']).to eq('https://gravatar') @@ -53,7 +53,7 @@ describe API::Avatar do end it 'returns the avatar url from Gravatar' do - get api('/avatar'), { email: 'public@example.com' } + get api('/avatar'), params: { email: 'public@example.com' } expect(response.status).to eq 200 expect(json_response['avatar_url']).to eq('https://gravatar') @@ -70,7 +70,7 @@ describe API::Avatar do end it 'returns the avatar url from Gravatar' do - get api('/avatar'), { email: 'private@example.com' } + get api('/avatar'), params: { email: 'private@example.com' } expect(response.status).to eq 200 expect(json_response['avatar_url']).to eq('https://gravatar') @@ -88,7 +88,7 @@ describe API::Avatar do context 'when authenticated' do it 'returns the avatar url' do - get api('/avatar', user), { email: 'public@example.com' } + get api('/avatar', user), params: { email: 'public@example.com' } expect(response.status).to eq 200 expect(json_response['avatar_url']).to eql("#{::Settings.gitlab.base_url}#{user.avatar.local_url}") @@ -97,7 +97,7 @@ describe API::Avatar do context 'when unauthenticated' do it_behaves_like '403 response' do - let(:request) { get api('/avatar'), { email: 'public@example.com' } } + let(:request) { get api('/avatar'), params: { email: 'public@example.com' } } end end end diff --git a/spec/requests/api/award_emoji_spec.rb b/spec/requests/api/award_emoji_spec.rb index 7f3f3ab0977..22f6fcdc922 100644 --- a/spec/requests/api/award_emoji_spec.rb +++ b/spec/requests/api/award_emoji_spec.rb @@ -148,7 +148,7 @@ describe API::AwardEmoji do context "on an issue" do it "creates a new award emoji" do - post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: 'blowfish' + post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: { name: 'blowfish' } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') @@ -162,21 +162,21 @@ describe API::AwardEmoji do end it "returns a 401 unauthorized error if the user is not authenticated" do - post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji"), name: 'thumbsup' + post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji"), params: { name: 'thumbsup' } expect(response).to have_gitlab_http_status(401) end it "normalizes +1 as thumbsup award" do - post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: '+1' + post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: { name: '+1' } expect(issue.award_emoji.last.name).to eq("thumbsup") end context 'when the emoji already has been awarded' do it 'returns a 404 status code' do - post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: 'thumbsup' - post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: 'thumbsup' + post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: { name: 'thumbsup' } + post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: { name: 'thumbsup' } expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") @@ -188,7 +188,7 @@ describe API::AwardEmoji do it 'creates a new award emoji' do snippet = create(:project_snippet, :public, project: project) - post api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user), name: 'blowfish' + post api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user), params: { name: 'blowfish' } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') @@ -202,7 +202,7 @@ describe API::AwardEmoji do it 'creates a new award emoji' do expect do - post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: 'rocket' + post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: { name: 'rocket' } end.to change { note.award_emoji.count }.from(0).to(1) expect(response).to have_gitlab_http_status(201) @@ -210,15 +210,15 @@ describe API::AwardEmoji do end it "normalizes +1 as thumbsup award" do - post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: '+1' + post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: { name: '+1' } expect(note.award_emoji.last.name).to eq("thumbsup") end context 'when the emoji already has been awarded' do it 'returns a 404 status code' do - post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: 'rocket' - post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: 'rocket' + post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: { name: 'rocket' } + post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: { name: 'rocket' } expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") diff --git a/spec/requests/api/badges_spec.rb b/spec/requests/api/badges_spec.rb index e232e2e04ee..1271324a2ba 100644 --- a/spec/requests/api/badges_spec.rb +++ b/spec/requests/api/badges_spec.rb @@ -103,7 +103,7 @@ describe API::Badges do it_behaves_like 'a 404 response when source is private' do let(:route) do post api("/#{source_type.pluralize}/#{source.id}/badges", stranger), - link_url: example_url, image_url: example_url2 + params: { link_url: example_url, image_url: example_url2 } end end @@ -114,7 +114,7 @@ describe API::Badges do user = public_send(type) post api("/#{source_type.pluralize}/#{source.id}/badges", user), - link_url: example_url, image_url: example_url2 + params: { link_url: example_url, image_url: example_url2 } expect(response).to have_gitlab_http_status(403) end @@ -126,7 +126,7 @@ describe API::Badges do it 'creates a new badge' do expect do post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer), - link_url: example_url, image_url: example_url2 + params: { link_url: example_url, image_url: example_url2 } expect(response).to have_gitlab_http_status(201) end.to change { source.badges.count }.by(1) @@ -139,21 +139,21 @@ describe API::Badges do it 'returns 400 when link_url is not given' do post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer), - link_url: example_url + params: { link_url: example_url } expect(response).to have_gitlab_http_status(400) end it 'returns 400 when image_url is not given' do post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer), - image_url: example_url2 + params: { image_url: example_url2 } expect(response).to have_gitlab_http_status(400) end it 'returns 400 when link_url or image_url is not valid' do post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer), - link_url: 'whatever', image_url: 'whatever' + params: { link_url: 'whatever', image_url: 'whatever' } expect(response).to have_gitlab_http_status(400) end @@ -173,7 +173,7 @@ describe API::Badges do it_behaves_like 'a 404 response when source is private' do let(:route) do put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", stranger), - link_url: example_url + params: { link_url: example_url } end end @@ -184,7 +184,7 @@ describe API::Badges do user = public_send(type) put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", user), - link_url: example_url + params: { link_url: example_url } expect(response).to have_gitlab_http_status(403) end @@ -195,7 +195,7 @@ describe API::Badges do context 'when authenticated as a maintainer/owner' do it 'updates the member' do put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", maintainer), - link_url: example_url, image_url: example_url2 + params: { link_url: example_url, image_url: example_url2 } expect(response).to have_gitlab_http_status(200) expect(json_response['link_url']).to eq(example_url) @@ -206,7 +206,7 @@ describe API::Badges do it 'returns 400 when link_url or image_url is not valid' do put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", maintainer), - link_url: 'whatever', image_url: 'whatever' + params: { link_url: 'whatever', image_url: 'whatever' } expect(response).to have_gitlab_http_status(400) end diff --git a/spec/requests/api/boards_spec.rb b/spec/requests/api/boards_spec.rb index 7710f19ce4e..ab4f42cad47 100644 --- a/spec/requests/api/boards_spec.rb +++ b/spec/requests/api/boards_spec.rb @@ -41,7 +41,7 @@ describe API::Boards do group_label = create(:group_label, group: group) board_parent.update(group: group) - post api(url, user), label_id: group_label.id + post api(url, user), params: { label_id: group_label.id } expect(response).to have_gitlab_http_status(201) expect(json_response['label']['name']).to eq(group_label.title) @@ -56,7 +56,7 @@ describe API::Boards do group.add_developer(user) sub_group.add_developer(user) - post api(url, user), label_id: group_label.id + post api(url, user), params: { label_id: group_label.id } expect(response).to have_gitlab_http_status(201) expect(json_response['label']['name']).to eq(group_label.title) @@ -73,7 +73,7 @@ describe API::Boards do group.add_developer(user) group_label = create(:group_label, group: group) - post api(url, user), label_id: group_label.id + post api(url, user), params: { label_id: group_label.id } expect(response).to have_gitlab_http_status(201) expect(json_response['label']['name']).to eq(group_label.title) diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb index 7fff0a6cce6..93c411476bb 100644 --- a/spec/requests/api/branches_spec.rb +++ b/spec/requests/api/branches_spec.rb @@ -21,7 +21,7 @@ describe API::Branches do shared_examples_for 'repository branches' do it 'returns the repository branches' do - get api(route, current_user), per_page: 100 + get api(route, current_user), params: { per_page: 100 } expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/branches') @@ -42,7 +42,7 @@ describe API::Branches do context 'when search parameter is passed' do context 'and branch exists' do it 'returns correct branches' do - get api(route, user), per_page: 100, search: branch_name + get api(route, user), params: { per_page: 100, search: branch_name } searched_branch_names = json_response.map { |branch| branch['name'] } project_branch_names = project.repository.branch_names.grep(/#{branch_name}/) @@ -53,7 +53,7 @@ describe API::Branches do context 'and branch does not exist' do it 'returns an empty array' do - get api(route, user), per_page: 100, search: 'no_such_branch_name_entropy_of_jabadabadu' + get api(route, user), params: { per_page: 100, search: 'no_such_branch_name_entropy_of_jabadabadu' } expect(json_response).to eq [] end @@ -252,7 +252,7 @@ describe API::Branches do end it 'protects a single branch and developers can push' do - put api(route, current_user), developers_can_push: true + put api(route, current_user), params: { developers_can_push: true } expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/branch') @@ -263,7 +263,7 @@ describe API::Branches do end it 'protects a single branch and developers can merge' do - put api(route, current_user), developers_can_merge: true + put api(route, current_user), params: { developers_can_merge: true } expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/branch') @@ -274,7 +274,7 @@ describe API::Branches do end it 'protects a single branch and developers can push and merge' do - put api(route, current_user), developers_can_push: true, developers_can_merge: true + put api(route, current_user), params: { developers_can_push: true, developers_can_merge: true } expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/branch') @@ -373,7 +373,7 @@ describe API::Branches do it 'updates that a developer cannot push or merge' do put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user), - developers_can_push: false, developers_can_merge: false + params: { developers_can_push: false, developers_can_merge: false } expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/branch') @@ -391,7 +391,7 @@ describe API::Branches do it 'updates that a developer can push and merge' do put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user), - developers_can_push: true, developers_can_merge: true + params: { developers_can_push: true, developers_can_merge: true } expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/branch') @@ -504,7 +504,7 @@ describe API::Branches do shared_examples_for 'repository new branch' do it 'creates a new branch' do - post api(route, current_user), branch: 'feature1', ref: branch_sha + post api(route, current_user), params: { branch: 'feature1', ref: branch_sha } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/branch') @@ -549,25 +549,25 @@ describe API::Branches do end it 'returns 400 if branch name is invalid' do - post api(route, user), branch: 'new design', ref: branch_sha + post api(route, user), params: { branch: 'new design', ref: branch_sha } expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Branch name is invalid') end it 'returns 400 if branch already exists' do - post api(route, user), branch: 'new_design1', ref: branch_sha + post api(route, user), params: { branch: 'new_design1', ref: branch_sha } expect(response).to have_gitlab_http_status(201) - post api(route, user), branch: 'new_design1', ref: branch_sha + post api(route, user), params: { branch: 'new_design1', ref: branch_sha } expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Branch already exists') end it 'returns 400 if ref name is invalid' do - post api(route, user), branch: 'new_design3', ref: 'foo' + post api(route, user), params: { branch: 'new_design3', ref: 'foo' } expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Invalid reference name') diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb index fe8a14fae9e..0b48b79219c 100644 --- a/spec/requests/api/broadcast_messages_spec.rb +++ b/spec/requests/api/broadcast_messages_spec.rb @@ -56,13 +56,13 @@ describe API::BroadcastMessages do describe 'POST /broadcast_messages' do it 'returns a 401 for anonymous users' do - post api('/broadcast_messages'), attributes_for(:broadcast_message) + post api('/broadcast_messages'), params: attributes_for(:broadcast_message) expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do - post api('/broadcast_messages', user), attributes_for(:broadcast_message) + post api('/broadcast_messages', user), params: attributes_for(:broadcast_message) expect(response).to have_gitlab_http_status(403) end @@ -72,7 +72,7 @@ describe API::BroadcastMessages do attrs = attributes_for(:broadcast_message) attrs.delete(:message) - post api('/broadcast_messages', admin), attrs + post api('/broadcast_messages', admin), params: attrs expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq 'message is missing' @@ -81,7 +81,7 @@ describe API::BroadcastMessages do it 'defines sane default start and end times' do time = Time.zone.parse('2016-07-02 10:11:12') travel_to(time) do - post api('/broadcast_messages', admin), message: 'Test message' + post api('/broadcast_messages', admin), params: { message: 'Test message' } expect(response).to have_gitlab_http_status(201) expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z' @@ -92,7 +92,7 @@ describe API::BroadcastMessages do it 'accepts a custom background and foreground color' do attrs = attributes_for(:broadcast_message, color: '#000000', font: '#cecece') - post api('/broadcast_messages', admin), attrs + post api('/broadcast_messages', admin), params: attrs expect(response).to have_gitlab_http_status(201) expect(json_response['color']).to eq attrs[:color] @@ -104,14 +104,14 @@ describe API::BroadcastMessages do describe 'PUT /broadcast_messages/:id' do it 'returns a 401 for anonymous users' do put api("/broadcast_messages/#{message.id}"), - attributes_for(:broadcast_message) + params: attributes_for(:broadcast_message) expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do put api("/broadcast_messages/#{message.id}", user), - attributes_for(:broadcast_message) + params: attributes_for(:broadcast_message) expect(response).to have_gitlab_http_status(403) end @@ -120,7 +120,7 @@ describe API::BroadcastMessages do it 'accepts new background and foreground colors' do attrs = { color: '#000000', font: '#cecece' } - put api("/broadcast_messages/#{message.id}", admin), attrs + put api("/broadcast_messages/#{message.id}", admin), params: attrs expect(response).to have_gitlab_http_status(200) expect(json_response['color']).to eq attrs[:color] @@ -132,7 +132,7 @@ describe API::BroadcastMessages do travel_to(time) do attrs = { starts_at: Time.zone.now, ends_at: 3.hours.from_now } - put api("/broadcast_messages/#{message.id}", admin), attrs + put api("/broadcast_messages/#{message.id}", admin), params: attrs expect(response).to have_gitlab_http_status(200) expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z' @@ -143,7 +143,7 @@ describe API::BroadcastMessages do it 'accepts a new message' do attrs = { message: 'new message' } - put api("/broadcast_messages/#{message.id}", admin), attrs + put api("/broadcast_messages/#{message.id}", admin), params: attrs expect(response).to have_gitlab_http_status(200) expect { message.reload }.to change { message.message }.to('new message') @@ -154,14 +154,14 @@ describe API::BroadcastMessages do describe 'DELETE /broadcast_messages/:id' do it 'returns a 401 for anonymous users' do delete api("/broadcast_messages/#{message.id}"), - attributes_for(:broadcast_message) + params: attributes_for(:broadcast_message) expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do delete api("/broadcast_messages/#{message.id}", user), - attributes_for(:broadcast_message) + params: attributes_for(:broadcast_message) expect(response).to have_gitlab_http_status(403) end diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index a43304c9b83..9388343c392 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -51,7 +51,7 @@ describe API::CommitStatuses do context 'all commit statuses' do before do - get api(get_url, reporter), all: 1 + get api(get_url, reporter), params: { all: 1 } end it 'returns all commit statuses' do @@ -66,7 +66,7 @@ describe API::CommitStatuses do context 'latest commit statuses for specific ref' do before do - get api(get_url, reporter), ref: 'develop' + get api(get_url, reporter), params: { ref: 'develop' } end it 'returns latest commit statuses for specific ref' do @@ -79,7 +79,7 @@ describe API::CommitStatuses do context 'latest commit statues for specific name' do before do - get api(get_url, reporter), name: 'coverage' + get api(get_url, reporter), params: { name: 'coverage' } end it 'return latest commit statuses for specific name' do @@ -133,7 +133,7 @@ describe API::CommitStatuses do context "for #{status}" do context 'uses only required parameters' do it 'creates commit status' do - post api(post_url, developer), state: status + post api(post_url, developer), params: { state: status } expect(response).to have_gitlab_http_status(201) expect(json_response['sha']).to eq(commit.id) @@ -153,12 +153,12 @@ describe API::CommitStatuses do context 'transitions status from pending' do before do - post api(post_url, developer), state: 'pending' + post api(post_url, developer), params: { state: 'pending' } end %w[running success failed canceled].each do |status| it "to #{status}" do - expect { post api(post_url, developer), state: status }.not_to change { CommitStatus.count } + expect { post api(post_url, developer), params: { state: status } }.not_to change { CommitStatus.count } expect(response).to have_gitlab_http_status(201) expect(json_response['status']).to eq(status) @@ -169,7 +169,7 @@ describe API::CommitStatuses do context 'with all optional parameters' do context 'when creating a commit status' do subject do - post api(post_url, developer), { + post api(post_url, developer), params: { state: 'success', context: 'coverage', ref: 'master', @@ -206,7 +206,7 @@ describe API::CommitStatuses do context 'when updatig a commit status' do before do - post api(post_url, developer), { + post api(post_url, developer), params: { state: 'running', context: 'coverage', ref: 'master', @@ -215,7 +215,7 @@ describe API::CommitStatuses do target_url: 'http://gitlab.com/status' } - post api(post_url, developer), { + post api(post_url, developer), params: { state: 'success', name: 'coverage', ref: 'master', @@ -244,10 +244,10 @@ describe API::CommitStatuses do context 'when retrying a commit status' do before do post api(post_url, developer), - { state: 'failed', name: 'test', ref: 'master' } + params: { state: 'failed', name: 'test', ref: 'master' } post api(post_url, developer), - { state: 'success', name: 'test', ref: 'master' } + params: { state: 'success', name: 'test', ref: 'master' } end it 'correctly posts a new commit status' do @@ -265,7 +265,7 @@ describe API::CommitStatuses do context 'when status is invalid' do before do - post api(post_url, developer), state: 'invalid' + post api(post_url, developer), params: { state: 'invalid' } end it 'does not create commit status' do @@ -287,7 +287,7 @@ describe API::CommitStatuses do let(:sha) { 'invalid_sha' } before do - post api(post_url, developer), state: 'running' + post api(post_url, developer), params: { state: 'running' } end it 'returns not found error' do @@ -297,8 +297,10 @@ describe API::CommitStatuses do context 'when target URL is an invalid address' do before do - post api(post_url, developer), state: 'pending', - target_url: 'invalid url' + post api(post_url, developer), params: { + state: 'pending', + target_url: 'invalid url' + } end it 'responds with bad request status and validation errors' do @@ -311,7 +313,7 @@ describe API::CommitStatuses do context 'reporter user' do before do - post api(post_url, reporter), state: 'running' + post api(post_url, reporter), params: { state: 'running' } end it 'does not create commit status' do @@ -321,7 +323,7 @@ describe API::CommitStatuses do context 'guest user' do before do - post api(post_url, guest), state: 'running' + post api(post_url, guest), params: { state: 'running' } end it 'does not create commit status' do diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 9e599c2175f..6b9bc6eda6a 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -281,11 +281,11 @@ describe API::Commits do it 'does not increment the usage counters using access token authentication' do expect(::Gitlab::WebIdeCommitsCounter).not_to receive(:increment) - post api(url, user), valid_c_params + post api(url, user), params: valid_c_params end it 'a new file in project repo' do - post api(url, user), valid_c_params + post api(url, user), params: valid_c_params expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) @@ -294,7 +294,7 @@ describe API::Commits do end it 'a new file with utf8 chars in project repo' do - post api(url, user), valid_utf8_c_params + post api(url, user), params: valid_utf8_c_params expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) @@ -303,7 +303,7 @@ describe API::Commits do end it 'returns a 400 bad request if file exists' do - post api(url, user), invalid_c_params + post api(url, user), params: invalid_c_params expect(response).to have_gitlab_http_status(400) end @@ -312,7 +312,7 @@ describe API::Commits do let(:url) { "/projects/#{CGI.escape(project.full_path)}/repository/commits" } it 'a new file in project repo' do - post api(url, user), valid_c_params + post api(url, user), params: valid_c_params expect(response).to have_gitlab_http_status(201) end @@ -347,14 +347,14 @@ describe API::Commits do end it 'an existing file in project repo' do - post api(url, user), valid_d_params + post api(url, user), params: valid_d_params expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do - post api(url, user), invalid_d_params + post api(url, user), params: invalid_d_params expect(response).to have_gitlab_http_status(400) end @@ -392,14 +392,14 @@ describe API::Commits do end it 'an existing file in project repo' do - post api(url, user), valid_m_params + post api(url, user), params: valid_m_params expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do - post api(url, user), invalid_m_params + post api(url, user), params: invalid_m_params expect(response).to have_gitlab_http_status(400) end @@ -435,14 +435,14 @@ describe API::Commits do end it 'an existing file in project repo' do - post api(url, user), valid_u_params + post api(url, user), params: valid_u_params expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do - post api(url, user), invalid_u_params + post api(url, user), params: invalid_u_params expect(response).to have_gitlab_http_status(400) end @@ -467,7 +467,7 @@ describe API::Commits do end it 'responds with success' do - post api(url, user), params + post api(url, user), params: params expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) @@ -477,7 +477,7 @@ describe API::Commits do let(:execute_filemode) { false } it 'responds with success' do - post api(url, user), params + post api(url, user), params: params expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) @@ -488,7 +488,7 @@ describe API::Commits do let(:file_path) { 'foo/bar.baz' } it "responds with 400" do - post api(url, user), params + post api(url, user), params: params expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq("A file with this name doesn't exist") @@ -566,28 +566,28 @@ describe API::Commits do end it 'are committed as one in project repo' do - post api(url, user), valid_mo_params + post api(url, user), params: valid_mo_params expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'includes the commit stats' do - post api(url, user), valid_mo_params + post api(url, user), params: valid_mo_params expect(response).to have_gitlab_http_status(201) expect(json_response).to include 'stats' end it "doesn't include the commit stats when stats is false" do - post api(url, user), valid_mo_params.merge(stats: false) + post api(url, user), params: valid_mo_params.merge(stats: false) expect(response).to have_gitlab_http_status(201) expect(json_response).not_to include 'stats' end it 'return a 400 bad request if there are any issues' do - post api(url, user), invalid_mo_params + post api(url, user), params: invalid_mo_params expect(response).to have_gitlab_http_status(400) end @@ -613,13 +613,13 @@ describe API::Commits do end it 'allows pushing to the source branch of the merge request' do - post api(url, user), push_params('feature') + post api(url, user), params: push_params('feature') expect(response).to have_gitlab_http_status(:created) end it 'denies pushing to another branch' do - post api(url, user), push_params('other-branch') + post api(url, user), params: push_params('other-branch') expect(response).to have_gitlab_http_status(:forbidden) end @@ -651,7 +651,7 @@ describe API::Commits do context 'for a valid commit' do it 'returns all refs with no scope' do - get api(route, current_user), per_page: 100 + get api(route, current_user), params: { per_page: 100 } refs = project.repository.branch_names_contains(commit_id).map {|name| ['branch', name]} refs.concat(project.repository.tag_names_contains(commit_id).map {|name| ['tag', name]}) @@ -663,7 +663,7 @@ describe API::Commits do end it 'returns all refs' do - get api(route, current_user), type: 'all', per_page: 100 + get api(route, current_user), params: { type: 'all', per_page: 100 } refs = project.repository.branch_names_contains(commit_id).map {|name| ['branch', name]} refs.concat(project.repository.tag_names_contains(commit_id).map {|name| ['tag', name]}) @@ -673,7 +673,7 @@ describe API::Commits do end it 'returns the branch refs' do - get api(route, current_user), type: 'branch', per_page: 100 + get api(route, current_user), params: { type: 'branch', per_page: 100 } refs = project.repository.branch_names_contains(commit_id).map {|name| ['branch', name]} @@ -682,7 +682,7 @@ describe API::Commits do end it 'returns the tag refs' do - get api(route, current_user), type: 'tag', per_page: 100 + get api(route, current_user), params: { type: 'tag', per_page: 100 } refs = project.repository.tag_names_contains(commit_id).map {|name| ['tag', name]} @@ -750,14 +750,14 @@ describe API::Commits do end it "is false it does not include stats" do - get api(route, user), stats: false + get api(route, user), params: { stats: false } expect(response).to have_gitlab_http_status(200) expect(json_response).not_to include 'stats' end it "is true it includes stats" do - get api(route, user), stats: true + get api(route, user), params: { stats: true } expect(response).to have_gitlab_http_status(200) expect(json_response).to include 'stats' @@ -1063,7 +1063,7 @@ describe API::Commits do shared_examples_for 'ref cherry-pick' do context 'when ref exists' do it 'cherry-picks the ref commit' do - post api(route, current_user), branch: branch + post api(route, current_user), params: { branch: branch } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/commit/basic') @@ -1078,7 +1078,7 @@ describe API::Commits do include_context 'disabled repository' it_behaves_like '403 response' do - let(:request) { post api(route, current_user), branch: 'master' } + let(:request) { post api(route, current_user), params: { branch: 'master' } } end end end @@ -1087,13 +1087,13 @@ describe API::Commits do let(:project) { create(:project, :public, :repository) } it_behaves_like '403 response' do - let(:request) { post api(route), branch: 'master' } + let(:request) { post api(route), params: { branch: 'master' } } end end context 'when unauthenticated', 'and project is private' do it_behaves_like '404 response' do - let(:request) { post api(route), branch: 'master' } + let(:request) { post api(route), params: { branch: 'master' } } let(:message) { '404 Project Not Found' } end end @@ -1107,7 +1107,7 @@ describe API::Commits do let(:commit_id) { 'unknown' } it_behaves_like '404 response' do - let(:request) { post api(route, current_user), branch: 'master' } + let(:request) { post api(route, current_user), params: { branch: 'master' } } let(:message) { '404 Commit Not Found' } end end @@ -1121,21 +1121,21 @@ describe API::Commits do context 'when branch is empty' do ['', ' '].each do |branch| it_behaves_like '400 response' do - let(:request) { post api(route, current_user), branch: branch } + let(:request) { post api(route, current_user), params: { branch: branch } } end end end context 'when branch does not exist' do it_behaves_like '404 response' do - let(:request) { post api(route, current_user), branch: 'foo' } + let(:request) { post api(route, current_user), params: { branch: 'foo' } } let(:message) { '404 Branch Not Found' } end end context 'when commit is already included in the target branch' do it_behaves_like '400 response' do - let(:request) { post api(route, current_user), branch: 'markdown' } + let(:request) { post api(route, current_user), params: { branch: 'markdown' } } end end @@ -1150,7 +1150,7 @@ describe API::Commits do let(:commit_id) { branch_with_slash.name } it_behaves_like '404 response' do - let(:request) { post api(route, current_user), branch: 'master' } + let(:request) { post api(route, current_user), params: { branch: 'master' } } end end @@ -1181,7 +1181,7 @@ describe API::Commits do end it 'returns 400 if you are not allowed to push to the target branch' do - post api(route, current_user), branch: 'feature' + post api(route, current_user), params: { branch: 'feature' } expect(response).to have_gitlab_http_status(:forbidden) expect(json_response['message']).to match(/You are not allowed to push into this branch/) @@ -1195,13 +1195,13 @@ describe API::Commits do let(:project_id) { forked_project.id } it 'allows access from a maintainer that to the source branch' do - post api(route, user), branch: 'feature' + post api(route, user), params: { branch: 'feature' } expect(response).to have_gitlab_http_status(:created) end it 'denies cherry picking to another branch' do - post api(route, user), branch: 'master' + post api(route, user), params: { branch: 'master' } expect(response).to have_gitlab_http_status(:forbidden) end @@ -1217,7 +1217,7 @@ describe API::Commits do shared_examples_for 'ref revert' do context 'when ref exists' do it 'reverts the ref commit' do - post api(route, current_user), branch: branch + post api(route, current_user), params: { branch: branch } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/commit/basic') @@ -1233,7 +1233,7 @@ describe API::Commits do include_context 'disabled repository' it_behaves_like '403 response' do - let(:request) { post api(route, current_user), branch: branch } + let(:request) { post api(route, current_user), params: { branch: branch } } end end end @@ -1242,13 +1242,13 @@ describe API::Commits do let(:project) { create(:project, :public, :repository) } it_behaves_like '403 response' do - let(:request) { post api(route), branch: branch } + let(:request) { post api(route), params: { branch: branch } } end end context 'when unauthenticated', 'and project is private' do it_behaves_like '404 response' do - let(:request) { post api(route), branch: branch } + let(:request) { post api(route), params: { branch: branch } } let(:message) { '404 Project Not Found' } end end @@ -1262,7 +1262,7 @@ describe API::Commits do let(:commit_id) { 'unknown' } it_behaves_like '404 response' do - let(:request) { post api(route, current_user), branch: branch } + let(:request) { post api(route, current_user), params: { branch: branch } } let(:message) { '404 Commit Not Found' } end end @@ -1276,14 +1276,14 @@ describe API::Commits do context 'when branch is empty' do ['', ' '].each do |branch| it_behaves_like '400 response' do - let(:request) { post api(route, current_user), branch: branch } + let(:request) { post api(route, current_user), params: { branch: branch } } end end end context 'when branch does not exist' do it_behaves_like '404 response' do - let(:request) { post api(route, current_user), branch: 'foo' } + let(:request) { post api(route, current_user), params: { branch: 'foo' } } let(:message) { '404 Branch Not Found' } end end @@ -1311,7 +1311,7 @@ describe API::Commits do end it 'returns 400 if you are not allowed to push to the target branch' do - post api(route, current_user), branch: 'feature' + post api(route, current_user), params: { branch: 'feature' } expect(response).to have_gitlab_http_status(:forbidden) expect(json_response['message']).to match(/You are not allowed to push into this branch/) @@ -1329,7 +1329,7 @@ describe API::Commits do shared_examples_for 'ref new comment' do context 'when ref exists' do it 'creates the comment' do - post api(route, current_user), note: note + post api(route, current_user), params: { note: note } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/commit_note') @@ -1344,7 +1344,7 @@ describe API::Commits do include_context 'disabled repository' it_behaves_like '403 response' do - let(:request) { post api(route, current_user), note: 'My comment' } + let(:request) { post api(route, current_user), params: { note: 'My comment' } } end end end @@ -1353,13 +1353,13 @@ describe API::Commits do let(:project) { create(:project, :public, :repository) } it_behaves_like '400 response' do - let(:request) { post api(route), note: 'My comment' } + let(:request) { post api(route), params: { note: 'My comment' } } end end context 'when unauthenticated', 'and project is private' do it_behaves_like '404 response' do - let(:request) { post api(route), note: 'My comment' } + let(:request) { post api(route), params: { note: 'My comment' } } let(:message) { '404 Project Not Found' } end end @@ -1370,7 +1370,7 @@ describe API::Commits do it_behaves_like 'ref new comment' it 'returns the inline comment' do - post api(route, current_user), note: 'My comment', path: project.repository.commit.raw_diffs.first.new_path, line: 1, line_type: 'new' + post api(route, current_user), params: { note: 'My comment', path: project.repository.commit.raw_diffs.first.new_path, line: 1, line_type: 'new' } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/commit_note') @@ -1384,7 +1384,7 @@ describe API::Commits do let(:commit_id) { 'unknown' } it_behaves_like '404 response' do - let(:request) { post api(route, current_user), note: 'My comment' } + let(:request) { post api(route, current_user), params: { note: 'My comment' } } let(:message) { '404 Commit Not Found' } end end @@ -1405,7 +1405,7 @@ describe API::Commits do let(:commit_id) { branch_with_slash.name } it_behaves_like '404 response' do - let(:request) { post api(route, current_user), note: 'My comment' } + let(:request) { post api(route, current_user), params: { note: 'My comment' } } end end diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb index 32fc704a79b..b93ee148736 100644 --- a/spec/requests/api/deploy_keys_spec.rb +++ b/spec/requests/api/deploy_keys_spec.rb @@ -72,14 +72,14 @@ describe API::DeployKeys do describe 'POST /projects/:id/deploy_keys' do it 'does not create an invalid ssh key' do - post api("/projects/#{project.id}/deploy_keys", admin), { title: 'invalid key' } + post api("/projects/#{project.id}/deploy_keys", admin), params: { title: 'invalid key' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'does not create a key without title' do - post api("/projects/#{project.id}/deploy_keys", admin), key: 'some key' + post api("/projects/#{project.id}/deploy_keys", admin), params: { key: 'some key' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') @@ -89,7 +89,7 @@ describe API::DeployKeys do key_attrs = attributes_for :another_key expect do - post api("/projects/#{project.id}/deploy_keys", admin), key_attrs + post api("/projects/#{project.id}/deploy_keys", admin), params: key_attrs end.to change { project.deploy_keys.count }.by(1) new_key = project.deploy_keys.last @@ -99,7 +99,7 @@ describe API::DeployKeys do it 'returns an existing ssh key when attempting to add a duplicate' do expect do - post api("/projects/#{project.id}/deploy_keys", admin), { key: deploy_key.key, title: deploy_key.title } + post api("/projects/#{project.id}/deploy_keys", admin), params: { key: deploy_key.key, title: deploy_key.title } end.not_to change { project.deploy_keys.count } expect(response).to have_gitlab_http_status(201) @@ -107,7 +107,7 @@ describe API::DeployKeys do it 'joins an existing ssh key to a new project' do expect do - post api("/projects/#{project2.id}/deploy_keys", admin), { key: deploy_key.key, title: deploy_key.title } + post api("/projects/#{project2.id}/deploy_keys", admin), params: { key: deploy_key.key, title: deploy_key.title } end.to change { project2.deploy_keys.count }.by(1) expect(response).to have_gitlab_http_status(201) @@ -116,7 +116,7 @@ describe API::DeployKeys do it 'accepts can_push parameter' do key_attrs = attributes_for(:another_key).merge(can_push: true) - post api("/projects/#{project.id}/deploy_keys", admin), key_attrs + post api("/projects/#{project.id}/deploy_keys", admin), params: key_attrs expect(response).to have_gitlab_http_status(201) expect(json_response['can_push']).to eq(true) @@ -131,7 +131,7 @@ describe API::DeployKeys do it 'updates a public deploy key as admin' do expect do - put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin), { title: 'new title' } + put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin), params: { title: 'new title' } end.not_to change(deploy_key, :title) expect(response).to have_gitlab_http_status(200) @@ -139,7 +139,7 @@ describe API::DeployKeys do it 'does not update a public deploy key as non admin' do expect do - put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", user), { title: 'new title' } + put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", user), params: { title: 'new title' } end.not_to change(deploy_key, :title) expect(response).to have_gitlab_http_status(404) @@ -149,7 +149,7 @@ describe API::DeployKeys do project_private_deploy_key expect do - put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), { title: '' } + put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), params: { title: '' } end.not_to change(deploy_key, :title) expect(response).to have_gitlab_http_status(400) @@ -158,7 +158,7 @@ describe API::DeployKeys do it 'updates a private ssh key with correct attributes' do project_private_deploy_key - put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), { title: 'new title', can_push: true } + put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), params: { title: 'new title', can_push: true } expect(json_response['id']).to eq(private_deploy_key.id) expect(json_response['title']).to eq('new title') diff --git a/spec/requests/api/doorkeeper_access_spec.rb b/spec/requests/api/doorkeeper_access_spec.rb index 308134eba72..d74484c8d29 100644 --- a/spec/requests/api/doorkeeper_access_spec.rb +++ b/spec/requests/api/doorkeeper_access_spec.rb @@ -7,20 +7,20 @@ describe 'doorkeeper access' do describe "unauthenticated" do it "returns authentication success" do - get api("/user"), access_token: token.token + get api("/user"), params: { access_token: token.token } expect(response).to have_gitlab_http_status(200) end include_examples 'user login request with unique ip limit' do def request - get api('/user'), access_token: token.token + get api('/user'), params: { access_token: token.token } end end end describe "when token invalid" do it "returns authentication error" do - get api("/user"), access_token: "123a" + get api("/user"), params: { access_token: "123a" } expect(response).to have_gitlab_http_status(401) end end @@ -41,7 +41,7 @@ describe 'doorkeeper access' do describe "when user is blocked" do it "returns authorization error" do user.block - get api("/user"), access_token: token.token + get api("/user"), params: { access_token: token.token } expect(response).to have_gitlab_http_status(403) end @@ -50,7 +50,7 @@ describe 'doorkeeper access' do describe "when user is ldap_blocked" do it "returns authorization error" do user.ldap_block - get api("/user"), access_token: token.token + get api("/user"), params: { access_token: token.token } expect(response).to have_gitlab_http_status(403) end diff --git a/spec/requests/api/environments_spec.rb b/spec/requests/api/environments_spec.rb index f3db0c122a0..493d3642255 100644 --- a/spec/requests/api/environments_spec.rb +++ b/spec/requests/api/environments_spec.rb @@ -47,7 +47,7 @@ describe API::Environments do describe 'POST /projects/:id/environments' do context 'as a member' do it 'creates a environment with valid params' do - post api("/projects/#{project.id}/environments", user), name: "mepmep" + post api("/projects/#{project.id}/environments", user), params: { name: "mepmep" } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('mepmep') @@ -56,19 +56,19 @@ describe API::Environments do end it 'requires name to be passed' do - post api("/projects/#{project.id}/environments", user), external_url: 'test.gitlab.com' + post api("/projects/#{project.id}/environments", user), params: { external_url: 'test.gitlab.com' } expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if environment already exists' do - post api("/projects/#{project.id}/environments", user), name: environment.name + post api("/projects/#{project.id}/environments", user), params: { name: environment.name } expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if slug is specified' do - post api("/projects/#{project.id}/environments", user), name: "foo", slug: "foo" + post api("/projects/#{project.id}/environments", user), params: { name: "foo", slug: "foo" } expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") @@ -77,13 +77,13 @@ describe API::Environments do context 'a non member' do it 'rejects the request' do - post api("/projects/#{project.id}/environments", non_member), name: 'gitlab.com' + post api("/projects/#{project.id}/environments", non_member), params: { name: 'gitlab.com' } expect(response).to have_gitlab_http_status(404) end it 'returns a 400 when the required params are missing' do - post api("/projects/12345/environments", non_member), external_url: 'http://env.git.com' + post api("/projects/12345/environments", non_member), params: { external_url: 'http://env.git.com' } end end end @@ -92,7 +92,7 @@ describe API::Environments do it 'returns a 200 if name and external_url are changed' do url = 'https://mepmep.whatever.ninja' put api("/projects/#{project.id}/environments/#{environment.id}", user), - name: 'Mepmep', external_url: url + params: { name: 'Mepmep', external_url: url } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') @@ -102,7 +102,7 @@ describe API::Environments do it "won't allow slug to be changed" do slug = environment.slug api_url = api("/projects/#{project.id}/environments/#{environment.id}", user) - put api_url, slug: slug + "-foo" + put api_url, params: { slug: slug + "-foo" } expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") @@ -111,7 +111,7 @@ describe API::Environments do it "won't update the external_url if only the name is passed" do url = environment.external_url put api("/projects/#{project.id}/environments/#{environment.id}", user), - name: 'Mepmep' + params: { name: 'Mepmep' } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') diff --git a/spec/requests/api/events_spec.rb b/spec/requests/api/events_spec.rb index c4e3ac14441..8c58ba45ce9 100644 --- a/spec/requests/api/events_spec.rb +++ b/spec/requests/api/events_spec.rb @@ -279,13 +279,13 @@ describe API::Events do it 'avoids N+1 queries' do control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do - get api("/projects/#{private_project.id}/events", user), target_type: :merge_request + get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request } end.count create_event(merge_request2) expect do - get api("/projects/#{private_project.id}/events", user), target_type: :merge_request + get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request } end.not_to exceed_all_query_limit(control_count) expect(response).to have_gitlab_http_status(200) diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb index c5354c2d639..7d3eff7d32d 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -79,7 +79,7 @@ describe API::Features do context 'when passed value=true' do it 'creates an enabled feature' do - post api("/features/#{feature_name}", admin), value: 'true' + post api("/features/#{feature_name}", admin), params: { value: 'true' } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -89,7 +89,7 @@ describe API::Features do end it 'creates an enabled feature for the given Flipper group when passed feature_group=perf_team' do - post api("/features/#{feature_name}", admin), value: 'true', feature_group: 'perf_team' + post api("/features/#{feature_name}", admin), params: { value: 'true', feature_group: 'perf_team' } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -102,7 +102,7 @@ describe API::Features do end it 'creates an enabled feature for the given user when passed user=username' do - post api("/features/#{feature_name}", admin), value: 'true', user: user.username + post api("/features/#{feature_name}", admin), params: { value: 'true', user: user.username } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -115,7 +115,7 @@ describe API::Features do end it 'creates an enabled feature for the given user and feature group when passed user=username and feature_group=perf_team' do - post api("/features/#{feature_name}", admin), value: 'true', user: user.username, feature_group: 'perf_team' + post api("/features/#{feature_name}", admin), params: { value: 'true', user: user.username, feature_group: 'perf_team' } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -130,7 +130,7 @@ describe API::Features do end it 'creates a feature with the given percentage if passed an integer' do - post api("/features/#{feature_name}", admin), value: '50' + post api("/features/#{feature_name}", admin), params: { value: '50' } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -152,7 +152,7 @@ describe API::Features do context 'when passed value=true' do it 'enables the feature' do - post api("/features/#{feature_name}", admin), value: 'true' + post api("/features/#{feature_name}", admin), params: { value: 'true' } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -162,7 +162,7 @@ describe API::Features do end it 'enables the feature for the given Flipper group when passed feature_group=perf_team' do - post api("/features/#{feature_name}", admin), value: 'true', feature_group: 'perf_team' + post api("/features/#{feature_name}", admin), params: { value: 'true', feature_group: 'perf_team' } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -175,7 +175,7 @@ describe API::Features do end it 'enables the feature for the given user when passed user=username' do - post api("/features/#{feature_name}", admin), value: 'true', user: user.username + post api("/features/#{feature_name}", admin), params: { value: 'true', user: user.username } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -193,7 +193,7 @@ describe API::Features do feature.enable expect(feature).to be_enabled - post api("/features/#{feature_name}", admin), value: 'false' + post api("/features/#{feature_name}", admin), params: { value: 'false' } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -206,7 +206,7 @@ describe API::Features do feature.enable(Feature.group(:perf_team)) expect(Feature.get(feature_name).enabled?(admin)).to be_truthy - post api("/features/#{feature_name}", admin), value: 'false', feature_group: 'perf_team' + post api("/features/#{feature_name}", admin), params: { value: 'false', feature_group: 'perf_team' } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -219,7 +219,7 @@ describe API::Features do feature.enable(user) expect(Feature.get(feature_name).enabled?(user)).to be_truthy - post api("/features/#{feature_name}", admin), value: 'false', user: user.username + post api("/features/#{feature_name}", admin), params: { value: 'false', user: user.username } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( @@ -235,7 +235,7 @@ describe API::Features do end it 'updates the percentage of time if passed an integer' do - post api("/features/#{feature_name}", admin), value: '30' + post api("/features/#{feature_name}", admin), params: { value: '30' } expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb index 620f9f5e1d6..e6d82448c0d 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -144,7 +144,7 @@ describe API::Files do describe "GET /projects/:id/repository/files/:file_path" do shared_examples_for 'repository files' do it 'returns file attributes as json' do - get api(route(file_path), current_user), params + get api(route(file_path), current_user), params: params expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(CGI.unescape(file_path)) @@ -157,7 +157,7 @@ describe API::Files do it 'returns json when file has txt extension' do file_path = "bar%2Fbranch-test.txt" - get api(route(file_path), current_user), params + get api(route(file_path), current_user), params: params expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq('application/json') @@ -168,7 +168,7 @@ describe API::Files do file_path = "files%2Fjs%2Fcommit%2Ejs%2Ecoffee" params[:ref] = "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9" - get api(route(file_path), current_user), params + get api(route(file_path), current_user), params: params expect(response).to have_gitlab_http_status(200) expect(json_response['file_name']).to eq('commit.js.coffee') @@ -180,7 +180,7 @@ describe API::Files do url = route(file_path) + "/raw" expect(Gitlab::Workhorse).to receive(:send_git_blob) - get api(url, current_user), params + get api(url, current_user), params: params expect(response).to have_gitlab_http_status(200) end @@ -188,7 +188,7 @@ describe API::Files do it 'forces attachment content disposition' do url = route(file_path) + "/raw" - get api(url, current_user), params + get api(url, current_user), params: params expect(headers['Content-Disposition']).to match(/^attachment/) end @@ -203,7 +203,7 @@ describe API::Files do let(:params) { { ref: 'master' } } it_behaves_like '404 response' do - let(:request) { get api(route('app%2Fmodels%2Fapplication%2Erb'), current_user), params } + let(:request) { get api(route('app%2Fmodels%2Fapplication%2Erb'), current_user), params: params } let(:message) { '404 File Not Found' } end end @@ -212,7 +212,7 @@ describe API::Files do include_context 'disabled repository' it_behaves_like '403 response' do - let(:request) { get api(route(file_path), current_user), params } + let(:request) { get api(route(file_path), current_user), params: params } end end end @@ -233,7 +233,7 @@ describe API::Files do context 'when unauthenticated', 'and project is private' do it_behaves_like '404 response' do - let(:request) { get api(route(file_path)), params } + let(:request) { get api(route(file_path)), params: params } let(:message) { '404 Project Not Found' } end end @@ -246,7 +246,7 @@ describe API::Files do context 'when authenticated', 'as a guest' do it_behaves_like '403 response' do - let(:request) { get api(route(file_path), guest), params } + let(:request) { get api(route(file_path), guest), params: params } end end end @@ -257,7 +257,7 @@ describe API::Files do url = route(file_path) + "/raw" expect(Gitlab::Workhorse).to receive(:send_git_blob) - get api(url, current_user), params + get api(url, current_user), params: params expect(response).to have_gitlab_http_status(200) end @@ -266,7 +266,7 @@ describe API::Files do url = route('.gitignore') + "/raw" expect(Gitlab::Workhorse).to receive(:send_git_blob) - get api(url, current_user), params + get api(url, current_user), params: params expect(response).to have_gitlab_http_status(200) end @@ -277,7 +277,7 @@ describe API::Files do params[:ref] = "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9" expect(Gitlab::Workhorse).to receive(:send_git_blob) - get api(route(file_path) + "/raw", current_user), params + get api(route(file_path) + "/raw", current_user), params: params expect(response).to have_gitlab_http_status(200) end @@ -292,7 +292,7 @@ describe API::Files do let(:params) { { ref: 'master' } } it_behaves_like '404 response' do - let(:request) { get api(route('app%2Fmodels%2Fapplication%2Erb'), current_user), params } + let(:request) { get api(route('app%2Fmodels%2Fapplication%2Erb'), current_user), params: params } let(:message) { '404 File Not Found' } end end @@ -301,7 +301,7 @@ describe API::Files do include_context 'disabled repository' it_behaves_like '403 response' do - let(:request) { get api(route(file_path), current_user), params } + let(:request) { get api(route(file_path), current_user), params: params } end end end @@ -315,7 +315,7 @@ describe API::Files do context 'when unauthenticated', 'and project is private' do it_behaves_like '404 response' do - let(:request) { get api(route(file_path)), params } + let(:request) { get api(route(file_path)), params: params } let(:message) { '404 Project Not Found' } end end @@ -328,7 +328,7 @@ describe API::Files do context 'when authenticated', 'as a guest' do it_behaves_like '403 response' do - let(:request) { get api(route(file_path), guest), params } + let(:request) { get api(route(file_path), guest), params: params } end end @@ -341,7 +341,7 @@ describe API::Files do params[:ref] = "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9" expect(Gitlab::Workhorse).to receive(:send_git_blob) - get api(route(file_path) + "/raw", personal_access_token: token), params + get api(route(file_path) + "/raw", personal_access_token: token), params: params expect(response).to have_gitlab_http_status(200) end @@ -359,7 +359,7 @@ describe API::Files do end it "creates a new file in project repo" do - post api(route(file_path), user), params + post api(route(file_path), user), params: params expect(response).to have_gitlab_http_status(201) expect(json_response["file_path"]).to eq(CGI.unescape(file_path)) @@ -377,7 +377,7 @@ describe API::Files do it 'returns a 400 bad request if the commit message is empty' do params[:commit_message] = '' - post api(route(file_path), user), params + post api(route(file_path), user), params: params expect(response).to have_gitlab_http_status(400) end @@ -386,7 +386,7 @@ describe API::Files do allow_any_instance_of(Repository).to receive(:create_file) .and_raise(Gitlab::Git::CommitError, 'Cannot create file') - post api(route("any%2Etxt"), user), params + post api(route("any%2Etxt"), user), params: params expect(response).to have_gitlab_http_status(400) end @@ -395,7 +395,7 @@ describe API::Files do it 'returns 403 with `read_repository` scope' do token = create(:personal_access_token, scopes: ['read_repository'], user: user) - post api(route(file_path), personal_access_token: token), params + post api(route(file_path), personal_access_token: token), params: params expect(response).to have_gitlab_http_status(403) end @@ -403,7 +403,7 @@ describe API::Files do it 'returns 201 with `api` scope' do token = create(:personal_access_token, scopes: ['api'], user: user) - post api(route(file_path), personal_access_token: token), params + post api(route(file_path), personal_access_token: token), params: params expect(response).to have_gitlab_http_status(201) end @@ -413,7 +413,7 @@ describe API::Files do it "creates a new file with the specified author" do params.merge!(author_email: author_email, author_name: author_name) - post api(route("new_file_with_author%2Etxt"), user), params + post api(route("new_file_with_author%2Etxt"), user), params: params expect(response).to have_gitlab_http_status(201) expect(response.content_type).to eq('application/json') @@ -427,7 +427,7 @@ describe API::Files do let!(:project) { create(:project_empty_repo, namespace: user.namespace ) } it "creates a new file in project repo" do - post api(route("newfile%2Erb"), user), params + post api(route("newfile%2Erb"), user), params: params expect(response).to have_gitlab_http_status(201) expect(json_response['file_path']).to eq('newfile.rb') @@ -448,7 +448,7 @@ describe API::Files do end it "updates existing file in project repo" do - put api(route(file_path), user), params + put api(route(file_path), user), params: params expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(CGI.unescape(file_path)) @@ -460,7 +460,7 @@ describe API::Files do it 'returns a 400 bad request if the commit message is empty' do params[:commit_message] = '' - put api(route(file_path), user), params + put api(route(file_path), user), params: params expect(response).to have_gitlab_http_status(400) end @@ -468,7 +468,7 @@ describe API::Files do it "returns a 400 bad request if update existing file with stale last commit id" do params_with_stale_id = params.merge(last_commit_id: 'stale') - put api(route(file_path), user), params_with_stale_id + put api(route(file_path), user), params: params_with_stale_id expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('You are attempting to update a file that has changed since you started editing it.') @@ -479,7 +479,7 @@ describe API::Files do .last_for_path(project.repository, 'master', URI.unescape(file_path)) params_with_correct_id = params.merge(last_commit_id: last_commit.id) - put api(route(file_path), user), params_with_correct_id + put api(route(file_path), user), params: params_with_correct_id expect(response).to have_gitlab_http_status(200) end @@ -494,7 +494,7 @@ describe API::Files do it "updates a file with the specified author" do params.merge!(author_email: author_email, author_name: author_name, content: "New content") - put api(route(file_path), user), params + put api(route(file_path), user), params: params expect(response).to have_gitlab_http_status(200) last_commit = project.repository.commit.raw @@ -513,7 +513,7 @@ describe API::Files do end it "deletes existing file in project repo" do - delete api(route(file_path), user), params + delete api(route(file_path), user), params: params expect(response).to have_gitlab_http_status(204) end @@ -527,7 +527,7 @@ describe API::Files do it 'returns a 400 bad request if the commit message is empty' do params[:commit_message] = '' - delete api(route(file_path), user), params + delete api(route(file_path), user), params: params expect(response).to have_gitlab_http_status(400) end @@ -535,7 +535,7 @@ describe API::Files do it "returns a 400 if fails to delete file" do allow_any_instance_of(Repository).to receive(:delete_file).and_raise(Gitlab::Git::CommitError, 'Cannot delete file') - delete api(route(file_path), user), params + delete api(route(file_path), user), params: params expect(response).to have_gitlab_http_status(400) end @@ -544,7 +544,7 @@ describe API::Files do it "removes a file with the specified author" do params.merge!(author_email: author_email, author_name: author_name) - delete api(route(file_path), user), params + delete api(route(file_path), user), params: params expect(response).to have_gitlab_http_status(204) end @@ -568,11 +568,11 @@ describe API::Files do end before do - post api(route(file_path), user), put_params + post api(route(file_path), user), params: put_params end it "remains unchanged" do - get api(route(file_path), user), get_params + get api(route(file_path), user), params: get_params expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(CGI.unescape(file_path)) diff --git a/spec/requests/api/group_boards_spec.rb b/spec/requests/api/group_boards_spec.rb index 894c94688ba..b400a7f55ef 100644 --- a/spec/requests/api/group_boards_spec.rb +++ b/spec/requests/api/group_boards_spec.rb @@ -46,7 +46,7 @@ describe API::GroupBoards do it 'does not create lists for child project labels' do project_label = create(:label, project: project) - post api(url, user), label_id: project_label.id + post api(url, user), params: { label_id: project_label.id } expect(response).to have_gitlab_http_status(400) end diff --git a/spec/requests/api/group_variables_spec.rb b/spec/requests/api/group_variables_spec.rb index f87e035c89d..e52f4c70407 100644 --- a/spec/requests/api/group_variables_spec.rb +++ b/spec/requests/api/group_variables_spec.rb @@ -87,7 +87,7 @@ describe API::GroupVariables do it 'creates variable' do expect do - post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true + post api("/groups/#{group.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true } end.to change {group.variables.count}.by(1) expect(response).to have_gitlab_http_status(201) @@ -98,7 +98,7 @@ describe API::GroupVariables do it 'creates variable with optional attributes' do expect do - post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2' + post api("/groups/#{group.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'VALUE_2' } end.to change {group.variables.count}.by(1) expect(response).to have_gitlab_http_status(201) @@ -109,7 +109,7 @@ describe API::GroupVariables do it 'does not allow to duplicate variable key' do expect do - post api("/groups/#{group.id}/variables", user), key: variable.key, value: 'VALUE_2' + post api("/groups/#{group.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' } end.to change {group.variables.count}.by(0) expect(response).to have_gitlab_http_status(400) @@ -145,7 +145,7 @@ describe API::GroupVariables do initial_variable = group.variables.reload.first value_before = initial_variable.value - put api("/groups/#{group.id}/variables/#{variable.key}", user), value: 'VALUE_1_UP', protected: true + put api("/groups/#{group.id}/variables/#{variable.key}", user), params: { value: 'VALUE_1_UP', protected: true } updated_variable = group.variables.reload.first diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 688d91113ad..c9dfc5c4a7e 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -60,7 +60,7 @@ describe API::Groups do end it "does not include statistics" do - get api("/groups", user1), statistics: true + get api("/groups", user1), params: { statistics: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -100,7 +100,7 @@ describe API::Groups do project1.statistics.update!(attributes) - get api("/groups", admin), statistics: true + get api("/groups", admin), params: { statistics: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -112,7 +112,7 @@ describe API::Groups do context "when using skip_groups in request" do it "returns all groups excluding skipped groups" do - get api("/groups", admin), skip_groups: [group2.id] + get api("/groups", admin), params: { skip_groups: [group2.id] } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -127,7 +127,7 @@ describe API::Groups do it "returns all groups you have access to" do public_group = create :group, :public - get api("/groups", user1), all_available: true + get api("/groups", user1), params: { all_available: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -159,7 +159,7 @@ describe API::Groups do end it "sorts in descending order when passed" do - get api("/groups", user1), sort: "desc" + get api("/groups", user1), params: { sort: "desc" } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -168,7 +168,7 @@ describe API::Groups do end it "sorts by path in order_by param" do - get api("/groups", user1), order_by: "path" + get api("/groups", user1), params: { order_by: "path" } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -177,7 +177,7 @@ describe API::Groups do end it "sorts by id in the order_by param" do - get api("/groups", user1), order_by: "id" + get api("/groups", user1), params: { order_by: "id" } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -186,7 +186,7 @@ describe API::Groups do end it "sorts also by descending id with pagination fix" do - get api("/groups", user1), order_by: "id", sort: "desc" + get api("/groups", user1), params: { order_by: "id", sort: "desc" } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -195,7 +195,7 @@ describe API::Groups do end it "sorts identical keys by id for good pagination" do - get api("/groups", user1), search: "same-name", order_by: "name" + get api("/groups", user1), params: { search: "same-name", order_by: "name" } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -204,7 +204,7 @@ describe API::Groups do end it "sorts descending identical keys by id for good pagination" do - get api("/groups", user1), search: "same-name", order_by: "name", sort: "desc" + get api("/groups", user1), params: { search: "same-name", order_by: "name", sort: "desc" } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -221,7 +221,7 @@ describe API::Groups do it 'returns an array of groups the user owns' do group1.add_maintainer(user2) - get api('/groups', user2), owned: true + get api('/groups', user2), params: { owned: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -241,7 +241,7 @@ describe API::Groups do end it 'returns an array of groups the user has at least master access' do - get api('/groups', user2), min_access_level: 40 + get api('/groups', user2), params: { min_access_level: 40 } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -344,7 +344,7 @@ describe API::Groups do project = create(:project, namespace: group2, path: 'Foo') create(:project_group_link, project: project, group: group1) - get api("/groups/#{group1.id}", user1), with_projects: false + get api("/groups/#{group1.id}", user1), params: { with_projects: false } expect(response).to have_gitlab_http_status(200) expect(json_response['projects']).to be_nil @@ -426,7 +426,7 @@ describe API::Groups do context 'when authenticated as the group owner' do it 'updates the group' do - put api("/groups/#{group1.id}", user1), name: new_group_name, request_access_enabled: true + put api("/groups/#{group1.id}", user1), params: { name: new_group_name, request_access_enabled: true } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) @@ -434,7 +434,7 @@ describe API::Groups do end it 'returns 404 for a non existing group' do - put api('/groups/1328', user1), name: new_group_name + put api('/groups/1328', user1), params: { name: new_group_name } expect(response).to have_gitlab_http_status(404) end @@ -442,7 +442,7 @@ describe API::Groups do context 'when authenticated as the admin' do it 'updates the group' do - put api("/groups/#{group1.id}", admin), name: new_group_name + put api("/groups/#{group1.id}", admin), params: { name: new_group_name } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) @@ -451,7 +451,7 @@ describe API::Groups do context 'when authenticated as an user that can see the group' do it 'does not updates the group' do - put api("/groups/#{group1.id}", user2), name: new_group_name + put api("/groups/#{group1.id}", user2), params: { name: new_group_name } expect(response).to have_gitlab_http_status(403) end @@ -459,7 +459,7 @@ describe API::Groups do context 'when authenticated as an user that cannot see the group' do it 'returns 404 when trying to update the group' do - put api("/groups/#{group2.id}", user1), name: new_group_name + put api("/groups/#{group2.id}", user1), params: { name: new_group_name } expect(response).to have_gitlab_http_status(404) end @@ -480,7 +480,7 @@ describe API::Groups do end it "returns the group's projects with simple representation" do - get api("/groups/#{group1.id}/projects", user1), simple: true + get api("/groups/#{group1.id}/projects", user1), params: { simple: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -493,7 +493,7 @@ describe API::Groups do it "filters the groups projects" do public_project = create(:project, :public, path: 'test1', group: group1) - get api("/groups/#{group1.id}/projects", user1), visibility: 'public' + get api("/groups/#{group1.id}/projects", user1), params: { visibility: 'public' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -507,7 +507,7 @@ describe API::Groups do create(:project_group_link, project: create(:project), group: group1) create(:project_group_link, project: create(:project), group: group1) - get api("/groups/#{group1.id}/projects", user1), with_shared: false + get api("/groups/#{group1.id}/projects", user1), params: { with_shared: false } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -520,7 +520,7 @@ describe API::Groups do create(:project, group: subgroup) create(:project, group: subgroup) - get api("/groups/#{group1.id}/projects", user1), include_subgroups: true + get api("/groups/#{group1.id}/projects", user1), params: { include_subgroups: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -554,7 +554,7 @@ describe API::Groups do it 'only returns the projects owned by user' do project2.group.add_owner(user3) - get api("/groups/#{project2.group.id}/projects", user3), owned: true + get api("/groups/#{project2.group.id}/projects", user3), params: { owned: true } expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) @@ -564,7 +564,7 @@ describe API::Groups do it 'only returns the projects starred by user' do user1.starred_projects = [project1] - get api("/groups/#{group1.id}/projects", user1), starred: true + get api("/groups/#{group1.id}/projects", user1), params: { starred: true } expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) @@ -663,7 +663,7 @@ describe API::Groups do context 'when using all_available in request' do it 'returns public subgroups' do - get api("/groups/#{group1.id}/subgroups", user2), all_available: true + get api("/groups/#{group1.id}/subgroups", user2), params: { all_available: true } expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array @@ -702,7 +702,7 @@ describe API::Groups do context 'when using statistics in request' do it 'does not include statistics' do - get api("/groups/#{group1.id}/subgroups", user2), statistics: true + get api("/groups/#{group1.id}/subgroups", user2), params: { statistics: true } expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array @@ -754,7 +754,7 @@ describe API::Groups do end it 'includes statistics if requested' do - get api("/groups/#{group1.id}/subgroups", admin), statistics: true + get api("/groups/#{group1.id}/subgroups", admin), params: { statistics: true } expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array @@ -766,7 +766,7 @@ describe API::Groups do describe "POST /groups" do context "when authenticated as user without group permissions" do it "does not create group" do - post api("/groups", user1), attributes_for(:group) + post api("/groups", user1), params: attributes_for(:group) expect(response).to have_gitlab_http_status(403) end @@ -777,7 +777,7 @@ describe API::Groups do end it 'can create subgroups' do - post api("/groups", user1), parent_id: group2.id, name: 'foo', path: 'foo' + post api("/groups", user1), params: { parent_id: group2.id, name: 'foo', path: 'foo' } expect(response).to have_gitlab_http_status(201) end @@ -789,7 +789,7 @@ describe API::Groups do end it 'cannot create subgroups' do - post api("/groups", user1), parent_id: group2.id, name: 'foo', path: 'foo' + post api("/groups", user1), params: { parent_id: group2.id, name: 'foo', path: 'foo' } expect(response).to have_gitlab_http_status(403) end @@ -800,7 +800,7 @@ describe API::Groups do it "creates group" do group = attributes_for(:group, { request_access_enabled: false }) - post api("/groups", user3), group + post api("/groups", user3), params: group expect(response).to have_gitlab_http_status(201) @@ -815,7 +815,7 @@ describe API::Groups do parent.add_owner(user3) group = attributes_for(:group, { parent_id: parent.id }) - post api("/groups", user3), group + post api("/groups", user3), params: group expect(response).to have_gitlab_http_status(201) @@ -824,20 +824,20 @@ describe API::Groups do end it "does not create group, duplicate" do - post api("/groups", user3), { name: 'Duplicate Test', path: group2.path } + post api("/groups", user3), params: { name: 'Duplicate Test', path: group2.path } expect(response).to have_gitlab_http_status(400) expect(response.message).to eq("Bad Request") end it "returns 400 bad request error if name not given" do - post api("/groups", user3), { path: group2.path } + post api("/groups", user3), params: { path: group2.path } expect(response).to have_gitlab_http_status(400) end it "returns 400 bad request error if path not given" do - post api("/groups", user3), { name: 'test' } + post api("/groups", user3), params: { name: 'test' } expect(response).to have_gitlab_http_status(400) end diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index f7916441313..a0c64d295c0 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -283,7 +283,7 @@ describe API::Helpers do it 'sends the params, excluding confidential values' do expect(ProjectsFinder).to receive(:new).and_raise('Runtime Error!') - get api('/projects', user), password: 'dont_send_this', other_param: 'send_this' + get api('/projects', user), params: { password: 'dont_send_this', other_param: 'send_this' } expect(event_data).to include('other_param=send_this') expect(event_data).to include('password=********') diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 89abdba98cf..589816b5d8f 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -12,7 +12,7 @@ describe API::Internal do it do expect_any_instance_of(Redis).to receive(:ping).and_return('PONG') - get api("/internal/check"), secret_token: secret_token + get api("/internal/check"), params: { secret_token: secret_token } expect(response).to have_gitlab_http_status(200) expect(json_response['api_version']).to eq(API::API.version) @@ -22,7 +22,7 @@ describe API::Internal do it 'returns false for field `redis` when redis is unavailable' do expect_any_instance_of(Redis).to receive(:ping).and_raise(Errno::ENOENT) - get api("/internal/check"), secret_token: secret_token + get api("/internal/check"), params: { secret_token: secret_token } expect(json_response['redis']).to be(false) end @@ -33,7 +33,7 @@ describe API::Internal do let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now ) } it 'returns one broadcast message' do - get api('/internal/broadcast_message'), secret_token: secret_token + get api('/internal/broadcast_message'), params: { secret_token: secret_token } expect(response).to have_gitlab_http_status(200) expect(json_response['message']).to eq(broadcast_message.message) @@ -42,7 +42,7 @@ describe API::Internal do context 'broadcast message does not exist' do it 'returns nothing' do - get api('/internal/broadcast_message'), secret_token: secret_token + get api('/internal/broadcast_message'), params: { secret_token: secret_token } expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty @@ -53,7 +53,7 @@ describe API::Internal do it 'returns nothing' do allow(BroadcastMessage).to receive(:current).and_return(nil) - get api('/internal/broadcast_message'), secret_token: secret_token + get api('/internal/broadcast_message'), params: { secret_token: secret_token } expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty @@ -66,7 +66,7 @@ describe API::Internal do let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now ) } it 'returns active broadcast message(s)' do - get api('/internal/broadcast_messages'), secret_token: secret_token + get api('/internal/broadcast_messages'), params: { secret_token: secret_token } expect(response).to have_gitlab_http_status(200) expect(json_response[0]['message']).to eq(broadcast_message.message) @@ -75,7 +75,7 @@ describe API::Internal do context 'broadcast message does not exist' do it 'returns nothing' do - get api('/internal/broadcast_messages'), secret_token: secret_token + get api('/internal/broadcast_messages'), params: { secret_token: secret_token } expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty @@ -86,8 +86,10 @@ describe API::Internal do describe 'GET /internal/two_factor_recovery_codes' do it 'returns an error message when the key does not exist' do post api('/internal/two_factor_recovery_codes'), - secret_token: secret_token, - key_id: 12345 + params: { + secret_token: secret_token, + key_id: 12345 + } expect(json_response['success']).to be_falsey expect(json_response['message']).to eq('Could not find the given key') @@ -97,8 +99,10 @@ describe API::Internal do deploy_key = create(:deploy_key) post api('/internal/two_factor_recovery_codes'), - secret_token: secret_token, - key_id: deploy_key.id + params: { + secret_token: secret_token, + key_id: deploy_key.id + } expect(json_response['success']).to be_falsey expect(json_response['message']).to eq('Deploy keys cannot be used to retrieve recovery codes') @@ -108,8 +112,10 @@ describe API::Internal do key_without_user = create(:key, user: nil) post api('/internal/two_factor_recovery_codes'), - secret_token: secret_token, - key_id: key_without_user.id + params: { + secret_token: secret_token, + key_id: key_without_user.id + } expect(json_response['success']).to be_falsey expect(json_response['message']).to eq('Could not find a user for the given key') @@ -123,8 +129,10 @@ describe API::Internal do .to receive(:generate_otp_backup_codes!).and_return(%w(119135e5a3ebce8e 34bd7b74adbc8861)) post api('/internal/two_factor_recovery_codes'), - secret_token: secret_token, - key_id: key.id + params: { + secret_token: secret_token, + key_id: key.id + } expect(json_response['success']).to be_truthy expect(json_response['recovery_codes']).to match_array(%w(119135e5a3ebce8e 34bd7b74adbc8861)) @@ -136,8 +144,10 @@ describe API::Internal do allow_any_instance_of(User).to receive(:two_factor_enabled?).and_return(false) post api('/internal/two_factor_recovery_codes'), - secret_token: secret_token, - key_id: key.id + params: { + secret_token: secret_token, + key_id: key.id + } expect(json_response['success']).to be_falsey expect(json_response['recovery_codes']).to be_nil @@ -204,7 +214,7 @@ describe API::Internal do describe "GET /internal/discover" do it "finds a user by key id" do - get(api("/internal/discover"), key_id: key.id, secret_token: secret_token) + get(api("/internal/discover"), params: { key_id: key.id, secret_token: secret_token }) expect(response).to have_gitlab_http_status(200) @@ -212,7 +222,7 @@ describe API::Internal do end it "finds a user by user id" do - get(api("/internal/discover"), user_id: user.id, secret_token: secret_token) + get(api("/internal/discover"), params: { user_id: user.id, secret_token: secret_token }) expect(response).to have_gitlab_http_status(200) @@ -220,7 +230,7 @@ describe API::Internal do end it "finds a user by username" do - get(api("/internal/discover"), username: user.username, secret_token: secret_token) + get(api("/internal/discover"), params: { username: user.username, secret_token: secret_token }) expect(response).to have_gitlab_http_status(200) @@ -231,7 +241,7 @@ describe API::Internal do describe "GET /internal/authorized_keys" do context "using an existing key's fingerprint" do it "finds the key" do - get(api('/internal/authorized_keys'), fingerprint: key.fingerprint, secret_token: secret_token) + get(api('/internal/authorized_keys'), params: { fingerprint: key.fingerprint, secret_token: secret_token }) expect(response.status).to eq(200) expect(json_response["key"]).to eq(key.key) @@ -240,7 +250,7 @@ describe API::Internal do context "non existing key's fingerprint" do it "returns 404" do - get(api('/internal/authorized_keys'), fingerprint: "no:t-:va:li:d0", secret_token: secret_token) + get(api('/internal/authorized_keys'), params: { fingerprint: "no:t-:va:li:d0", secret_token: secret_token }) expect(response.status).to eq(404) end @@ -248,7 +258,7 @@ describe API::Internal do context "using a partial fingerprint" do it "returns 404" do - get(api('/internal/authorized_keys'), fingerprint: "#{key.fingerprint[0..5]}%", secret_token: secret_token) + get(api('/internal/authorized_keys'), params: { fingerprint: "#{key.fingerprint[0..5]}%", secret_token: secret_token }) expect(response.status).to eq(404) end @@ -256,20 +266,20 @@ describe API::Internal do context "sending the key" do it "finds the key" do - get(api('/internal/authorized_keys'), key: key.key.split[1], secret_token: secret_token) + get(api('/internal/authorized_keys'), params: { key: key.key.split[1], secret_token: secret_token }) expect(response.status).to eq(200) expect(json_response["key"]).to eq(key.key) end it "returns 404 with a partial key" do - get(api('/internal/authorized_keys'), key: key.key.split[1][0...-3], secret_token: secret_token) + get(api('/internal/authorized_keys'), params: { key: key.key.split[1][0...-3], secret_token: secret_token }) expect(response.status).to eq(404) end it "returns 404 with an not valid base64 string" do - get(api('/internal/authorized_keys'), key: "whatever!", secret_token: secret_token) + get(api('/internal/authorized_keys'), params: { key: "whatever!", secret_token: secret_token }) expect(response.status).to eq(404) end @@ -677,7 +687,7 @@ describe API::Internal do end it 'returns link to create new merge request' do - get api("/internal/merge_request_urls?project=#{repo_name}&changes=#{changes}"), secret_token: secret_token + get api("/internal/merge_request_urls?project=#{repo_name}&changes=#{changes}"), params: { secret_token: secret_token } expect(json_response).to match [{ "branch_name" => "new_branch", @@ -689,7 +699,7 @@ describe API::Internal do it 'returns empty array if printing_merge_request_link_enabled is false' do project.update!(printing_merge_request_link_enabled: false) - get api("/internal/merge_request_urls?project=#{repo_name}&changes=#{changes}"), secret_token: secret_token + get api("/internal/merge_request_urls?project=#{repo_name}&changes=#{changes}"), params: { secret_token: secret_token } expect(json_response).to eq([]) end @@ -698,7 +708,7 @@ describe API::Internal do let(:gl_repository) { "project-#{project.id}" } it 'returns link to create new merge request' do - get api("/internal/merge_request_urls?gl_repository=#{gl_repository}&changes=#{changes}"), secret_token: secret_token + get api("/internal/merge_request_urls?gl_repository=#{gl_repository}&changes=#{changes}"), params: { secret_token: secret_token } expect(json_response).to match [{ "branch_name" => "new_branch", @@ -817,7 +827,7 @@ describe API::Internal do expect(PostReceive).to receive(:perform_async) .with(gl_repository, identifier, changes) - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params end it 'decreases the reference counter and returns the result' do @@ -825,13 +835,13 @@ describe API::Internal do .and_return(reference_counter) expect(reference_counter).to receive(:decrease).and_return(true) - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params expect(json_response['reference_counter_decreased']).to be(true) end it 'returns link to create new merge request' do - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params expect(json_response['merge_request_urls']).to match [{ "branch_name" => "new_branch", @@ -843,7 +853,7 @@ describe API::Internal do it 'returns empty array if printing_merge_request_link_enabled is false' do project.update!(printing_merge_request_link_enabled: false) - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params expect(json_response['merge_request_urls']).to eq([]) end @@ -852,7 +862,7 @@ describe API::Internal do let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now ) } it 'returns one broadcast message' do - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params expect(response).to have_gitlab_http_status(200) expect(json_response['broadcast_message']).to eq(broadcast_message.message) @@ -861,7 +871,7 @@ describe API::Internal do context 'broadcast message does not exist' do it 'returns empty string' do - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params expect(response).to have_gitlab_http_status(200) expect(json_response['broadcast_message']).to eq(nil) @@ -872,7 +882,7 @@ describe API::Internal do it 'returns empty string' do allow(BroadcastMessage).to receive(:current).and_return(nil) - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params expect(response).to have_gitlab_http_status(200) expect(json_response['broadcast_message']).to eq(nil) @@ -884,7 +894,7 @@ describe API::Internal do project_moved = Gitlab::Checks::ProjectMoved.new(project, user, 'http', 'foo/baz') project_moved.add_message - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params expect(response).to have_gitlab_http_status(200) expect(json_response["redirected_message"]).to be_present @@ -897,7 +907,7 @@ describe API::Internal do project_created = Gitlab::Checks::ProjectCreated.new(project, user, 'http') project_created.add_message - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params expect(response).to have_gitlab_http_status(200) expect(json_response["project_created_message"]).to be_present @@ -909,7 +919,7 @@ describe API::Internal do it 'does not try to notify that project moved' do allow_any_instance_of(Gitlab::Identifier).to receive(:identify).and_return(nil) - post api("/internal/post_receive"), valid_params + post api("/internal/post_receive"), params: valid_params expect(response).to have_gitlab_http_status(200) end @@ -926,7 +936,7 @@ describe API::Internal do .and_return(reference_counter) expect(reference_counter).to receive(:increase).and_return(true) - post api("/internal/pre_receive"), valid_params + post api("/internal/pre_receive"), params: valid_params expect(json_response['reference_counter_increased']).to be(true) end @@ -946,12 +956,14 @@ describe API::Internal do def pull(key, project, protocol = 'ssh') post( api("/internal/allowed"), - key_id: key.id, - project: project.full_path, - gl_repository: gl_repository_for(project), - action: 'git-upload-pack', - secret_token: secret_token, - protocol: protocol + params: { + key_id: key.id, + project: project.full_path, + gl_repository: gl_repository_for(project), + action: 'git-upload-pack', + secret_token: secret_token, + protocol: protocol + } ) end @@ -976,39 +988,47 @@ describe API::Internal do def archive(key, project) post( api("/internal/allowed"), - ref: 'master', - key_id: key.id, - project: project.full_path, - gl_repository: gl_repository_for(project), - action: 'git-upload-archive', - secret_token: secret_token, - protocol: 'ssh' + params: { + ref: 'master', + key_id: key.id, + project: project.full_path, + gl_repository: gl_repository_for(project), + action: 'git-upload-archive', + secret_token: secret_token, + protocol: 'ssh' + } ) end def lfs_auth_project(project) post( api("/internal/lfs_authenticate"), - secret_token: secret_token, - project: project.full_path + params: { + secret_token: secret_token, + project: project.full_path + } ) end def lfs_auth_key(key_id, project) post( api("/internal/lfs_authenticate"), - key_id: key_id, - secret_token: secret_token, - project: project.full_path + params: { + key_id: key_id, + secret_token: secret_token, + project: project.full_path + } ) end def lfs_auth_user(user_id, project) post( api("/internal/lfs_authenticate"), - user_id: user_id, - secret_token: secret_token, - project: project.full_path + params: { + user_id: user_id, + secret_token: secret_token, + project: project.full_path + } ) end end diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 1827da61e2d..0fd465da4f8 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -66,7 +66,7 @@ describe API::Issues do describe "GET /issues" do context "when unauthenticated" do it "returns an array of all issues" do - get api("/issues"), scope: 'all' + get api("/issues"), params: { scope: 'all' } expect(response).to have_http_status(200) expect(json_response).to be_an Array @@ -79,13 +79,13 @@ describe API::Issues do end it "returns authentication error when scope is assigned-to-me" do - get api("/issues"), scope: 'assigned-to-me' + get api("/issues"), params: { scope: 'assigned-to-me' } expect(response).to have_http_status(401) end it "returns authentication error when scope is created-by-me" do - get api("/issues"), scope: 'created-by-me' + get api("/issues"), params: { scope: 'created-by-me' } expect(response).to have_http_status(401) end @@ -103,21 +103,21 @@ describe API::Issues do end it 'returns an array of closed issues' do - get api('/issues', user), state: :closed + get api('/issues', user), params: { state: :closed } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(closed_issue.id) end it 'returns an array of opened issues' do - get api('/issues', user), state: :opened + get api('/issues', user), params: { state: :opened } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(issue.id) end it 'returns an array of all issues' do - get api('/issues', user), state: :all + get api('/issues', user), params: { state: :all } expect_paginated_array_response(size: 2) expect(first_issue['id']).to eq(issue.id) @@ -127,7 +127,7 @@ describe API::Issues do it 'returns issues assigned to me' do issue2 = create(:issue, assignees: [user2], project: project) - get api('/issues', user2), scope: 'assigned_to_me' + get api('/issues', user2), params: { scope: 'assigned_to_me' } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(issue2.id) @@ -136,7 +136,7 @@ describe API::Issues do it 'returns issues assigned to me (kebab-case)' do issue2 = create(:issue, assignees: [user2], project: project) - get api('/issues', user2), scope: 'assigned-to-me' + get api('/issues', user2), params: { scope: 'assigned-to-me' } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(issue2.id) @@ -145,7 +145,7 @@ describe API::Issues do it 'returns issues authored by the given author id' do issue2 = create(:issue, author: user2, project: project) - get api('/issues', user), author_id: user2.id, scope: 'all' + get api('/issues', user), params: { author_id: user2.id, scope: 'all' } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(issue2.id) @@ -154,7 +154,7 @@ describe API::Issues do it 'returns issues assigned to the given assignee id' do issue2 = create(:issue, assignees: [user2], project: project) - get api('/issues', user), assignee_id: user2.id, scope: 'all' + get api('/issues', user), params: { assignee_id: user2.id, scope: 'all' } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(issue2.id) @@ -163,7 +163,7 @@ describe API::Issues do it 'returns issues authored by the given author id and assigned to the given assignee id' do issue2 = create(:issue, author: user2, assignees: [user2], project: project) - get api('/issues', user), author_id: user2.id, assignee_id: user2.id, scope: 'all' + get api('/issues', user), params: { author_id: user2.id, assignee_id: user2.id, scope: 'all' } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(issue2.id) @@ -172,7 +172,7 @@ describe API::Issues do it 'returns issues with no assignee' do issue2 = create(:issue, author: user2, project: project) - get api('/issues', user), assignee_id: 0, scope: 'all' + get api('/issues', user), params: { assignee_id: 0, scope: 'all' } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(issue2.id) @@ -181,7 +181,7 @@ describe API::Issues do it 'returns issues with no assignee' do issue2 = create(:issue, author: user2, project: project) - get api('/issues', user), assignee_id: 'None', scope: 'all' + get api('/issues', user), params: { assignee_id: 'None', scope: 'all' } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(issue2.id) @@ -191,7 +191,7 @@ describe API::Issues do # This issue without assignee should not be returned create(:issue, author: user2, project: project) - get api('/issues', user), assignee_id: 'Any', scope: 'all' + get api('/issues', user), params: { assignee_id: 'Any', scope: 'all' } expect_paginated_array_response(size: 3) end @@ -202,7 +202,7 @@ describe API::Issues do create(:award_emoji, awardable: issue, user: user2, name: 'thumbsup') - get api('/issues', user2), my_reaction_emoji: 'Any', scope: 'all' + get api('/issues', user2), params: { my_reaction_emoji: 'Any', scope: 'all' } expect_paginated_array_response(size: 2) end @@ -211,20 +211,20 @@ describe API::Issues do issue2 = create(:issue, project: project, author: user, assignees: [user]) create(:award_emoji, awardable: issue2, user: user2, name: 'star') - get api('/issues', user2), my_reaction_emoji: 'None', scope: 'all' + get api('/issues', user2), params: { my_reaction_emoji: 'None', scope: 'all' } expect_paginated_array_response(size: 2) end it 'returns issues matching given search string for title' do - get api("/issues", user), search: issue.title + get api("/issues", user), params: { search: issue.title } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(issue.id) end it 'returns issues matching given search string for description' do - get api("/issues", user), search: issue.description + get api("/issues", user), params: { search: issue.description } expect_paginated_array_response(size: 1) expect(first_issue['id']).to eq(issue.id) @@ -267,7 +267,7 @@ describe API::Issues do end it 'returns an array of labeled issues' do - get api("/issues", user), labels: label.title + get api("/issues", user), params: { labels: label.title } expect_paginated_array_response(size: 1) expect(first_issue['labels']).to eq([label.title]) @@ -280,20 +280,20 @@ describe API::Issues do create(:label_link, label: label_b, target: issue) create(:label_link, label: label_c, target: issue) - get api("/issues", user), labels: "#{label.title},#{label_b.title},#{label_c.title}" + get api("/issues", user), params: { labels: "#{label.title},#{label_b.title},#{label_c.title}" } expect_paginated_array_response(size: 1) expect(json_response.first['labels']).to eq([label_c.title, label_b.title, label.title]) end it 'returns an empty array if no issue matches labels' do - get api('/issues', user), labels: 'foo,bar' + get api('/issues', user), params: { labels: 'foo,bar' } expect_paginated_array_response(size: 0) end it 'returns an array of labeled issues matching given state' do - get api("/issues", user), labels: label.title, state: :opened + get api("/issues", user), params: { labels: label.title, state: :opened } expect_paginated_array_response(size: 1) expect(json_response.first['labels']).to eq([label.title]) @@ -301,27 +301,27 @@ describe API::Issues do end it 'returns an empty array if no issue matches labels and state filters' do - get api("/issues", user), labels: label.title, state: :closed + get api("/issues", user), params: { labels: label.title, state: :closed } expect_paginated_array_response(size: 0) end it 'returns an array of issues with any label' do - get api("/issues", user), labels: IssuesFinder::FILTER_ANY + get api("/issues", user), params: { labels: IssuesFinder::FILTER_ANY } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(issue.id) end it 'returns an array of issues with no label' do - get api("/issues", user), labels: IssuesFinder::FILTER_NONE + get api("/issues", user), params: { labels: IssuesFinder::FILTER_NONE } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(closed_issue.id) end it 'returns an array of issues with no label when using the legacy No+Label filter' do - get api("/issues", user), labels: "No Label" + get api("/issues", user), params: { labels: "No Label" } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(closed_issue.id) @@ -363,14 +363,14 @@ describe API::Issues do end it 'returns an array of issues found by iids' do - get api('/issues', user), iids: [closed_issue.iid] + get api('/issues', user), params: { iids: [closed_issue.iid] } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(closed_issue.id) end it 'returns an empty array if iid does not exist' do - get api("/issues", user), iids: [99999] + get api("/issues", user), params: { iids: [99999] } expect_paginated_array_response(size: 0) end @@ -506,58 +506,58 @@ describe API::Issues do end it 'returns group issues without confidential issues for non project members' do - get api(base_url, non_member), state: :opened + get api(base_url, non_member), params: { state: :opened } expect_paginated_array_response(size: 1) expect(json_response.first['title']).to eq(group_issue.title) end it 'returns group confidential issues for author' do - get api(base_url, author), state: :opened + get api(base_url, author), params: { state: :opened } expect_paginated_array_response(size: 2) end it 'returns group confidential issues for assignee' do - get api(base_url, assignee), state: :opened + get api(base_url, assignee), params: { state: :opened } expect_paginated_array_response(size: 2) end it 'returns group issues with confidential issues for project members' do - get api(base_url, user), state: :opened + get api(base_url, user), params: { state: :opened } expect_paginated_array_response(size: 2) end it 'returns group confidential issues for admin' do - get api(base_url, admin), state: :opened + get api(base_url, admin), params: { state: :opened } expect_paginated_array_response(size: 2) end it 'returns an array of labeled group issues' do - get api(base_url, user), labels: group_label.title + get api(base_url, user), params: { labels: group_label.title } expect_paginated_array_response(size: 1) expect(json_response.first['labels']).to eq([group_label.title]) end it 'returns an array of labeled group issues where all labels match' do - get api(base_url, user), labels: "#{group_label.title},foo,bar" + get api(base_url, user), params: { labels: "#{group_label.title},foo,bar" } expect_paginated_array_response(size: 0) end it 'returns issues matching given search string for title' do - get api(base_url, user), search: group_issue.title + get api(base_url, user), params: { search: group_issue.title } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(group_issue.id) end it 'returns issues matching given search string for description' do - get api(base_url, user), search: group_issue.description + get api(base_url, user), params: { search: group_issue.description } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(group_issue.id) @@ -570,40 +570,40 @@ describe API::Issues do create(:label_link, label: label_b, target: group_issue) create(:label_link, label: label_c, target: group_issue) - get api(base_url, user), labels: "#{group_label.title},#{label_b.title},#{label_c.title}" + get api(base_url, user), params: { labels: "#{group_label.title},#{label_b.title},#{label_c.title}" } expect_paginated_array_response(size: 1) expect(json_response.first['labels']).to eq([label_c.title, label_b.title, group_label.title]) end it 'returns an array of issues found by iids' do - get api(base_url, user), iids: [group_issue.iid] + get api(base_url, user), params: { iids: [group_issue.iid] } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(group_issue.id) end it 'returns an empty array if iid does not exist' do - get api(base_url, user), iids: [99999] + get api(base_url, user), params: { iids: [99999] } expect_paginated_array_response(size: 0) end it 'returns an empty array if no group issue matches labels' do - get api(base_url, user), labels: 'foo,bar' + get api(base_url, user), params: { labels: 'foo,bar' } expect_paginated_array_response(size: 0) end it 'returns an array of group issues with any label' do - get api(base_url, user), labels: IssuesFinder::FILTER_ANY + get api(base_url, user), params: { labels: IssuesFinder::FILTER_ANY } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(group_issue.id) end it 'returns an array of group issues with no label' do - get api(base_url, user), labels: IssuesFinder::FILTER_NONE + get api(base_url, user), params: { labels: IssuesFinder::FILTER_NONE } response_ids = json_response.map { |issue| issue['id'] } @@ -612,33 +612,33 @@ describe API::Issues do end it 'returns an empty array if no issue matches milestone' do - get api(base_url, user), milestone: group_empty_milestone.title + get api(base_url, user), params: { milestone: group_empty_milestone.title } expect_paginated_array_response(size: 0) end it 'returns an empty array if milestone does not exist' do - get api(base_url, user), milestone: 'foo' + get api(base_url, user), params: { milestone: 'foo' } expect_paginated_array_response(size: 0) end it 'returns an array of issues in given milestone' do - get api(base_url, user), state: :opened, milestone: group_milestone.title + get api(base_url, user), params: { state: :opened, milestone: group_milestone.title } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(group_issue.id) end it 'returns an array of issues matching state in milestone' do - get api(base_url, user), milestone: group_milestone.title, state: :closed + get api(base_url, user), params: { milestone: group_milestone.title, state: :closed } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(group_closed_issue.id) end it 'returns an array of issues with no milestone' do - get api(base_url, user), milestone: no_milestone_title + get api(base_url, user), params: { milestone: no_milestone_title } expect(response).to have_gitlab_http_status(200) @@ -674,7 +674,7 @@ describe API::Issues do end it 'sorts by updated_at ascending when requested' do - get api(base_url, user), order_by: :updated_at, sort: :asc + get api(base_url, user), params: { order_by: :updated_at, sort: :asc } response_dates = json_response.map { |issue| issue['updated_at'] } @@ -777,7 +777,7 @@ describe API::Issues do end it 'returns an array of labeled project issues' do - get api("#{base_url}/issues", user), labels: label.title + get api("#{base_url}/issues", user), params: { labels: label.title } expect_paginated_array_response(size: 1) expect(json_response.first['labels']).to eq([label.title]) @@ -790,7 +790,7 @@ describe API::Issues do create(:label_link, label: label_b, target: issue) create(:label_link, label: label_c, target: issue) - get api("#{base_url}/issues", user), labels: "#{label.title},#{label_b.title},#{label_c.title}" + get api("#{base_url}/issues", user), params: { labels: "#{label.title},#{label_b.title},#{label_c.title}" } expect_paginated_array_response(size: 1) expect(json_response.first['labels']).to eq([label_c.title, label_b.title, label.title]) @@ -811,14 +811,14 @@ describe API::Issues do end it 'returns an array of issues found by iids' do - get api("#{base_url}/issues", user), iids: [issue.iid] + get api("#{base_url}/issues", user), params: { iids: [issue.iid] } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(issue.id) end it 'returns an empty array if iid does not exist' do - get api("#{base_url}/issues", user), iids: [99999] + get api("#{base_url}/issues", user), params: { iids: [99999] } expect_paginated_array_response(size: 0) end @@ -830,14 +830,14 @@ describe API::Issues do end it 'returns an array of project issues with any label' do - get api("#{base_url}/issues", user), labels: IssuesFinder::FILTER_ANY + get api("#{base_url}/issues", user), params: { labels: IssuesFinder::FILTER_ANY } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(issue.id) end it 'returns an array of project issues with no label' do - get api("#{base_url}/issues", user), labels: IssuesFinder::FILTER_NONE + get api("#{base_url}/issues", user), params: { labels: IssuesFinder::FILTER_NONE } response_ids = json_response.map { |issue| issue['id'] } @@ -846,25 +846,25 @@ describe API::Issues do end it 'returns an empty array if no project issue matches labels' do - get api("#{base_url}/issues", user), labels: 'foo,bar' + get api("#{base_url}/issues", user), params: { labels: 'foo,bar' } expect_paginated_array_response(size: 0) end it 'returns an empty array if no issue matches milestone' do - get api("#{base_url}/issues", user), milestone: empty_milestone.title + get api("#{base_url}/issues", user), params: { milestone: empty_milestone.title } expect_paginated_array_response(size: 0) end it 'returns an empty array if milestone does not exist' do - get api("#{base_url}/issues", user), milestone: :foo + get api("#{base_url}/issues", user), params: { milestone: :foo } expect_paginated_array_response(size: 0) end it 'returns an array of issues in given milestone' do - get api("#{base_url}/issues", user), milestone: milestone.title + get api("#{base_url}/issues", user), params: { milestone: milestone.title } expect_paginated_array_response(size: 2) expect(json_response.first['id']).to eq(issue.id) @@ -872,21 +872,21 @@ describe API::Issues do end it 'returns an array of issues matching state in milestone' do - get api("#{base_url}/issues", user), milestone: milestone.title, state: :closed + get api("#{base_url}/issues", user), params: { milestone: milestone.title, state: :closed } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(closed_issue.id) end it 'returns an array of issues with no milestone' do - get api("#{base_url}/issues", user), milestone: no_milestone_title + get api("#{base_url}/issues", user), params: { milestone: no_milestone_title } expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(confidential_issue.id) end it 'returns an array of issues with any milestone' do - get api("#{base_url}/issues", user), milestone: any_milestone_title + get api("#{base_url}/issues", user), params: { milestone: any_milestone_title } response_ids = json_response.map { |issue| issue['id'] } @@ -904,7 +904,7 @@ describe API::Issues do end it 'sorts ascending when requested' do - get api("#{base_url}/issues", user), sort: :asc + get api("#{base_url}/issues", user), params: { sort: :asc } response_dates = json_response.map { |issue| issue['created_at'] } @@ -913,7 +913,7 @@ describe API::Issues do end it 'sorts by updated_at descending when requested' do - get api("#{base_url}/issues", user), order_by: :updated_at + get api("#{base_url}/issues", user), params: { order_by: :updated_at } response_dates = json_response.map { |issue| issue['updated_at'] } @@ -922,7 +922,7 @@ describe API::Issues do end it 'sorts by updated_at ascending when requested' do - get api("#{base_url}/issues", user), order_by: :updated_at, sort: :asc + get api("#{base_url}/issues", user), params: { order_by: :updated_at, sort: :asc } response_dates = json_response.map { |issue| issue['updated_at'] } @@ -1051,7 +1051,7 @@ describe API::Issues do context 'support for deprecated assignee_id' do it 'creates a new project issue' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', assignee_id: user2.id + params: { title: 'new issue', assignee_id: user2.id } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') @@ -1061,7 +1061,7 @@ describe API::Issues do it 'creates a new project issue when assignee_id is empty' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', assignee_id: '' + params: { title: 'new issue', assignee_id: '' } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') @@ -1072,7 +1072,7 @@ describe API::Issues do context 'single assignee restrictions' do it 'creates a new project issue with no more than one assignee' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', assignee_ids: [user2.id, guest.id] + params: { title: 'new issue', assignee_ids: [user2.id, guest.id] } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') @@ -1088,7 +1088,7 @@ describe API::Issues do end it 'renders 403' do - post api("/projects/#{project.id}/issues", not_member), title: 'new issue' + post api("/projects/#{project.id}/issues", not_member), params: { title: 'new issue' } expect(response).to have_gitlab_http_status(403) end @@ -1098,7 +1098,7 @@ describe API::Issues do context 'by an admin' do it 'sets the internal ID on the new issue' do post api("/projects/#{project.id}/issues", admin), - title: 'new issue', iid: 9001 + params: { title: 'new issue', iid: 9001 } expect(response).to have_gitlab_http_status(201) expect(json_response['iid']).to eq 9001 @@ -1108,7 +1108,7 @@ describe API::Issues do context 'by an owner' do it 'sets the internal ID on the new issue' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', iid: 9001 + params: { title: 'new issue', iid: 9001 } expect(response).to have_gitlab_http_status(201) expect(json_response['iid']).to eq 9001 @@ -1122,7 +1122,7 @@ describe API::Issues do it 'sets the internal ID on the new issue' do group.add_owner(user2) post api("/projects/#{group_project.id}/issues", user2), - title: 'new issue', iid: 9001 + params: { title: 'new issue', iid: 9001 } expect(response).to have_gitlab_http_status(201) expect(json_response['iid']).to eq 9001 @@ -1132,7 +1132,7 @@ describe API::Issues do context 'by another user' do it 'ignores the given internal ID' do post api("/projects/#{project.id}/issues", user2), - title: 'new issue', iid: 9001 + params: { title: 'new issue', iid: 9001 } expect(response).to have_gitlab_http_status(201) expect(json_response['iid']).not_to eq 9001 @@ -1142,8 +1142,7 @@ describe API::Issues do it 'creates a new project issue' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', labels: 'label, label2', weight: 3, - assignee_ids: [user2.id] + params: { title: 'new issue', labels: 'label, label2', weight: 3, assignee_ids: [user2.id] } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') @@ -1156,7 +1155,7 @@ describe API::Issues do it 'creates a new confidential project issue' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', confidential: true + params: { title: 'new issue', confidential: true } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') @@ -1165,7 +1164,7 @@ describe API::Issues do it 'creates a new confidential project issue with a different param' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', confidential: 'y' + params: { title: 'new issue', confidential: 'y' } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') @@ -1174,7 +1173,7 @@ describe API::Issues do it 'creates a public issue when confidential param is false' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', confidential: false + params: { title: 'new issue', confidential: false } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') @@ -1183,21 +1182,23 @@ describe API::Issues do it 'creates a public issue when confidential param is invalid' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', confidential: 'foo' + params: { title: 'new issue', confidential: 'foo' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') end it "returns a 400 bad request if title not given" do - post api("/projects/#{project.id}/issues", user), labels: 'label, label2' + post api("/projects/#{project.id}/issues", user), params: { labels: 'label, label2' } expect(response).to have_gitlab_http_status(400) end it 'allows special label names' do post api("/projects/#{project.id}/issues", user), - title: 'new issue', - labels: 'label, label?, label&foo, ?, &' + params: { + title: 'new issue', + labels: 'label, label?, label&foo, ?, &' + } expect(response.status).to eq(201) expect(json_response['labels']).to include 'label' expect(json_response['labels']).to include 'label?' @@ -1208,7 +1209,7 @@ describe API::Issues do it 'returns 400 if title is too long' do post api("/projects/#{project.id}/issues", user), - title: 'g' * 256 + params: { title: 'g' * 256 } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' @@ -1227,8 +1228,10 @@ describe API::Issues do context 'resolving all discussions in a merge request' do before do post api("/projects/#{project.id}/issues", user), - title: 'New Issue', - merge_request_to_resolve_discussions_of: merge_request.iid + params: { + title: 'New Issue', + merge_request_to_resolve_discussions_of: merge_request.iid + } end it_behaves_like 'creating an issue resolving discussions through the API' @@ -1237,9 +1240,11 @@ describe API::Issues do context 'resolving a single discussion' do before do post api("/projects/#{project.id}/issues", user), - title: 'New Issue', - merge_request_to_resolve_discussions_of: merge_request.iid, - discussion_to_resolve: discussion.id + params: { + title: 'New Issue', + merge_request_to_resolve_discussions_of: merge_request.iid, + discussion_to_resolve: discussion.id + } end it_behaves_like 'creating an issue resolving discussions through the API' @@ -1251,7 +1256,7 @@ describe API::Issues do due_date = 2.weeks.from_now.strftime('%Y-%m-%d') post api("/projects/#{project.id}/issues", user), - title: 'new issue', due_date: due_date + params: { title: 'new issue', due_date: due_date } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') @@ -1266,7 +1271,7 @@ describe API::Issues do context 'by an admin' do it 'sets the creation time on the new issue' do - post api("/projects/#{project.id}/issues", admin), params + post api("/projects/#{project.id}/issues", admin), params: params expect(response).to have_gitlab_http_status(201) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) @@ -1275,7 +1280,7 @@ describe API::Issues do context 'by a project owner' do it 'sets the creation time on the new issue' do - post api("/projects/#{project.id}/issues", user), params + post api("/projects/#{project.id}/issues", user), params: params expect(response).to have_gitlab_http_status(201) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) @@ -1287,7 +1292,7 @@ describe API::Issues do group = create(:group) group_project = create(:project, :public, namespace: group) group.add_owner(user2) - post api("/projects/#{group_project.id}/issues", user2), params + post api("/projects/#{group_project.id}/issues", user2), params: params expect(response).to have_gitlab_http_status(201) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) @@ -1296,7 +1301,7 @@ describe API::Issues do context 'by another user' do it 'ignores the given creation time' do - post api("/projects/#{project.id}/issues", user2), params + post api("/projects/#{project.id}/issues", user2), params: params expect(response).to have_gitlab_http_status(201) expect(Time.parse(json_response['created_at'])).not_to be_like_time(creation_time) @@ -1307,7 +1312,7 @@ describe API::Issues do context 'the user can only read the issue' do it 'cannot create new labels' do expect do - post api("/projects/#{project.id}/issues", non_member), title: 'new issue', labels: 'label, label2' + post api("/projects/#{project.id}/issues", non_member), params: { title: 'new issue', labels: 'label, label2' } end.not_to change { project.labels.count } end end @@ -1328,7 +1333,7 @@ describe API::Issues do end it "does not create a new project issue" do - expect { post api("/projects/#{project.id}/issues", user), params }.not_to change(Issue, :count) + expect { post api("/projects/#{project.id}/issues", user), params: params }.not_to change(Issue, :count) expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) @@ -1344,7 +1349,7 @@ describe API::Issues do describe "PUT /projects/:id/issues/:issue_iid to update only title" do it "updates a project issue" do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - title: 'updated title' + params: { title: 'updated title' } expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') @@ -1352,20 +1357,22 @@ describe API::Issues do it "returns 404 error if issue iid not found" do put api("/projects/#{project.id}/issues/44444", user), - title: 'updated title' + params: { title: 'updated title' } expect(response).to have_gitlab_http_status(404) end it "returns 404 error if issue id is used instead of the iid" do put api("/projects/#{project.id}/issues/#{issue.id}", user), - title: 'updated title' + params: { title: 'updated title' } expect(response).to have_gitlab_http_status(404) end it 'allows special label names' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - title: 'updated title', - labels: 'label, label?, label&foo, ?, &' + params: { + title: 'updated title', + labels: 'label, label?, label&foo, ?, &' + } expect(response.status).to eq(200) expect(json_response['labels']).to include 'label' @@ -1378,40 +1385,40 @@ describe API::Issues do context 'confidential issues' do it "returns 403 for non project members" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member), - title: 'updated title' + params: { title: 'updated title' } expect(response).to have_gitlab_http_status(403) end it "returns 403 for project members with guest role" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest), - title: 'updated title' + params: { title: 'updated title' } expect(response).to have_gitlab_http_status(403) end it "updates a confidential issue for project members" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), - title: 'updated title' + params: { title: 'updated title' } expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end it "updates a confidential issue for author" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author), - title: 'updated title' + params: { title: 'updated title' } expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end it "updates a confidential issue for admin" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin), - title: 'updated title' + params: { title: 'updated title' } expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end it 'sets an issue to confidential' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - confidential: true + params: { confidential: true } expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_truthy @@ -1419,7 +1426,7 @@ describe API::Issues do it 'makes a confidential issue public' do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), - confidential: false + params: { confidential: false } expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_falsy @@ -1427,7 +1434,7 @@ describe API::Issues do it 'does not update a confidential issue with wrong confidential flag' do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), - confidential: 'foo' + params: { confidential: 'foo' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') @@ -1448,7 +1455,7 @@ describe API::Issues do allow_any_instance_of(SpamService).to receive_messages(check_for_spam?: true) allow_any_instance_of(AkismetService).to receive_messages(spam?: true) - put api("/projects/#{project.id}/issues/#{issue.iid}", user), params + put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: params expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) @@ -1466,7 +1473,7 @@ describe API::Issues do context 'support for deprecated assignee_id' do it 'removes assignee' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - assignee_id: 0 + params: { assignee_id: 0 } expect(response).to have_gitlab_http_status(200) @@ -1475,7 +1482,7 @@ describe API::Issues do it 'updates an issue with new assignee' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - assignee_id: user2.id + params: { assignee_id: user2.id } expect(response).to have_gitlab_http_status(200) @@ -1485,7 +1492,7 @@ describe API::Issues do it 'removes assignee' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - assignee_ids: [0] + params: { assignee_ids: [0] } expect(response).to have_gitlab_http_status(200) @@ -1494,7 +1501,7 @@ describe API::Issues do it 'updates an issue with new assignee' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - assignee_ids: [user2.id] + params: { assignee_ids: [user2.id] } expect(response).to have_gitlab_http_status(200) @@ -1504,7 +1511,7 @@ describe API::Issues do context 'single assignee restrictions' do it 'updates an issue with several assignees but only one has been applied' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - assignee_ids: [user2.id, guest.id] + params: { assignee_ids: [user2.id, guest.id] } expect(response).to have_gitlab_http_status(200) @@ -1519,14 +1526,14 @@ describe API::Issues do it 'does not update labels if not present' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - title: 'updated title' + params: { title: 'updated title' } expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to eq([label.title]) end it 'removes all labels and touches the record' do Timecop.travel(1.minute.from_now) do - put api("/projects/#{project.id}/issues/#{issue.iid}", user), labels: '' + put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { labels: '' } end expect(response).to have_gitlab_http_status(200) @@ -1537,7 +1544,7 @@ describe API::Issues do it 'updates labels and touches the record' do Timecop.travel(1.minute.from_now) do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - labels: 'foo,bar' + params: { labels: 'foo,bar' } end expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'foo' @@ -1547,7 +1554,7 @@ describe API::Issues do it 'allows special label names' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - labels: 'label:foo, label-bar,label_bar,label/bar,label?bar,label&bar,?,&' + params: { labels: 'label:foo, label-bar,label_bar,label/bar,label?bar,label&bar,?,&' } expect(response.status).to eq(200) expect(json_response['labels']).to include 'label:foo' expect(json_response['labels']).to include 'label-bar' @@ -1561,7 +1568,7 @@ describe API::Issues do it 'returns 400 if title is too long' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - title: 'g' * 256 + params: { title: 'g' * 256 } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' @@ -1572,7 +1579,7 @@ describe API::Issues do describe "PUT /projects/:id/issues/:issue_iid to update state and label" do it "updates a project issue" do put api("/projects/#{project.id}/issues/#{issue.iid}", user), - labels: 'label2', state_event: "close" + params: { labels: 'label2', state_event: "close" } expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label2' @@ -1580,7 +1587,7 @@ describe API::Issues do end it 'reopens a project isssue' do - put api("/projects/#{project.id}/issues/#{closed_issue.iid}", user), state_event: 'reopen' + put api("/projects/#{project.id}/issues/#{closed_issue.iid}", user), params: { state_event: 'reopen' } expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq 'opened' @@ -1590,7 +1597,7 @@ describe API::Issues do it 'accepts the update date to be set' do update_time = 2.weeks.ago put api("/projects/#{project.id}/issues/#{issue.iid}", user), - labels: 'label3', state_event: 'close', updated_at: update_time + params: { labels: 'label3', state_event: 'close', updated_at: update_time } expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label3' @@ -1603,7 +1610,7 @@ describe API::Issues do it 'creates a new project issue' do due_date = 2.weeks.from_now.strftime('%Y-%m-%d') - put api("/projects/#{project.id}/issues/#{issue.iid}", user), due_date: due_date + put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { due_date: due_date } expect(response).to have_gitlab_http_status(200) expect(json_response['due_date']).to eq(due_date) @@ -1657,7 +1664,7 @@ describe API::Issues do it 'moves an issue' do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), - to_project_id: target_project.id + params: { to_project_id: target_project.id } expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project.id) @@ -1666,7 +1673,7 @@ describe API::Issues do context 'when source and target projects are the same' do it 'returns 400 when trying to move an issue' do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), - to_project_id: project.id + params: { to_project_id: project.id } expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue to project it originates from!') @@ -1676,7 +1683,7 @@ describe API::Issues do context 'when the user does not have the permission to move issues' do it 'returns 400 when trying to move an issue' do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), - to_project_id: target_project2.id + params: { to_project_id: target_project2.id } expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue due to insufficient permissions!') @@ -1685,7 +1692,7 @@ describe API::Issues do it 'moves the issue to another namespace if I am admin' do post api("/projects/#{project.id}/issues/#{issue.iid}/move", admin), - to_project_id: target_project2.id + params: { to_project_id: target_project2.id } expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project2.id) @@ -1694,7 +1701,7 @@ describe API::Issues do context 'when using the issue ID instead of iid' do it 'returns 404 when trying to move an issue' do post api("/projects/#{project.id}/issues/#{issue.id}/move", user), - to_project_id: target_project.id + params: { to_project_id: target_project.id } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Issue Not Found') @@ -1704,7 +1711,7 @@ describe API::Issues do context 'when issue does not exist' do it 'returns 404 when trying to move an issue' do post api("/projects/#{project.id}/issues/123/move", user), - to_project_id: target_project.id + params: { to_project_id: target_project.id } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Issue Not Found') @@ -1714,7 +1721,7 @@ describe API::Issues do context 'when source project does not exist' do it 'returns 404 when trying to move an issue' do post api("/projects/0/issues/#{issue.iid}/move", user), - to_project_id: target_project.id + params: { to_project_id: target_project.id } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') @@ -1724,7 +1731,7 @@ describe API::Issues do context 'when target project does not exist' do it 'returns 404 when trying to move an issue' do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), - to_project_id: 0 + params: { to_project_id: 0 } expect(response).to have_gitlab_http_status(404) end diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index cd4e480ca64..73131dba542 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -58,7 +58,7 @@ describe API::Jobs do before do |example| unless example.metadata[:skip_before_request] - get api("/projects/#{project.id}/jobs", api_user), query + get api("/projects/#{project.id}/jobs", api_user), params: query end end @@ -150,7 +150,7 @@ describe API::Jobs do end def go - get api("/projects/#{project.id}/jobs", api_user), query + get api("/projects/#{project.id}/jobs", api_user), params: query end end @@ -160,7 +160,7 @@ describe API::Jobs do before do |example| unless example.metadata[:skip_before_request] job - get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), query + get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query end end @@ -229,13 +229,13 @@ describe API::Jobs do it 'avoids N+1 queries' do control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do - get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), query + get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query end.count 3.times { create(:ci_build, :trace_artifact, :artifacts, :test_reports, pipeline: pipeline) } expect do - get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), query + get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query end.not_to exceed_all_query_limit(control_count) end end @@ -479,7 +479,7 @@ describe API::Jobs do end def get_for_ref(ref = pipeline.ref, job_name = job.name) - get api("/projects/#{project.id}/jobs/artifacts/#{ref}/download", api_user), job: job_name + get api("/projects/#{project.id}/jobs/artifacts/#{ref}/download", api_user), params: { job: job_name } end context 'when not logged in' do @@ -712,7 +712,7 @@ describe API::Jobs do end def get_artifact_file(artifact_path, ref = pipeline.ref, job_name = job.name) - get api("/projects/#{project.id}/jobs/artifacts/#{ref}/raw/#{artifact_path}", api_user), job: job_name + get api("/projects/#{project.id}/jobs/artifacts/#{ref}/raw/#{artifact_path}", api_user), params: { job: job_name } end end diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index b8a4a04a7e4..49eea2e362b 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -70,10 +70,12 @@ describe API::Labels do describe 'POST /projects/:id/labels' do it 'returns created label when all params' do post api("/projects/#{project.id}/labels", user), - name: 'Foo', - color: '#FFAABB', - description: 'test', - priority: 2 + params: { + name: 'Foo', + color: '#FFAABB', + description: 'test', + priority: 2 + } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('Foo') @@ -84,8 +86,10 @@ describe API::Labels do it 'returns created label when only required params' do post api("/projects/#{project.id}/labels", user), - name: 'Foo & Bar', - color: '#FFAABB' + params: { + name: 'Foo & Bar', + color: '#FFAABB' + } expect(response.status).to eq(201) expect(json_response['name']).to eq('Foo & Bar') @@ -96,9 +100,11 @@ describe API::Labels do it 'creates a prioritized label' do post api("/projects/#{project.id}/labels", user), - name: 'Foo & Bar', - color: '#FFAABB', - priority: 3 + params: { + name: 'Foo & Bar', + color: '#FFAABB', + priority: 3 + } expect(response.status).to eq(201) expect(json_response['name']).to eq('Foo & Bar') @@ -108,35 +114,41 @@ describe API::Labels do end it 'returns a 400 bad request if name not given' do - post api("/projects/#{project.id}/labels", user), color: '#FFAABB' + post api("/projects/#{project.id}/labels", user), params: { color: '#FFAABB' } expect(response).to have_gitlab_http_status(400) end it 'returns a 400 bad request if color not given' do - post api("/projects/#{project.id}/labels", user), name: 'Foobar' + post api("/projects/#{project.id}/labels", user), params: { name: 'Foobar' } expect(response).to have_gitlab_http_status(400) end it 'returns 400 for invalid color' do post api("/projects/#{project.id}/labels", user), - name: 'Foo', - color: '#FFAA' + params: { + name: 'Foo', + color: '#FFAA' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end it 'returns 400 for too long color code' do post api("/projects/#{project.id}/labels", user), - name: 'Foo', - color: '#FFAAFFFF' + params: { + name: 'Foo', + color: '#FFAAFFFF' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end it 'returns 400 for invalid name' do post api("/projects/#{project.id}/labels", user), - name: ',', - color: '#FFAABB' + params: { + name: ',', + color: '#FFAABB' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq(['is invalid']) end @@ -147,8 +159,10 @@ describe API::Labels do project.update(group: group) post api("/projects/#{project.id}/labels", user), - name: group_label.name, - color: '#FFAABB' + params: { + name: group_label.name, + color: '#FFAABB' + } expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Label already exists') @@ -156,17 +170,21 @@ describe API::Labels do it 'returns 400 for invalid priority' do post api("/projects/#{project.id}/labels", user), - name: 'Foo', - color: '#FFAAFFFF', - priority: 'foo' + params: { + name: 'Foo', + color: '#FFAAFFFF', + priority: 'foo' + } expect(response).to have_gitlab_http_status(400) end it 'returns 409 if label already exists in project' do post api("/projects/#{project.id}/labels", user), - name: 'label1', - color: '#FFAABB' + params: { + name: 'label1', + color: '#FFAABB' + } expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Label already exists') end @@ -174,13 +192,13 @@ describe API::Labels do describe 'DELETE /projects/:id/labels' do it 'returns 204 for existing label' do - delete api("/projects/#{project.id}/labels", user), name: 'label1' + delete api("/projects/#{project.id}/labels", user), params: { name: 'label1' } expect(response).to have_gitlab_http_status(204) end it 'returns 404 for non existing label' do - delete api("/projects/#{project.id}/labels", user), name: 'label2' + delete api("/projects/#{project.id}/labels", user), params: { name: 'label2' } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Label Not Found') end @@ -199,10 +217,12 @@ describe API::Labels do describe 'PUT /projects/:id/labels' do it 'returns 200 if name and colors and description are changed' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - new_name: 'New Label', - color: '#FFFFFF', - description: 'test' + params: { + name: 'label1', + new_name: 'New Label', + color: '#FFFFFF', + description: 'test' + } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('New Label') expect(json_response['color']).to eq('#FFFFFF') @@ -211,8 +231,10 @@ describe API::Labels do it 'returns 200 if name is changed' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - new_name: 'New Label' + params: { + name: 'label1', + new_name: 'New Label' + } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('New Label') expect(json_response['color']).to eq(label1.color) @@ -220,8 +242,10 @@ describe API::Labels do it 'returns 200 if colors is changed' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - color: '#FFFFFF' + params: { + name: 'label1', + color: '#FFFFFF' + } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(label1.name) expect(json_response['color']).to eq('#FFFFFF') @@ -229,8 +253,10 @@ describe API::Labels do it 'returns 200 if description is changed' do put api("/projects/#{project.id}/labels", user), - name: 'bug', - description: 'test' + params: { + name: 'bug', + description: 'test' + } expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(priority_label.name) @@ -240,8 +266,10 @@ describe API::Labels do it 'returns 200 if priority is changed' do put api("/projects/#{project.id}/labels", user), - name: 'bug', - priority: 10 + params: { + name: 'bug', + priority: 10 + } expect(response.status).to eq(200) expect(json_response['name']).to eq(priority_label.name) @@ -250,8 +278,10 @@ describe API::Labels do it 'returns 200 if a priority is added' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - priority: 3 + params: { + name: 'label1', + priority: 3 + } expect(response.status).to eq(200) expect(json_response['name']).to eq(label1.name) @@ -260,8 +290,10 @@ describe API::Labels do it 'returns 200 if the priority is removed' do put api("/projects/#{project.id}/labels", user), - name: priority_label.name, - priority: nil + params: { + name: priority_label.name, + priority: nil + } expect(response.status).to eq(200) expect(json_response['name']).to eq(priority_label.name) @@ -270,19 +302,21 @@ describe API::Labels do it 'returns 404 if label does not exist' do put api("/projects/#{project.id}/labels", user), - name: 'label2', - new_name: 'label3' + params: { + name: 'label2', + new_name: 'label3' + } expect(response).to have_gitlab_http_status(404) end it 'returns 400 if no label name given' do - put api("/projects/#{project.id}/labels", user), new_name: 'label2' + put api("/projects/#{project.id}/labels", user), params: { new_name: 'label2' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end it 'returns 400 if no new parameters given' do - put api("/projects/#{project.id}/labels", user), name: 'label1' + put api("/projects/#{project.id}/labels", user), params: { name: 'label1' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('new_name, color, description, priority are missing, '\ 'at least one parameter must be provided') @@ -290,33 +324,41 @@ describe API::Labels do it 'returns 400 for invalid name' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - new_name: ',', - color: '#FFFFFF' + params: { + name: 'label1', + new_name: ',', + color: '#FFFFFF' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq(['is invalid']) end it 'returns 400 when color code is too short' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - color: '#FF' + params: { + name: 'label1', + color: '#FF' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end it 'returns 400 for too long color code' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - color: '#FFAAFFFF' + params: { + name: 'label1', + color: '#FFAAFFFF' + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end it 'returns 400 for invalid priority' do put api("/projects/#{project.id}/labels", user), - name: 'label1', - priority: 'foo' + params: { + name: 'label1', + priority: 'foo' + } expect(response).to have_gitlab_http_status(400) end diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb index e3065840e6f..f52cdf1c459 100644 --- a/spec/requests/api/lint_spec.rb +++ b/spec/requests/api/lint_spec.rb @@ -8,7 +8,7 @@ describe API::Lint do end it 'passes validation' do - post api('/ci/lint'), { content: yaml_content } + post api('/ci/lint'), params: { content: yaml_content } expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Hash @@ -19,7 +19,7 @@ describe API::Lint do context 'with an invalid .gitlab_ci.yml' do it 'responds with errors about invalid syntax' do - post api('/ci/lint'), { content: 'invalid content' } + post api('/ci/lint'), params: { content: 'invalid content' } expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('invalid') @@ -27,7 +27,7 @@ describe API::Lint do end it "responds with errors about invalid configuration" do - post api('/ci/lint'), { content: '{ image: "ruby:2.1", services: ["postgres"] }' } + post api('/ci/lint'), params: { content: '{ image: "ruby:2.1", services: ["postgres"] }' } expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('invalid') diff --git a/spec/requests/api/markdown_spec.rb b/spec/requests/api/markdown_spec.rb index e369c1435f0..e82ef002d32 100644 --- a/spec/requests/api/markdown_spec.rb +++ b/spec/requests/api/markdown_spec.rb @@ -7,7 +7,7 @@ describe API::Markdown do let(:user) {} # No-op. It gets overwritten in the contexts below. before do - post api("/markdown", user), params + post api("/markdown", user), params: params end shared_examples "rendered markdown text without GFM" do diff --git a/spec/requests/api/members_spec.rb b/spec/requests/api/members_spec.rb index bb32d581176..79edbb301f2 100644 --- a/spec/requests/api/members_spec.rb +++ b/spec/requests/api/members_spec.rb @@ -78,7 +78,7 @@ describe API::Members do end it 'finds members with query string' do - get api(members_url, developer), query: maintainer.username + get api(members_url, developer), params: { query: maintainer.username } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -88,7 +88,7 @@ describe API::Members do end it 'finds all members with no query specified' do - get api(members_url, developer), query: '' + get api(members_url, developer), params: { query: '' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -178,7 +178,7 @@ describe API::Members do it_behaves_like 'a 404 response when source is private' do let(:route) do post api("/#{source_type.pluralize}/#{source.id}/members", stranger), - user_id: access_requester.id, access_level: Member::MAINTAINER + params: { user_id: access_requester.id, access_level: Member::MAINTAINER } end end @@ -188,7 +188,7 @@ describe API::Members do it 'returns 403' do user = public_send(type) post api("/#{source_type.pluralize}/#{source.id}/members", user), - user_id: access_requester.id, access_level: Member::MAINTAINER + params: { user_id: access_requester.id, access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(403) end @@ -201,7 +201,7 @@ describe API::Members do it 'transforms the requester into a proper member' do expect do post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), - user_id: access_requester.id, access_level: Member::MAINTAINER + params: { user_id: access_requester.id, access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) @@ -214,7 +214,7 @@ describe API::Members do it 'creates a new member' do expect do post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), - user_id: stranger.id, access_level: Member::DEVELOPER, expires_at: '2016-08-05' + params: { user_id: stranger.id, access_level: Member::DEVELOPER, expires_at: '2016-08-05' } expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) @@ -233,7 +233,7 @@ describe API::Members do parent.add_developer(stranger) post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), - user_id: stranger.id, access_level: Member::REPORTER + params: { user_id: stranger.id, access_level: Member::REPORTER } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['access_level']).to eq(["should be higher than Developer inherited membership from group #{parent.name}"]) @@ -247,7 +247,7 @@ describe API::Members do parent.add_developer(stranger) post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), - user_id: stranger.id, access_level: Member::MAINTAINER + params: { user_id: stranger.id, access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(stranger.id) @@ -257,14 +257,14 @@ describe API::Members do it "returns 409 if member already exists" do post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), - user_id: maintainer.id, access_level: Member::MAINTAINER + params: { user_id: maintainer.id, access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(409) end it 'returns 404 when the user_id is not valid' do post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), - user_id: 0, access_level: Member::MAINTAINER + params: { user_id: 0, access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') @@ -272,21 +272,21 @@ describe API::Members do it 'returns 400 when user_id is not given' do post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), - access_level: Member::MAINTAINER + params: { access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access_level is not given' do post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), - user_id: stranger.id + params: { user_id: stranger.id } expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access_level is not valid' do post api("/#{source_type.pluralize}/#{source.id}/members", maintainer), - user_id: stranger.id, access_level: 1234 + params: { user_id: stranger.id, access_level: 1234 } expect(response).to have_gitlab_http_status(400) end @@ -298,7 +298,7 @@ describe API::Members do it_behaves_like 'a 404 response when source is private' do let(:route) do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", stranger), - access_level: Member::MAINTAINER + params: { access_level: Member::MAINTAINER } end end @@ -308,7 +308,7 @@ describe API::Members do it 'returns 403' do user = public_send(type) put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user), - access_level: Member::MAINTAINER + params: { access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(403) end @@ -319,7 +319,7 @@ describe API::Members do context 'when authenticated as a maintainer/owner' do it 'updates the member' do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", maintainer), - access_level: Member::MAINTAINER, expires_at: '2016-08-05' + params: { access_level: Member::MAINTAINER, expires_at: '2016-08-05' } expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(developer.id) @@ -330,7 +330,7 @@ describe API::Members do it 'returns 409 if member does not exist' do put api("/#{source_type.pluralize}/#{source.id}/members/123", maintainer), - access_level: Member::MAINTAINER + params: { access_level: Member::MAINTAINER } expect(response).to have_gitlab_http_status(404) end @@ -343,7 +343,7 @@ describe API::Members do it 'returns 400 when access level is not valid' do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", maintainer), - access_level: 1234 + params: { access_level: 1234 } expect(response).to have_gitlab_http_status(400) end @@ -457,7 +457,7 @@ describe API::Members do it 'returns 403' do expect do post api("/projects/#{project.id}/members", maintainer), - user_id: stranger.id, access_level: Member::OWNER + params: { user_id: stranger.id, access_level: Member::OWNER } expect(response).to have_gitlab_http_status(400) end.to change { project.members.count }.by(0) diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 27bcde77860..dd40f3d1561 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -45,7 +45,7 @@ describe API::MergeRequests do describe 'GET /merge_requests' do context 'when unauthenticated' do it 'returns an array of all merge requests' do - get api('/merge_requests', user), scope: 'all' + get api('/merge_requests', user), params: { scope: 'all' } expect_paginated_array_response end @@ -57,19 +57,19 @@ describe API::MergeRequests do end it "returns authentication error when scope is assigned-to-me" do - get api("/merge_requests"), scope: 'assigned-to-me' + get api("/merge_requests"), params: { scope: 'assigned-to-me' } expect(response).to have_gitlab_http_status(401) end it "returns authentication error when scope is assigned_to_me" do - get api("/merge_requests"), scope: 'assigned_to_me' + get api("/merge_requests"), params: { scope: 'assigned_to_me' } expect(response).to have_gitlab_http_status(401) end it "returns authentication error when scope is created-by-me" do - get api("/merge_requests"), scope: 'created-by-me' + get api("/merge_requests"), params: { scope: 'created-by-me' } expect(response).to have_gitlab_http_status(401) end @@ -81,7 +81,7 @@ describe API::MergeRequests do let(:user2) { create(:user) } it 'returns an array of all merge requests except unauthorized ones' do - get api('/merge_requests', user), scope: :all + get api('/merge_requests', user), params: { scope: :all } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -91,7 +91,7 @@ describe API::MergeRequests do end it "returns an array of no merge_requests when wip=yes" do - get api("/merge_requests", user), wip: 'yes' + get api("/merge_requests", user), params: { wip: 'yes' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -100,7 +100,7 @@ describe API::MergeRequests do end it "returns an array of no merge_requests when wip=no" do - get api("/merge_requests", user), wip: 'no' + get api("/merge_requests", user), params: { wip: 'no' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -113,7 +113,7 @@ describe API::MergeRequests do private_project = create(:project, :private) merge_request3 = create(:merge_request, :simple, source_project: private_project, target_project: private_project, source_branch: 'other-branch') - get api('/merge_requests', user), scope: :all + get api('/merge_requests', user), params: { scope: :all } expect_response_contain_exactly(merge_request2, merge_request_merged, merge_request_closed, merge_request, merge_request_locked) expect(json_response.map { |mr| mr['id'] }).not_to include(merge_request3.id) @@ -130,7 +130,7 @@ describe API::MergeRequests do it 'returns an array of merge requests authored by the given user' do merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch') - get api('/merge_requests', user), author_id: user2.id, scope: :all + get api('/merge_requests', user), params: { author_id: user2.id, scope: :all } expect_response_ordered_exactly(merge_request3) end @@ -138,7 +138,7 @@ describe API::MergeRequests do it 'returns an array of merge requests assigned to the given user' do merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: 'other-branch') - get api('/merge_requests', user), assignee_id: user2.id, scope: :all + get api('/merge_requests', user), params: { assignee_id: user2.id, scope: :all } expect_response_ordered_exactly(merge_request3) end @@ -146,7 +146,7 @@ describe API::MergeRequests do it 'returns an array of merge requests with no assignee' do merge_request3 = create(:merge_request, :simple, author: user, source_project: project2, target_project: project2, source_branch: 'other-branch') - get api('/merge_requests', user), assignee_id: 'None', scope: :all + get api('/merge_requests', user), params: { assignee_id: 'None', scope: :all } expect_response_ordered_exactly(merge_request3) end @@ -155,7 +155,7 @@ describe API::MergeRequests do # This MR with no assignee should not be returned create(:merge_request, :simple, author: user, source_project: project2, target_project: project2, source_branch: 'other-branch') - get api('/merge_requests', user), assignee_id: 'Any', scope: :all + get api('/merge_requests', user), params: { assignee_id: 'Any', scope: :all } expect_response_contain_exactly(merge_request, merge_request2, merge_request_closed, merge_request_merged, merge_request_locked) end @@ -163,7 +163,7 @@ describe API::MergeRequests do it 'returns an array of merge requests assigned to me' do merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: 'other-branch') - get api('/merge_requests', user2), scope: 'assigned_to_me' + get api('/merge_requests', user2), params: { scope: 'assigned_to_me' } expect_response_ordered_exactly(merge_request3) end @@ -171,7 +171,7 @@ describe API::MergeRequests do it 'returns an array of merge requests assigned to me (kebab-case)' do merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: 'other-branch') - get api('/merge_requests', user2), scope: 'assigned-to-me' + get api('/merge_requests', user2), params: { scope: 'assigned-to-me' } expect_response_ordered_exactly(merge_request3) end @@ -179,7 +179,7 @@ describe API::MergeRequests do it 'returns an array of merge requests created by me' do merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch') - get api('/merge_requests', user2), scope: 'created_by_me' + get api('/merge_requests', user2), params: { scope: 'created_by_me' } expect_response_ordered_exactly(merge_request3) end @@ -187,7 +187,7 @@ describe API::MergeRequests do it 'returns an array of merge requests created by me (kebab-case)' do merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch') - get api('/merge_requests', user2), scope: 'created-by-me' + get api('/merge_requests', user2), params: { scope: 'created-by-me' } expect_response_ordered_exactly(merge_request3) end @@ -196,14 +196,14 @@ describe API::MergeRequests do merge_request3 = create(:merge_request, :simple, author: user, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch') award_emoji = create(:award_emoji, awardable: merge_request3, user: user2, name: 'star') - get api('/merge_requests', user2), my_reaction_emoji: award_emoji.name, scope: 'all' + get api('/merge_requests', user2), params: { my_reaction_emoji: award_emoji.name, scope: 'all' } expect_response_ordered_exactly(merge_request3) end context 'source_branch param' do it 'returns merge requests with the given source branch' do - get api('/merge_requests', user), source_branch: merge_request_closed.source_branch, state: 'all' + get api('/merge_requests', user), params: { source_branch: merge_request_closed.source_branch, state: 'all' } expect_response_contain_exactly(merge_request_closed, merge_request_merged, merge_request_locked) end @@ -211,7 +211,7 @@ describe API::MergeRequests do context 'target_branch param' do it 'returns merge requests with the given target branch' do - get api('/merge_requests', user), target_branch: merge_request_closed.target_branch, state: 'all' + get api('/merge_requests', user), params: { target_branch: merge_request_closed.target_branch, state: 'all' } expect_response_contain_exactly(merge_request_closed, merge_request_merged, merge_request_locked) end @@ -255,13 +255,13 @@ describe API::MergeRequests do end it 'returns merge requests matching given search string for title' do - get api("/merge_requests", user), search: merge_request.title + get api("/merge_requests", user), params: { search: merge_request.title } expect_response_ordered_exactly(merge_request) end it 'returns merge requests for project matching given search string for description' do - get api("/merge_requests", user), project_id: project.id, search: merge_request.description + get api("/merge_requests", user), params: { project_id: project.id, search: merge_request.description } expect_response_ordered_exactly(merge_request) end @@ -269,7 +269,7 @@ describe API::MergeRequests do context 'state param' do it 'returns merge requests with the given state' do - get api('/merge_requests', user), state: 'locked' + get api('/merge_requests', user), params: { state: 'locked' } expect_response_contain_exactly(merge_request_locked) end @@ -291,7 +291,7 @@ describe API::MergeRequests do end it "returns an array of no merge_requests when wip=yes" do - get api("/projects/#{project.id}/merge_requests", user), wip: 'yes' + get api("/projects/#{project.id}/merge_requests", user), params: { wip: 'yes' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -300,7 +300,7 @@ describe API::MergeRequests do end it 'returns merge_request by "iids" array' do - get api(endpoint_path, user), iids: [merge_request.iid, merge_request_closed.iid] + get api(endpoint_path, user), params: { iids: [merge_request.iid, merge_request_closed.iid] } expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array @@ -364,7 +364,7 @@ describe API::MergeRequests do end it 'exposes description and title html when render_html is true' do - get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), render_html: true + get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { render_html: true } expect(response).to have_gitlab_http_status(200) @@ -372,7 +372,7 @@ describe API::MergeRequests do end it 'exposes rebase_in_progress when include_rebase_in_progress is true' do - get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), include_rebase_in_progress: true + get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { include_rebase_in_progress: true } expect(response).to have_gitlab_http_status(200) @@ -421,7 +421,7 @@ describe API::MergeRequests do it 'returns the commits behind the target branch when include_diverged_commits_count is present' do allow_any_instance_of(merge_request.class).to receive(:diverged_commits_count).and_return(1) - get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), include_diverged_commits_count: true + get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { include_diverged_commits_count: true } expect(response).to have_gitlab_http_status(200) expect(json_response['diverged_commits_count']).to eq(1) @@ -587,13 +587,15 @@ describe API::MergeRequests do context 'between branches projects' do it "returns merge_request" do post api("/projects/#{project.id}/merge_requests", user), - title: 'Test merge_request', - source_branch: 'feature_conflict', - target_branch: 'master', - author: user, - labels: 'label, label2', - milestone_id: milestone.id, - squash: true + params: { + title: 'Test merge_request', + source_branch: 'feature_conflict', + target_branch: 'master', + author: user, + labels: 'label, label2', + milestone_id: milestone.id, + squash: true + } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('Test merge_request') @@ -605,35 +607,37 @@ describe API::MergeRequests do it "returns 422 when source_branch equals target_branch" do post api("/projects/#{project.id}/merge_requests", user), - title: "Test merge_request", source_branch: "master", target_branch: "master", author: user + params: { title: "Test merge_request", source_branch: "master", target_branch: "master", author: user } expect(response).to have_gitlab_http_status(422) end it "returns 400 when source_branch is missing" do post api("/projects/#{project.id}/merge_requests", user), - title: "Test merge_request", target_branch: "master", author: user + params: { title: "Test merge_request", target_branch: "master", author: user } expect(response).to have_gitlab_http_status(400) end it "returns 400 when target_branch is missing" do post api("/projects/#{project.id}/merge_requests", user), - title: "Test merge_request", source_branch: "markdown", author: user + params: { title: "Test merge_request", source_branch: "markdown", author: user } expect(response).to have_gitlab_http_status(400) end it "returns 400 when title is missing" do post api("/projects/#{project.id}/merge_requests", user), - target_branch: 'master', source_branch: 'markdown' + params: { target_branch: 'master', source_branch: 'markdown' } expect(response).to have_gitlab_http_status(400) end it 'allows special label names' do post api("/projects/#{project.id}/merge_requests", user), - title: 'Test merge_request', - source_branch: 'markdown', - target_branch: 'master', - author: user, - labels: 'label, label?, label&foo, ?, &' + params: { + title: 'Test merge_request', + source_branch: 'markdown', + target_branch: 'master', + author: user, + labels: 'label, label?, label&foo, ?, &' + } expect(response).to have_gitlab_http_status(201) expect(json_response['labels']).to include 'label' expect(json_response['labels']).to include 'label?' @@ -645,20 +649,24 @@ describe API::MergeRequests do context 'with existing MR' do before do post api("/projects/#{project.id}/merge_requests", user), - title: 'Test merge_request', - source_branch: 'feature_conflict', - target_branch: 'master', - author: user + params: { + title: 'Test merge_request', + source_branch: 'feature_conflict', + target_branch: 'master', + author: user + } @mr = MergeRequest.all.last end it 'returns 409 when MR already exists for source/target' do expect do post api("/projects/#{project.id}/merge_requests", user), - title: 'New test merge_request', - source_branch: 'feature_conflict', - target_branch: 'master', - author: user + params: { + title: 'New test merge_request', + source_branch: 'feature_conflict', + target_branch: 'master', + author: user + } end.to change { MergeRequest.count }.by(0) expect(response).to have_gitlab_http_status(409) end @@ -673,13 +681,13 @@ describe API::MergeRequests do end it 'sets force_remove_source_branch to false' do - post api("/projects/#{project.id}/merge_requests", user), params.merge(remove_source_branch: false) + post api("/projects/#{project.id}/merge_requests", user), params: params.merge(remove_source_branch: false) expect(json_response['force_remove_source_branch']).to be_falsy end it 'sets force_remove_source_branch to true' do - post api("/projects/#{project.id}/merge_requests", user), params.merge(remove_source_branch: true) + post api("/projects/#{project.id}/merge_requests", user), params: params.merge(remove_source_branch: true) expect(json_response['force_remove_source_branch']).to be_truthy end @@ -698,8 +706,7 @@ describe API::MergeRequests do it "returns merge_request" do post api("/projects/#{forked_project.id}/merge_requests", user2), - title: 'Test merge_request', source_branch: "feature_conflict", target_branch: "master", - author: user2, target_project_id: project.id, description: 'Test description for Test merge_request' + params: { title: 'Test merge_request', source_branch: "feature_conflict", target_branch: "master", author: user2, target_project_id: project.id, description: 'Test description for Test merge_request' } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('Test merge_request') expect(json_response['description']).to eq('Test description for Test merge_request') @@ -710,7 +717,7 @@ describe API::MergeRequests do expect(forked_project.forked?).to be_truthy expect(forked_project.forked_from_project).to eq(project) post api("/projects/#{forked_project.id}/merge_requests", user2), - title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id + params: { title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id } expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('Test merge_request') end @@ -719,37 +726,38 @@ describe API::MergeRequests do project.project_feature.update(merge_requests_access_level: 0) post api("/projects/#{forked_project.id}/merge_requests", user2), - title: 'Test', - target_branch: 'master', - source_branch: 'markdown', - author: user2, - target_project_id: project.id + params: { + title: 'Test', + target_branch: 'master', + source_branch: 'markdown', + author: user2, + target_project_id: project.id + } expect(response).to have_gitlab_http_status(403) end it "returns 400 when source_branch is missing" do post api("/projects/#{forked_project.id}/merge_requests", user2), - title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id + params: { title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id } expect(response).to have_gitlab_http_status(400) end it "returns 400 when target_branch is missing" do post api("/projects/#{forked_project.id}/merge_requests", user2), - title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id + params: { title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id } expect(response).to have_gitlab_http_status(400) end it "returns 400 when title is missing" do post api("/projects/#{forked_project.id}/merge_requests", user2), - target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: project.id + params: { target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: project.id } expect(response).to have_gitlab_http_status(400) end it 'allows setting `allow_collaboration`' do post api("/projects/#{forked_project.id}/merge_requests", user2), - title: 'Test merge_request', source_branch: "feature_conflict", target_branch: "master", - author: user2, target_project_id: project.id, allow_collaboration: true + params: { title: 'Test merge_request', source_branch: "feature_conflict", target_branch: "master", author: user2, target_project_id: project.id, allow_collaboration: true } expect(response).to have_gitlab_http_status(201) expect(json_response['allow_collaboration']).to be_truthy expect(json_response['allow_maintainer_to_push']).to be_truthy @@ -767,13 +775,13 @@ describe API::MergeRequests do it 'returns 422 if targeting a different fork' do unrelated_project.add_developer(user2) - post api("/projects/#{forked_project.id}/merge_requests", user2), params + post api("/projects/#{forked_project.id}/merge_requests", user2), params: params expect(response).to have_gitlab_http_status(422) end it 'returns 403 if targeting a different fork which user can not access' do - post api("/projects/#{forked_project.id}/merge_requests", user2), params + post api("/projects/#{forked_project.id}/merge_requests", user2), params: params expect(response).to have_gitlab_http_status(403) end @@ -781,7 +789,7 @@ describe API::MergeRequests do it "returns 201 when target_branch is specified and for the same project" do post api("/projects/#{forked_project.id}/merge_requests", user2), - title: 'Test merge_request', target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: forked_project.id + params: { title: 'Test merge_request', target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: forked_project.id } expect(response).to have_gitlab_http_status(201) end end @@ -877,21 +885,21 @@ describe API::MergeRequests do end it "returns 409 if the SHA parameter doesn't match" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), sha: merge_request.diff_head_sha.reverse + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { sha: merge_request.diff_head_sha.reverse } expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to start_with('SHA does not match HEAD of source branch') end it "succeeds if the SHA parameter matches" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), sha: merge_request.diff_head_sha + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { sha: merge_request.diff_head_sha } expect(response).to have_gitlab_http_status(200) end it "updates the MR's squash attribute" do expect do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), squash: true + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { squash: true } end.to change { merge_request.reload.squash } expect(response).to have_gitlab_http_status(200) @@ -901,7 +909,7 @@ describe API::MergeRequests do allow_any_instance_of(MergeRequest).to receive(:head_pipeline).and_return(pipeline) allow(pipeline).to receive(:active?).and_return(true) - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), merge_when_pipeline_succeeds: true + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { merge_when_pipeline_succeeds: true } expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('Test') @@ -913,7 +921,7 @@ describe API::MergeRequests do allow(pipeline).to receive(:active?).and_return(true) project.update_attribute(:only_allow_merge_if_pipeline_succeeds, true) - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), merge_when_pipeline_succeeds: true + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { merge_when_pipeline_succeeds: true } expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('Test') @@ -936,7 +944,7 @@ describe API::MergeRequests do describe "PUT /projects/:id/merge_requests/:merge_request_iid" do context "to close a MR" do it "returns merge_request" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), state_event: "close" + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: "close" } expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq('closed') @@ -944,38 +952,38 @@ describe API::MergeRequests do end it "updates title and returns merge_request" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), title: "New title" + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { title: "New title" } expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('New title') end it "updates description and returns merge_request" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), description: "New description" + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { description: "New description" } expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq('New description') end it "updates milestone_id and returns merge_request" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), milestone_id: milestone.id + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { milestone_id: milestone.id } expect(response).to have_gitlab_http_status(200) expect(json_response['milestone']['id']).to eq(milestone.id) end it "updates squash and returns merge_request" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), squash: true + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { squash: true } expect(response).to have_gitlab_http_status(200) expect(json_response['squash']).to be_truthy end it "returns merge_request with renamed target_branch" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), target_branch: "wiki" + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { target_branch: "wiki" } expect(response).to have_gitlab_http_status(200) expect(json_response['target_branch']).to eq('wiki') end it "returns merge_request that removes the source branch" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), remove_source_branch: true + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { remove_source_branch: true } expect(response).to have_gitlab_http_status(200) expect(json_response['force_remove_source_branch']).to be_truthy @@ -983,8 +991,10 @@ describe API::MergeRequests do it 'allows special label names' do put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), - title: 'new issue', - labels: 'label, label?, label&foo, ?, &' + params: { + title: 'new issue', + labels: 'label, label?, label&foo, ?, &' + } expect(response.status).to eq(200) expect(json_response['labels']).to include 'label' @@ -995,7 +1005,7 @@ describe API::MergeRequests do end it 'does not update state when title is empty' do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), state_event: 'close', title: nil + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: 'close', title: nil } merge_request.reload expect(response).to have_gitlab_http_status(400) @@ -1003,7 +1013,7 @@ describe API::MergeRequests do end it 'does not update state when target_branch is empty' do - put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), state_event: 'close', target_branch: nil + put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: 'close', target_branch: nil } merge_request.reload expect(response).to have_gitlab_http_status(400) @@ -1011,13 +1021,13 @@ describe API::MergeRequests do end it "returns 404 for an invalid merge request IID" do - put api("/projects/#{project.id}/merge_requests/12345", user), state_event: "close" + put api("/projects/#{project.id}/merge_requests/12345", user), params: { state_event: "close" } expect(response).to have_gitlab_http_status(404) end it "returns 404 if the merge request id is used instead of iid" do - put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: "close" + put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), params: { state_event: "close" } expect(response).to have_gitlab_http_status(404) end diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index 3fb45449c74..9bf753fe049 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -28,7 +28,7 @@ describe API::Notes do # before do post api("/projects/#{private_issue.project.id}/issues/#{private_issue.iid}/notes", user), - body: 'Hi!' + params: { body: 'Hi!' } end it 'responds with resource not found error' do @@ -154,7 +154,7 @@ describe API::Notes do end context 'when a user is a team member' do - subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", user), body: 'Hi!' } + subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", user), params: { body: 'Hi!' } } it 'returns 200 status' do subject @@ -168,7 +168,7 @@ describe API::Notes do end context 'when a user is not a team member' do - subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", private_user), body: 'Hi!' } + subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", private_user), params: { body: 'Hi!' } } it 'returns 403 status' do subject diff --git a/spec/requests/api/notification_settings_spec.rb b/spec/requests/api/notification_settings_spec.rb index 3273cd26690..4ed667ad0dc 100644 --- a/spec/requests/api/notification_settings_spec.rb +++ b/spec/requests/api/notification_settings_spec.rb @@ -20,7 +20,7 @@ describe API::NotificationSettings do let(:email) { create(:email, user: user) } it "updates global notification settings for the current user" do - put api("/notification_settings", user), { level: 'watch', notification_email: email.email } + put api("/notification_settings", user), params: { level: 'watch', notification_email: email.email } expect(response).to have_gitlab_http_status(200) expect(json_response['notification_email']).to eq(email.email) @@ -31,7 +31,7 @@ describe API::NotificationSettings do describe "PUT /notification_settings" do it "fails on non-user email address" do - put api("/notification_settings", user), { notification_email: 'invalid@example.com' } + put api("/notification_settings", user), params: { notification_email: 'invalid@example.com' } expect(response).to have_gitlab_http_status(400) end @@ -49,7 +49,7 @@ describe API::NotificationSettings do describe "PUT /groups/:id/notification_settings" do it "updates group level notification settings for the current user" do - put api("/groups/#{group.id}/notification_settings", user), { level: 'watch' } + put api("/groups/#{group.id}/notification_settings", user), params: { level: 'watch' } expect(response).to have_gitlab_http_status(200) expect(json_response['level']).to eq(user.reload.notification_settings_for(group).level) @@ -68,7 +68,7 @@ describe API::NotificationSettings do describe "PUT /projects/:id/notification_settings" do it "updates project level notification settings for the current user" do - put api("/projects/#{project.id}/notification_settings", user), { level: 'custom', new_note: true } + put api("/projects/#{project.id}/notification_settings", user), params: { level: 'custom', new_note: true } expect(response).to have_gitlab_http_status(200) expect(json_response['level']).to eq(user.reload.notification_settings_for(project).level) @@ -79,7 +79,7 @@ describe API::NotificationSettings do describe "PUT /projects/:id/notification_settings" do it "fails on invalid level" do - put api("/projects/#{project.id}/notification_settings", user), { level: 'invalid' } + put api("/projects/#{project.id}/notification_settings", user), params: { level: 'invalid' } expect(response).to have_gitlab_http_status(400) end diff --git a/spec/requests/api/oauth_tokens_spec.rb b/spec/requests/api/oauth_tokens_spec.rb index bdda80cc229..3811ec751de 100644 --- a/spec/requests/api/oauth_tokens_spec.rb +++ b/spec/requests/api/oauth_tokens_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe 'OAuth tokens' do context 'Resource Owner Password Credentials' do def request_oauth_token(user) - post '/oauth/token', username: user.username, password: user.password, grant_type: 'password' + post '/oauth/token', params: { username: user.username, password: user.password, grant_type: 'password' } end context 'when user has 2FA enabled' do diff --git a/spec/requests/api/pages_domains_spec.rb b/spec/requests/api/pages_domains_spec.rb index 35b6ed8d5c0..3eb68a6abb6 100644 --- a/spec/requests/api/pages_domains_spec.rb +++ b/spec/requests/api/pages_domains_spec.rb @@ -236,7 +236,7 @@ describe API::PagesDomains do shared_examples_for 'post pages domains' do it 'creates a new pages domain' do - post api(route, user), params + post api(route, user), params: params pages_domain = PagesDomain.find_by(domain: json_response['domain']) expect(response).to have_gitlab_http_status(201) @@ -247,7 +247,7 @@ describe API::PagesDomains do end it 'creates a new secure pages domain' do - post api(route, user), params_secure + post api(route, user), params: params_secure pages_domain = PagesDomain.find_by(domain: json_response['domain']) expect(response).to have_gitlab_http_status(201) @@ -258,13 +258,13 @@ describe API::PagesDomains do end it 'fails to create pages domain without key' do - post api(route, user), pages_domain_secure_params.slice(:domain, :certificate) + post api(route, user), params: pages_domain_secure_params.slice(:domain, :certificate) expect(response).to have_gitlab_http_status(400) end it 'fails to create pages domain with key missmatch' do - post api(route, user), pages_domain_secure_key_missmatch_params.slice(:domain, :certificate, :key) + post api(route, user), params: pages_domain_secure_key_missmatch_params.slice(:domain, :certificate, :key) expect(response).to have_gitlab_http_status(400) end @@ -284,7 +284,7 @@ describe API::PagesDomains do end it_behaves_like '403 response' do - let(:request) { post api(route, user), params } + let(:request) { post api(route, user), params: params } end end @@ -294,7 +294,7 @@ describe API::PagesDomains do end it_behaves_like '403 response' do - let(:request) { post api(route, user), params } + let(:request) { post api(route, user), params: params } end end @@ -304,13 +304,13 @@ describe API::PagesDomains do end it_behaves_like '403 response' do - let(:request) { post api(route, user), params } + let(:request) { post api(route, user), params: params } end end context 'when user is not a member' do it_behaves_like '404 response' do - let(:request) { post api(route, user), params } + let(:request) { post api(route, user), params: params } end end end @@ -331,7 +331,7 @@ describe API::PagesDomains do end it 'updates pages domain adding certificate' do - put api(route_domain, user), params_secure + put api(route_domain, user), params: params_secure pages_domain.reload expect(response).to have_gitlab_http_status(200) @@ -341,7 +341,7 @@ describe API::PagesDomains do end it 'updates pages domain with expired certificate' do - put api(route_expired_domain, user), params_secure + put api(route_expired_domain, user), params: params_secure pages_domain_expired.reload expect(response).to have_gitlab_http_status(200) @@ -351,7 +351,7 @@ describe API::PagesDomains do end it 'updates pages domain with expired certificate not updating key' do - put api(route_secure_domain, user), params_secure_nokey + put api(route_secure_domain, user), params: params_secure_nokey pages_domain_secure.reload expect(response).to have_gitlab_http_status(200) @@ -360,19 +360,19 @@ describe API::PagesDomains do end it 'fails to update pages domain adding certificate without key' do - put api(route_domain, user), params_secure_nokey + put api(route_domain, user), params: params_secure_nokey expect(response).to have_gitlab_http_status(400) end it 'fails to update pages domain adding certificate with missing chain' do - put api(route_domain, user), pages_domain_secure_missing_chain_params.slice(:certificate) + put api(route_domain, user), params: pages_domain_secure_missing_chain_params.slice(:certificate) expect(response).to have_gitlab_http_status(400) end it 'fails to update pages domain with key missmatch' do - put api(route_secure_domain, user), pages_domain_secure_key_missmatch_params.slice(:certificate, :key) + put api(route_secure_domain, user), params: pages_domain_secure_key_missmatch_params.slice(:certificate, :key) expect(response).to have_gitlab_http_status(400) end diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb index 997d413eb4f..870ef34437f 100644 --- a/spec/requests/api/pipeline_schedules_spec.rb +++ b/spec/requests/api/pipeline_schedules_spec.rb @@ -58,7 +58,7 @@ describe API::PipelineSchedules do end it 'returns matched pipeline schedules' do - get api("/projects/#{project.id}/pipeline_schedules", developer), scope: target + get api("/projects/#{project.id}/pipeline_schedules", developer), params: { scope: target } expect(json_response.map { |r| r['active'] }).to all(eq(active?(target))) end @@ -146,7 +146,7 @@ describe API::PipelineSchedules do it 'creates pipeline_schedule' do expect do post api("/projects/#{project.id}/pipeline_schedules", developer), - params + params: params end.to change { project.pipeline_schedules.count }.by(1) expect(response).to have_gitlab_http_status(:created) @@ -170,7 +170,7 @@ describe API::PipelineSchedules do context 'when cron has validation error' do it 'does not create pipeline_schedule' do post api("/projects/#{project.id}/pipeline_schedules", developer), - params.merge('cron' => 'invalid-cron') + params: params.merge('cron' => 'invalid-cron') expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to have_key('cron') @@ -180,7 +180,7 @@ describe API::PipelineSchedules do context 'authenticated user with invalid permissions' do it 'does not create pipeline_schedule' do - post api("/projects/#{project.id}/pipeline_schedules", user), params + post api("/projects/#{project.id}/pipeline_schedules", user), params: params expect(response).to have_gitlab_http_status(:not_found) end @@ -188,7 +188,7 @@ describe API::PipelineSchedules do context 'unauthenticated user' do it 'does not create pipeline_schedule' do - post api("/projects/#{project.id}/pipeline_schedules"), params + post api("/projects/#{project.id}/pipeline_schedules"), params: params expect(response).to have_gitlab_http_status(:unauthorized) end @@ -203,7 +203,7 @@ describe API::PipelineSchedules do context 'authenticated user with valid permissions' do it 'updates cron' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer), - cron: '1 2 3 4 *' + params: { cron: '1 2 3 4 *' } expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('pipeline_schedule') @@ -213,7 +213,7 @@ describe API::PipelineSchedules do context 'when cron has validation error' do it 'does not update pipeline_schedule' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer), - cron: 'invalid-cron' + params: { cron: 'invalid-cron' } expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to have_key('cron') @@ -331,7 +331,7 @@ describe API::PipelineSchedules do it 'creates pipeline_schedule_variable' do expect do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", developer), - params + params: params end.to change { pipeline_schedule.variables.count }.by(1) expect(response).to have_gitlab_http_status(:created) @@ -352,7 +352,7 @@ describe API::PipelineSchedules do context 'when key has validation error' do it 'does not create pipeline_schedule_variable' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", developer), - params.merge('key' => '!?!?') + params: params.merge('key' => '!?!?') expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to have_key('key') @@ -362,7 +362,7 @@ describe API::PipelineSchedules do context 'authenticated user with invalid permissions' do it 'does not create pipeline_schedule_variable' do - post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", user), params + post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", user), params: params expect(response).to have_gitlab_http_status(:not_found) end @@ -370,7 +370,7 @@ describe API::PipelineSchedules do context 'unauthenticated user' do it 'does not create pipeline_schedule_variable' do - post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables"), params + post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables"), params: params expect(response).to have_gitlab_http_status(:unauthorized) end @@ -389,7 +389,7 @@ describe API::PipelineSchedules do context 'authenticated user with valid permissions' do it 'updates pipeline_schedule_variable' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", developer), - value: 'updated_value' + params: { value: 'updated_value' } expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('pipeline_schedule_variable') diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index 2e4fa0f9e16..eb002de62a2 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -36,7 +36,7 @@ describe API::Pipelines do end it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), scope: target + get api("/projects/#{project.id}/pipelines", user), params: { scope: target } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -54,7 +54,7 @@ describe API::Pipelines do end it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), scope: 'finished' + get api("/projects/#{project.id}/pipelines", user), params: { scope: 'finished' } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -69,7 +69,7 @@ describe API::Pipelines do context 'when scope is branches' do it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), scope: 'branches' + get api("/projects/#{project.id}/pipelines", user), params: { scope: 'branches' } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -80,7 +80,7 @@ describe API::Pipelines do context 'when scope is tags' do it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), scope: 'tags' + get api("/projects/#{project.id}/pipelines", user), params: { scope: 'tags' } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -92,7 +92,7 @@ describe API::Pipelines do context 'when scope is invalid' do it 'returns bad_request' do - get api("/projects/#{project.id}/pipelines", user), scope: 'invalid-scope' + get api("/projects/#{project.id}/pipelines", user), params: { scope: 'invalid-scope' } expect(response).to have_gitlab_http_status(:bad_request) end @@ -107,7 +107,7 @@ describe API::Pipelines do end it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), status: target + get api("/projects/#{project.id}/pipelines", user), params: { status: target } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -119,7 +119,7 @@ describe API::Pipelines do context 'when status is invalid' do it 'returns bad_request' do - get api("/projects/#{project.id}/pipelines", user), status: 'invalid-status' + get api("/projects/#{project.id}/pipelines", user), params: { status: 'invalid-status' } expect(response).to have_gitlab_http_status(:bad_request) end @@ -132,7 +132,7 @@ describe API::Pipelines do context 'when ref exists' do it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), ref: 'master' + get api("/projects/#{project.id}/pipelines", user), params: { ref: 'master' } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -143,7 +143,7 @@ describe API::Pipelines do context 'when ref does not exist' do it 'returns empty' do - get api("/projects/#{project.id}/pipelines", user), ref: 'invalid-ref' + get api("/projects/#{project.id}/pipelines", user), params: { ref: 'invalid-ref' } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -157,7 +157,7 @@ describe API::Pipelines do context 'when name exists' do it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), name: user.name + get api("/projects/#{project.id}/pipelines", user), params: { name: user.name } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -167,7 +167,7 @@ describe API::Pipelines do context 'when name does not exist' do it 'returns empty' do - get api("/projects/#{project.id}/pipelines", user), name: 'invalid-name' + get api("/projects/#{project.id}/pipelines", user), params: { name: 'invalid-name' } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -181,7 +181,7 @@ describe API::Pipelines do context 'when username exists' do it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), username: user.username + get api("/projects/#{project.id}/pipelines", user), params: { username: user.username } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -191,7 +191,7 @@ describe API::Pipelines do context 'when username does not exist' do it 'returns empty' do - get api("/projects/#{project.id}/pipelines", user), username: 'invalid-username' + get api("/projects/#{project.id}/pipelines", user), params: { username: 'invalid-username' } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -206,7 +206,7 @@ describe API::Pipelines do context 'when yaml_errors is true' do it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), yaml_errors: true + get api("/projects/#{project.id}/pipelines", user), params: { yaml_errors: true } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -216,7 +216,7 @@ describe API::Pipelines do context 'when yaml_errors is false' do it 'returns matched pipelines' do - get api("/projects/#{project.id}/pipelines", user), yaml_errors: false + get api("/projects/#{project.id}/pipelines", user), params: { yaml_errors: false } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -226,7 +226,7 @@ describe API::Pipelines do context 'when yaml_errors is invalid' do it 'returns bad_request' do - get api("/projects/#{project.id}/pipelines", user), yaml_errors: 'invalid-yaml_errors' + get api("/projects/#{project.id}/pipelines", user), params: { yaml_errors: 'invalid-yaml_errors' } expect(response).to have_gitlab_http_status(:bad_request) end @@ -243,7 +243,7 @@ describe API::Pipelines do context 'when sort parameter is valid' do it 'sorts as user_id: :desc' do - get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'desc' + get api("/projects/#{project.id}/pipelines", user), params: { order_by: 'user_id', sort: 'desc' } expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers @@ -256,7 +256,7 @@ describe API::Pipelines do context 'when sort parameter is invalid' do it 'returns bad_request' do - get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'invalid_sort' + get api("/projects/#{project.id}/pipelines", user), params: { order_by: 'user_id', sort: 'invalid_sort' } expect(response).to have_gitlab_http_status(:bad_request) end @@ -265,7 +265,7 @@ describe API::Pipelines do context 'when order_by is invalid' do it 'returns bad_request' do - get api("/projects/#{project.id}/pipelines", user), order_by: 'lock_version', sort: 'asc' + get api("/projects/#{project.id}/pipelines", user), params: { order_by: 'lock_version', sort: 'asc' } expect(response).to have_gitlab_http_status(:bad_request) end @@ -303,7 +303,7 @@ describe API::Pipelines do it 'creates and returns a new pipeline' do expect do - post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch + post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch } end.to change { project.ci_pipelines.count }.by(1) expect(response).to have_gitlab_http_status(201) @@ -316,7 +316,7 @@ describe API::Pipelines do it 'creates and returns a new pipeline using the given variables' do expect do - post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch, variables: variables + post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch, variables: variables } end.to change { project.ci_pipelines.count }.by(1) expect_variables(project.ci_pipelines.last.variables, variables) @@ -337,7 +337,7 @@ describe API::Pipelines do it 'creates and returns a new pipeline using the given variables' do expect do - post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch, variables: variables + post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch, variables: variables } end.to change { project.ci_pipelines.count }.by(1) expect_variables(project.ci_pipelines.last.variables, variables) @@ -352,7 +352,7 @@ describe API::Pipelines do it "doesn't create a job" do expect do - post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch + post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch } end.not_to change { project.ci_pipelines.count } expect(response).to have_gitlab_http_status(400) @@ -361,7 +361,7 @@ describe API::Pipelines do end it 'fails when using an invalid ref' do - post api("/projects/#{project.id}/pipeline", user), ref: 'invalid_ref' + post api("/projects/#{project.id}/pipeline", user), params: { ref: 'invalid_ref' } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Reference not found' @@ -376,7 +376,7 @@ describe API::Pipelines do end it 'fails to create pipeline' do - post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch + post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Missing .gitlab-ci.yml file' @@ -388,7 +388,7 @@ describe API::Pipelines do context 'unauthorized user' do it 'does not create pipeline' do - post api("/projects/#{project.id}/pipeline", non_member), ref: project.default_branch + post api("/projects/#{project.id}/pipeline", non_member), params: { ref: project.default_branch } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' diff --git a/spec/requests/api/project_export_spec.rb b/spec/requests/api/project_export_spec.rb index 0586025956f..1d2f81a397d 100644 --- a/spec/requests/api/project_export_spec.rb +++ b/spec/requests/api/project_export_spec.rb @@ -294,14 +294,14 @@ describe API::ProjectExport do context 'with upload strategy' do context 'when params invalid' do it_behaves_like '400 response' do - let(:request) { post(api(path, user), 'upload[url]' => 'whatever') } + let(:request) { post(api(path, user), params: { 'upload[url]' => 'whatever' }) } end end it 'starts' do allow_any_instance_of(Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy).to receive(:send_file) - post(api(path, user), 'upload[url]' => 'http://gitlab.com') + post(api(path, user), params: { 'upload[url]' => 'http://gitlab.com' }) expect(response).to have_gitlab_http_status(202) end @@ -374,7 +374,7 @@ describe API::ProjectExport do params = { description: "Foo" } expect_any_instance_of(Projects::ImportExport::ExportService).to receive(:execute) - post api(path, project.owner), params + post api(path, project.owner), params: params expect(response).to have_gitlab_http_status(202) end diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb index 87997a48dc9..b88a8b95201 100644 --- a/spec/requests/api/project_hooks_spec.rb +++ b/spec/requests/api/project_hooks_spec.rb @@ -91,8 +91,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "adds hook to project" do expect do post api("/projects/#{project.id}/hooks", user), - url: "http://example.com", issues_events: true, confidential_issues_events: true, wiki_page_events: true, - job_events: true, push_events_branch_filter: 'some-feature-branch' + params: { url: "http://example.com", issues_events: true, confidential_issues_events: true, wiki_page_events: true, job_events: true, push_events_branch_filter: 'some-feature-branch' } end.to change {project.hooks.count}.by(1) expect(response).to have_gitlab_http_status(201) @@ -116,7 +115,7 @@ describe API::ProjectHooks, 'ProjectHooks' do token = "secret token" expect do - post api("/projects/#{project.id}/hooks", user), url: "http://example.com", token: token + post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", token: token } end.to change {project.hooks.count}.by(1) expect(response).to have_gitlab_http_status(201) @@ -135,12 +134,12 @@ describe API::ProjectHooks, 'ProjectHooks' do end it "returns a 422 error if url not valid" do - post api("/projects/#{project.id}/hooks", user), url: "ftp://example.com" + post api("/projects/#{project.id}/hooks", user), params: { url: "ftp://example.com" } expect(response).to have_gitlab_http_status(422) end it "returns a 422 error if branch filter is not valid" do - post api("/projects/#{project.id}/hooks", user), url: "http://example.com", push_events_branch_filter: '~badbranchname/' + post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", push_events_branch_filter: '~badbranchname/' } expect(response).to have_gitlab_http_status(422) end end @@ -148,7 +147,7 @@ describe API::ProjectHooks, 'ProjectHooks' do describe "PUT /projects/:id/hooks/:hook_id" do it "updates an existing project hook" do put api("/projects/#{project.id}/hooks/#{hook.id}", user), - url: 'http://example.org', push_events: false, job_events: true + params: { url: 'http://example.org', push_events: false, job_events: true } expect(response).to have_gitlab_http_status(200) expect(json_response['url']).to eq('http://example.org') @@ -168,7 +167,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "adds the token without including it in the response" do token = "secret token" - put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: "http://example.org", token: token + put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: "http://example.org", token: token } expect(response).to have_gitlab_http_status(200) expect(json_response["url"]).to eq("http://example.org") @@ -179,7 +178,7 @@ describe API::ProjectHooks, 'ProjectHooks' do end it "returns 404 error if hook id not found" do - put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org' + put api("/projects/#{project.id}/hooks/1234", user), params: { url: 'http://example.org' } expect(response).to have_gitlab_http_status(404) end @@ -189,7 +188,7 @@ describe API::ProjectHooks, 'ProjectHooks' do end it "returns a 422 error if url is not valid" do - put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com' + put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: 'ftp://example.com' } expect(response).to have_gitlab_http_status(422) end end diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb index 204702b8a5a..594b42bb6c0 100644 --- a/spec/requests/api/project_import_spec.rb +++ b/spec/requests/api/project_import_spec.rb @@ -20,7 +20,7 @@ describe API::ProjectImport do it 'schedules an import using a namespace' do stub_import(namespace) - post api('/projects/import', user), path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id + post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id } expect(response).to have_gitlab_http_status(201) end @@ -28,7 +28,7 @@ describe API::ProjectImport do it 'schedules an import using the namespace path' do stub_import(namespace) - post api('/projects/import', user), path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path + post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path } expect(response).to have_gitlab_http_status(201) end @@ -36,7 +36,7 @@ describe API::ProjectImport do it 'schedules an import at the user namespace level' do stub_import(user.namespace) - post api('/projects/import', user), path: 'test-import2', file: fixture_file_upload(file) + post api('/projects/import', user), params: { path: 'test-import2', file: fixture_file_upload(file) } expect(response).to have_gitlab_http_status(201) end @@ -45,7 +45,7 @@ describe API::ProjectImport do expect_any_instance_of(ProjectImportState).not_to receive(:schedule) expect(::Projects::CreateService).not_to receive(:new) - post api('/projects/import', user), namespace: 'nonexistent', path: 'test-import2', file: fixture_file_upload(file) + post api('/projects/import', user), params: { namespace: 'nonexistent', path: 'test-import2', file: fixture_file_upload(file) } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Namespace Not Found') @@ -55,9 +55,11 @@ describe API::ProjectImport do expect_any_instance_of(ProjectImportState).not_to receive(:schedule) post(api('/projects/import', create(:user)), - path: 'test-import3', - file: fixture_file_upload(file), - namespace: namespace.full_path) + params: { + path: 'test-import3', + file: fixture_file_upload(file), + namespace: namespace.full_path + }) expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Namespace Not Found') @@ -66,7 +68,7 @@ describe API::ProjectImport do it 'does not schedule an import if the user uploads no valid file' do expect_any_instance_of(ProjectImportState).not_to receive(:schedule) - post api('/projects/import', user), path: 'test-import3', file: './random/test' + post api('/projects/import', user), params: { path: 'test-import3', file: './random/test' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('file is invalid') @@ -77,10 +79,12 @@ describe API::ProjectImport do override_params = { 'description' => 'Hello world' } post api('/projects/import', user), - path: 'test-import', - file: fixture_file_upload(file), - namespace: namespace.id, - override_params: override_params + params: { + path: 'test-import', + file: fixture_file_upload(file), + namespace: namespace.id, + override_params: override_params + } import_project = Project.find(json_response['id']) expect(import_project.import_data.data['override_params']).to eq(override_params) @@ -91,10 +95,12 @@ describe API::ProjectImport do override_params = { 'not_allowed' => 'Hello world' } post api('/projects/import', user), - path: 'test-import', - file: fixture_file_upload(file), - namespace: namespace.id, - override_params: override_params + params: { + path: 'test-import', + file: fixture_file_upload(file), + namespace: namespace.id, + override_params: override_params + } import_project = Project.find(json_response['id']) expect(import_project.import_data.data['override_params']).to be_empty @@ -105,10 +111,12 @@ describe API::ProjectImport do perform_enqueued_jobs do post api('/projects/import', user), - path: 'test-import', - file: fixture_file_upload(file), - namespace: namespace.id, - override_params: override_params + params: { + path: 'test-import', + file: fixture_file_upload(file), + namespace: namespace.id, + override_params: override_params + } end import_project = Project.find(json_response['id']) @@ -121,7 +129,7 @@ describe API::ProjectImport do it 'does not schedule an import' do expect_any_instance_of(ProjectImportState).not_to receive(:schedule) - post api('/projects/import', user), path: existing_project.path, file: fixture_file_upload(file) + post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file) } expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Name has already been taken') @@ -131,7 +139,7 @@ describe API::ProjectImport do it 'schedules an import' do stub_import(user.namespace) - post api('/projects/import', user), path: existing_project.path, file: fixture_file_upload(file), overwrite: true + post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file), overwrite: true } expect(response).to have_gitlab_http_status(201) end diff --git a/spec/requests/api/project_milestones_spec.rb b/spec/requests/api/project_milestones_spec.rb index 62613aa5938..0fa13dd71e2 100644 --- a/spec/requests/api/project_milestones_spec.rb +++ b/spec/requests/api/project_milestones_spec.rb @@ -46,7 +46,7 @@ describe API::ProjectMilestones do expect(Event).to receive(:create!) put api("/projects/#{project.id}/milestones/#{milestone.id}", user), - state_event: 'close' + params: { state_event: 'close' } end end end diff --git a/spec/requests/api/project_snapshots_spec.rb b/spec/requests/api/project_snapshots_spec.rb index 07a920f8d28..44b5ee1f130 100644 --- a/spec/requests/api/project_snapshots_spec.rb +++ b/spec/requests/api/project_snapshots_spec.rb @@ -35,14 +35,14 @@ describe API::ProjectSnapshots do end it 'requests project repository raw archive as administrator' do - get api("/projects/#{project.id}/snapshot", admin), wiki: '0' + get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '0' } expect(response).to have_gitlab_http_status(200) expect_snapshot_response_for(project.repository) end it 'requests wiki repository raw archive as administrator' do - get api("/projects/#{project.id}/snapshot", admin), wiki: '1' + get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '1' } expect(response).to have_gitlab_http_status(200) expect_snapshot_response_for(project.wiki.repository) diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index 5dec0bc778c..29f69b6ce20 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -97,7 +97,7 @@ describe API::ProjectSnippets do end it 'creates a new snippet' do - post api("/projects/#{project.id}/snippets/", admin), params + post api("/projects/#{project.id}/snippets/", admin), params: params expect(response).to have_gitlab_http_status(201) snippet = ProjectSnippet.find(json_response['id']) @@ -111,7 +111,7 @@ describe API::ProjectSnippets do it 'returns 400 for missing parameters' do params.delete(:title) - post api("/projects/#{project.id}/snippets/", admin), params + post api("/projects/#{project.id}/snippets/", admin), params: params expect(response).to have_gitlab_http_status(400) end @@ -119,7 +119,7 @@ describe API::ProjectSnippets do it 'returns 400 for empty code field' do params[:code] = '' - post api("/projects/#{project.id}/snippets/", admin), params + post api("/projects/#{project.id}/snippets/", admin), params: params expect(response).to have_gitlab_http_status(400) end @@ -128,7 +128,7 @@ describe API::ProjectSnippets do def create_snippet(project, snippet_params = {}) project.add_developer(user) - post api("/projects/#{project.id}/snippets", user), params.merge(snippet_params) + post api("/projects/#{project.id}/snippets", user), params: params.merge(snippet_params) end before do @@ -167,7 +167,7 @@ describe API::ProjectSnippets do new_content = 'New content' new_description = 'New description' - put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), code: new_content, description: new_description + put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content, description: new_description } expect(response).to have_gitlab_http_status(200) snippet.reload @@ -176,7 +176,7 @@ describe API::ProjectSnippets do end it 'returns 404 for invalid snippet id' do - put api("/projects/#{snippet.project.id}/snippets/1234", admin), title: 'foo' + put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { title: 'foo' } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') @@ -191,14 +191,14 @@ describe API::ProjectSnippets do it 'returns 400 for empty code field' do new_content = '' - put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), code: new_content + put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content } expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do def update_snippet(snippet_params = {}) - put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}", admin), snippet_params + put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}", admin), params: snippet_params end before do diff --git a/spec/requests/api/project_templates_spec.rb b/spec/requests/api/project_templates_spec.rb index 86e33f23951..ab5d4de7ff7 100644 --- a/spec/requests/api/project_templates_spec.rb +++ b/spec/requests/api/project_templates_spec.rb @@ -130,8 +130,10 @@ describe API::ProjectTemplates do describe 'GET /projects/:id/templates/licenses/:key' do it 'fills placeholders in the license' do get api("/projects/#{public_project.id}/templates/licenses/agpl-3.0"), - project: 'Project Placeholder', - fullname: 'Fullname Placeholder' + params: { + project: 'Project Placeholder', + fullname: 'Fullname Placeholder' + } expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/license') diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index e40db55cd20..ffe4512fa6f 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -52,7 +52,7 @@ describe API::Projects do describe 'GET /projects' do shared_examples_for 'projects response' do it 'returns an array of projects' do - get api('/projects', current_user), filter + get api('/projects', current_user), params: filter expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -61,7 +61,7 @@ describe API::Projects do end it 'returns the proper security headers' do - get api('/projects', current_user), filter + get api('/projects', current_user), params: filter expect(response).to include_security_headers end @@ -192,7 +192,7 @@ describe API::Projects do end it "includes statistics if requested" do - get api('/projects', user), statistics: true + get api('/projects', user), params: { statistics: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -210,7 +210,7 @@ describe API::Projects do end it "does not include license if requested" do - get api('/projects', user), license: true + get api('/projects', user), params: { license: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -315,7 +315,7 @@ describe API::Projects do context 'and using the visibility filter' do it 'filters based on private visibility param' do - get api('/projects', user), { visibility: 'private' } + get api('/projects', user), params: { visibility: 'private' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -326,7 +326,7 @@ describe API::Projects do it 'filters based on internal visibility param' do project2.update_attribute(:visibility_level, Gitlab::VisibilityLevel::INTERNAL) - get api('/projects', user), { visibility: 'internal' } + get api('/projects', user), params: { visibility: 'internal' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -335,7 +335,7 @@ describe API::Projects do end it 'filters based on public visibility param' do - get api('/projects', user), { visibility: 'public' } + get api('/projects', user), params: { visibility: 'public' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -346,7 +346,7 @@ describe API::Projects do context 'and using sorting' do it 'returns the correct order when sorted by id' do - get api('/projects', user), { order_by: 'id', sort: 'desc' } + get api('/projects', user), params: { order_by: 'id', sort: 'desc' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -357,7 +357,7 @@ describe API::Projects do context 'and with owned=true' do it 'returns an array of projects the user owns' do - get api('/projects', user4), owned: true + get api('/projects', user4), params: { owned: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -376,7 +376,7 @@ describe API::Projects do end it 'returns the starred projects viewable by the user' do - get api('/projects', user3), starred: true + get api('/projects', user3), params: { starred: true } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -398,7 +398,7 @@ describe API::Projects do context 'including owned filter' do it 'returns only projects that satisfy all query parameters' do - get api('/projects', user), { visibility: 'public', owned: true, starred: true, search: 'gitlab' } + get api('/projects', user), params: { visibility: 'public', owned: true, starred: true, search: 'gitlab' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -417,7 +417,7 @@ describe API::Projects do end it 'returns only projects that satisfy all query parameters' do - get api('/projects', user), { visibility: 'public', membership: true, starred: true, search: 'gitlab' } + get api('/projects', user), params: { visibility: 'public', membership: true, starred: true, search: 'gitlab' } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -436,7 +436,7 @@ describe API::Projects do end it 'returns an array of groups the user has at least developer access' do - get api('/projects', user2), { min_access_level: 30 } + get api('/projects', user2), params: { min_access_level: 30 } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array @@ -479,14 +479,14 @@ describe API::Projects do context 'maximum number of projects reached' do it 'does not create new project and respond with 403' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) - expect { post api('/projects', user2), name: 'foo' } + expect { post api('/projects', user2), params: { name: 'foo' } } .to change {Project.count}.by(0) expect(response).to have_gitlab_http_status(403) end end it 'creates new project without path but with name and returns 201' do - expect { post api('/projects', user), name: 'Foo Project' } + expect { post api('/projects', user), params: { name: 'Foo Project' } } .to change { Project.count }.by(1) expect(response).to have_gitlab_http_status(201) @@ -497,7 +497,7 @@ describe API::Projects do end it 'creates new project without name but with path and returns 201' do - expect { post api('/projects', user), path: 'foo_project' } + expect { post api('/projects', user), params: { path: 'foo_project' } } .to change { Project.count }.by(1) expect(response).to have_gitlab_http_status(201) @@ -508,7 +508,7 @@ describe API::Projects do end it 'creates new project with name and path and returns 201' do - expect { post api('/projects', user), path: 'path-project-Foo', name: 'Foo Project' } + expect { post api('/projects', user), params: { path: 'path-project-Foo', name: 'Foo Project' } } .to change { Project.count }.by(1) expect(response).to have_gitlab_http_status(201) @@ -520,7 +520,7 @@ describe API::Projects do it 'creates last project before reaching project limit' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1) - post api('/projects', user2), name: 'foo' + post api('/projects', user2), params: { name: 'foo' } expect(response).to have_gitlab_http_status(201) end @@ -544,7 +544,7 @@ describe API::Projects do merge_method: 'ff' }) - post api('/projects', user), project + post api('/projects', user), params: project expect(response).to have_gitlab_http_status(201) @@ -564,7 +564,7 @@ describe API::Projects do it 'sets a project as public' do project = attributes_for(:project, visibility: 'public') - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['visibility']).to eq('public') end @@ -572,7 +572,7 @@ describe API::Projects do it 'sets a project as internal' do project = attributes_for(:project, visibility: 'internal') - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['visibility']).to eq('internal') end @@ -580,7 +580,7 @@ describe API::Projects do it 'sets a project as private' do project = attributes_for(:project, visibility: 'private') - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['visibility']).to eq('private') end @@ -588,7 +588,7 @@ describe API::Projects do it 'creates a new project initialized with a README.md' do project = attributes_for(:project, initialize_with_readme: 1, name: 'somewhere') - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/blob/master/README.md") end @@ -596,7 +596,7 @@ describe API::Projects do it 'sets tag list to a project' do project = attributes_for(:project, tag_list: %w[tagFirst tagSecond]) - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['tag_list']).to eq(%w[tagFirst tagSecond]) end @@ -604,7 +604,7 @@ describe API::Projects do it 'uploads avatar for project a project' do project = attributes_for(:project, avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif')) - post api('/projects', user), project + post api('/projects', user), params: project project_id = json_response['id'] expect(json_response['avatar_url']).to eq("http://localhost/uploads/-/system/project/avatar/#{project_id}/banana_sample.gif") @@ -613,7 +613,7 @@ describe API::Projects do it 'sets a project as not allowing outdated diff discussions to automatically resolve' do project = attributes_for(:project, resolve_outdated_diff_discussions: false) - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['resolve_outdated_diff_discussions']).to be_falsey end @@ -621,7 +621,7 @@ describe API::Projects do it 'sets a project as allowing outdated diff discussions to automatically resolve' do project = attributes_for(:project, resolve_outdated_diff_discussions: true) - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['resolve_outdated_diff_discussions']).to be_truthy end @@ -629,7 +629,7 @@ describe API::Projects do it 'sets a project as allowing merge even if build fails' do project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: false) - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_falsey end @@ -637,7 +637,7 @@ describe API::Projects do it 'sets a project as allowing merge only if merge_when_pipeline_succeeds' do project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: true) - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_truthy end @@ -645,7 +645,7 @@ describe API::Projects do it 'sets a project as allowing merge even if discussions are unresolved' do project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: false) - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_falsey end @@ -653,7 +653,7 @@ describe API::Projects do it 'sets a project as allowing merge if only_allow_merge_if_all_discussions_are_resolved is nil' do project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: nil) - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_falsey end @@ -661,7 +661,7 @@ describe API::Projects do it 'sets a project as allowing merge only if all discussions are resolved' do project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: true) - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy end @@ -669,7 +669,7 @@ describe API::Projects do it 'sets the merge method of a project to rebase merge' do project = attributes_for(:project, merge_method: 'rebase_merge') - post api('/projects', user), project + post api('/projects', user), params: project expect(json_response['merge_method']).to eq('rebase_merge') end @@ -677,7 +677,7 @@ describe API::Projects do it 'rejects invalid values for merge_method' do project = attributes_for(:project, merge_method: 'totally_not_valid_method') - post api('/projects', user), project + post api('/projects', user), params: project expect(response).to have_gitlab_http_status(400) end @@ -685,7 +685,7 @@ describe API::Projects do it 'ignores import_url when it is nil' do project = attributes_for(:project, import_url: nil) - post api('/projects', user), project + post api('/projects', user), params: project expect(response).to have_gitlab_http_status(201) end @@ -698,7 +698,7 @@ describe API::Projects do end it 'does not allow a non-admin to use a restricted visibility level' do - post api('/projects', user), project_param + post api('/projects', user), params: project_param expect(response).to have_gitlab_http_status(400) expect(json_response['message']['visibility_level'].first).to( @@ -707,7 +707,7 @@ describe API::Projects do end it 'allows an admin to override restricted visibility settings' do - post api('/projects', admin), project_param + post api('/projects', admin), params: project_param expect(json_response['visibility']).to eq('public') end @@ -739,7 +739,7 @@ describe API::Projects do private_project1.add_developer(user2) private_project2.add_reporter(user2) - get api("/users/#{user4.id}/projects/", user2), { min_access_level: 30 } + get api("/users/#{user4.id}/projects/", user2), params: { min_access_level: 30 } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -750,7 +750,7 @@ describe API::Projects do describe 'POST /projects/user/:id' do it 'creates new project without path but with name and return 201' do - expect { post api("/projects/user/#{user.id}", admin), name: 'Foo Project' }.to change { Project.count }.by(1) + expect { post api("/projects/user/#{user.id}", admin), params: { name: 'Foo Project' } }.to change { Project.count }.by(1) expect(response).to have_gitlab_http_status(201) project = Project.last @@ -760,7 +760,7 @@ describe API::Projects do end it 'creates new project with name and path and returns 201' do - expect { post api("/projects/user/#{user.id}", admin), path: 'path-project-Foo', name: 'Foo Project' } + expect { post api("/projects/user/#{user.id}", admin), params: { path: 'path-project-Foo', name: 'Foo Project' } } .to change { Project.count }.by(1) expect(response).to have_gitlab_http_status(201) @@ -787,7 +787,7 @@ describe API::Projects do jobs_enabled: true }) - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(response).to have_gitlab_http_status(201) @@ -801,7 +801,7 @@ describe API::Projects do it 'sets a project as public' do project = attributes_for(:project, visibility: 'public') - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(response).to have_gitlab_http_status(201) expect(json_response['visibility']).to eq('public') @@ -810,7 +810,7 @@ describe API::Projects do it 'sets a project as internal' do project = attributes_for(:project, visibility: 'internal') - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(response).to have_gitlab_http_status(201) expect(json_response['visibility']).to eq('internal') @@ -819,7 +819,7 @@ describe API::Projects do it 'sets a project as private' do project = attributes_for(:project, visibility: 'private') - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(json_response['visibility']).to eq('private') end @@ -827,7 +827,7 @@ describe API::Projects do it 'sets a project as not allowing outdated diff discussions to automatically resolve' do project = attributes_for(:project, resolve_outdated_diff_discussions: false) - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(json_response['resolve_outdated_diff_discussions']).to be_falsey end @@ -835,27 +835,27 @@ describe API::Projects do it 'sets a project as allowing outdated diff discussions to automatically resolve' do project = attributes_for(:project, resolve_outdated_diff_discussions: true) - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(json_response['resolve_outdated_diff_discussions']).to be_truthy end it 'sets a project as allowing merge even if build fails' do project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: false) - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_falsey end it 'sets a project as allowing merge only if pipeline succeeds' do project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: true) - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_truthy end it 'sets a project as allowing merge even if discussions are unresolved' do project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: false) - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_falsey end @@ -863,7 +863,7 @@ describe API::Projects do it 'sets a project as allowing merge only if all discussions are resolved' do project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: true) - post api("/projects/user/#{user.id}", admin), project + post api("/projects/user/#{user.id}", admin), params: project expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy end @@ -875,7 +875,7 @@ describe API::Projects do end it "uploads the file and returns its info" do - post api("/projects/#{project.id}/uploads", user), file: fixture_file_upload("spec/fixtures/dk.png", "image/png") + post api("/projects/#{project.id}/uploads", user), params: { file: fixture_file_upload("spec/fixtures/dk.png", "image/png") } expect(response).to have_gitlab_http_status(201) expect(json_response['alt']).to eq("dk") @@ -1020,7 +1020,7 @@ describe API::Projects do end it 'includes license fields when requested' do - get api("/projects/#{project.id}", user), license: true + get api("/projects/#{project.id}", user), params: { license: true } expect(response).to have_gitlab_http_status(200) expect(json_response['license']).to eq({ @@ -1040,7 +1040,7 @@ describe API::Projects do end it "includes statistics if requested" do - get api("/projects/#{project.id}", user), statistics: true + get api("/projects/#{project.id}", user), params: { statistics: true } expect(response).to have_gitlab_http_status(200) expect(json_response).to include 'statistics' @@ -1397,7 +1397,7 @@ describe API::Projects do expires_at = 10.days.from_now.to_date expect do - post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at + post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at } end.to change { ProjectGroupLink.count }.by(1) expect(response).to have_gitlab_http_status(201) @@ -1407,37 +1407,37 @@ describe API::Projects do end it "returns a 400 error when group id is not given" do - post api("/projects/#{project.id}/share", user), group_access: Gitlab::Access::DEVELOPER + post api("/projects/#{project.id}/share", user), params: { group_access: Gitlab::Access::DEVELOPER } expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when access level is not given" do - post api("/projects/#{project.id}/share", user), group_id: group.id + post api("/projects/#{project.id}/share", user), params: { group_id: group.id } expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when sharing is disabled" do project.namespace.update(share_with_group_lock: true) - post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER + post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER } expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when user cannot read group' do private_group = create(:group, :private) - post api("/projects/#{project.id}/share", user), group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER + post api("/projects/#{project.id}/share", user), params: { group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER } expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when group does not exist' do - post api("/projects/#{project.id}/share", user), group_id: 1234, group_access: Gitlab::Access::DEVELOPER + post api("/projects/#{project.id}/share", user), params: { group_id: 1234, group_access: Gitlab::Access::DEVELOPER } expect(response).to have_gitlab_http_status(404) end it "returns a 400 error when wrong params passed" do - post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: 1234 + post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: 1234 } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq 'group_access does not have a valid value' @@ -1498,7 +1498,7 @@ describe API::Projects do it 'returns 400 when nothing sent' do project_param = {} - put api("/projects/#{project.id}", user), project_param + put api("/projects/#{project.id}", user), params: project_param expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to match('at least one parameter must be provided') @@ -1508,7 +1508,7 @@ describe API::Projects do it 'returns authentication error' do project_param = { name: 'bar' } - put api("/projects/#{project.id}"), project_param + put api("/projects/#{project.id}"), params: project_param expect(response).to have_gitlab_http_status(401) end @@ -1518,7 +1518,7 @@ describe API::Projects do it 'updates name' do project_param = { name: 'bar' } - put api("/projects/#{project.id}", user), project_param + put api("/projects/#{project.id}", user), params: project_param expect(response).to have_gitlab_http_status(200) @@ -1530,7 +1530,7 @@ describe API::Projects do it 'updates visibility_level' do project_param = { visibility: 'public' } - put api("/projects/#{project3.id}", user), project_param + put api("/projects/#{project3.id}", user), params: project_param expect(response).to have_gitlab_http_status(200) @@ -1543,7 +1543,7 @@ describe API::Projects do project3.update({ visibility_level: Gitlab::VisibilityLevel::PUBLIC }) project_param = { visibility: 'private' } - put api("/projects/#{project3.id}", user), project_param + put api("/projects/#{project3.id}", user), params: project_param expect(response).to have_gitlab_http_status(200) @@ -1557,7 +1557,7 @@ describe API::Projects do it 'does not update name to existing name' do project_param = { name: project3.name } - put api("/projects/#{project.id}", user), project_param + put api("/projects/#{project.id}", user), params: project_param expect(response).to have_gitlab_http_status(400) expect(json_response['message']['name']).to eq(['has already been taken']) @@ -1566,7 +1566,7 @@ describe API::Projects do it 'updates request_access_enabled' do project_param = { request_access_enabled: false } - put api("/projects/#{project.id}", user), project_param + put api("/projects/#{project.id}", user), params: project_param expect(response).to have_gitlab_http_status(200) expect(json_response['request_access_enabled']).to eq(false) @@ -1575,7 +1575,7 @@ describe API::Projects do it 'updates path & name to existing path & name in different namespace' do project_param = { path: project4.path, name: project4.name } - put api("/projects/#{project3.id}", user), project_param + put api("/projects/#{project3.id}", user), params: project_param expect(response).to have_gitlab_http_status(200) @@ -1587,7 +1587,7 @@ describe API::Projects do it 'updates jobs_enabled' do project_param = { jobs_enabled: true } - put api("/projects/#{project3.id}", user), project_param + put api("/projects/#{project3.id}", user), params: project_param expect(response).to have_gitlab_http_status(200) @@ -1599,7 +1599,7 @@ describe API::Projects do it 'updates merge_method' do project_param = { merge_method: 'ff' } - put api("/projects/#{project3.id}", user), project_param + put api("/projects/#{project3.id}", user), params: project_param expect(response).to have_gitlab_http_status(200) @@ -1611,7 +1611,7 @@ describe API::Projects do it 'rejects to update merge_method when merge_method is invalid' do project_param = { merge_method: 'invalid' } - put api("/projects/#{project3.id}", user), project_param + put api("/projects/#{project3.id}", user), params: project_param expect(response).to have_gitlab_http_status(400) end @@ -1622,7 +1622,7 @@ describe API::Projects do 'image/gif') } - put api("/projects/#{project3.id}", user), project_param + put api("/projects/#{project3.id}", user), params: project_param expect(response).to have_gitlab_http_status(200) expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\ @@ -1634,7 +1634,7 @@ describe API::Projects do context 'when authenticated as project maintainer' do it 'updates path' do project_param = { path: 'bar' } - put api("/projects/#{project3.id}", user4), project_param + put api("/projects/#{project3.id}", user4), params: project_param expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1649,7 +1649,7 @@ describe API::Projects do merge_method: 'ff', description: 'new description' } - put api("/projects/#{project3.id}", user4), project_param + put api("/projects/#{project3.id}", user4), params: project_param expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1658,20 +1658,20 @@ describe API::Projects do it 'does not update path to existing path' do project_param = { path: project.path } - put api("/projects/#{project3.id}", user4), project_param + put api("/projects/#{project3.id}", user4), params: project_param expect(response).to have_gitlab_http_status(400) expect(json_response['message']['path']).to eq(['has already been taken']) end it 'does not update name' do project_param = { name: 'bar' } - put api("/projects/#{project3.id}", user4), project_param + put api("/projects/#{project3.id}", user4), params: project_param expect(response).to have_gitlab_http_status(403) end it 'does not update visibility_level' do project_param = { visibility: 'public' } - put api("/projects/#{project3.id}", user4), project_param + put api("/projects/#{project3.id}", user4), params: project_param expect(response).to have_gitlab_http_status(403) end end @@ -1685,7 +1685,7 @@ describe API::Projects do merge_requests_enabled: true, description: 'new description', request_access_enabled: true } - put api("/projects/#{project.id}", user3), project_param + put api("/projects/#{project.id}", user3), params: project_param expect(response).to have_gitlab_http_status(403) end end @@ -1971,41 +1971,41 @@ describe API::Projects do end it 'forks with explicit own user namespace id' do - post api("/projects/#{project.id}/fork", user2), namespace: user2.namespace.id + post api("/projects/#{project.id}/fork", user2), params: { namespace: user2.namespace.id } expect(response).to have_gitlab_http_status(201) expect(json_response['owner']['id']).to eq(user2.id) end it 'forks with explicit own user name as namespace' do - post api("/projects/#{project.id}/fork", user2), namespace: user2.username + post api("/projects/#{project.id}/fork", user2), params: { namespace: user2.username } expect(response).to have_gitlab_http_status(201) expect(json_response['owner']['id']).to eq(user2.id) end it 'forks to another user when admin' do - post api("/projects/#{project.id}/fork", admin), namespace: user2.username + post api("/projects/#{project.id}/fork", admin), params: { namespace: user2.username } expect(response).to have_gitlab_http_status(201) expect(json_response['owner']['id']).to eq(user2.id) end it 'fails if trying to fork to another user when not admin' do - post api("/projects/#{project.id}/fork", user2), namespace: admin.namespace.id + post api("/projects/#{project.id}/fork", user2), params: { namespace: admin.namespace.id } expect(response).to have_gitlab_http_status(404) end it 'fails if trying to fork to non-existent namespace' do - post api("/projects/#{project.id}/fork", user2), namespace: 42424242 + post api("/projects/#{project.id}/fork", user2), params: { namespace: 42424242 } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Target Namespace Not Found') end it 'forks to owned group' do - post api("/projects/#{project.id}/fork", user2), namespace: group2.name + post api("/projects/#{project.id}/fork", user2), params: { namespace: group2.name } expect(response).to have_gitlab_http_status(201) expect(json_response['namespace']['name']).to eq(group2.name) @@ -2013,7 +2013,7 @@ describe API::Projects do it 'forks to owned subgroup' do full_path = "#{group2.path}/#{group3.path}" - post api("/projects/#{project.id}/fork", user2), namespace: full_path + post api("/projects/#{project.id}/fork", user2), params: { namespace: full_path } expect(response).to have_gitlab_http_status(201) expect(json_response['namespace']['name']).to eq(group3.name) @@ -2021,13 +2021,13 @@ describe API::Projects do end it 'fails to fork to not owned group' do - post api("/projects/#{project.id}/fork", user2), namespace: group.name + post api("/projects/#{project.id}/fork", user2), params: { namespace: group.name } expect(response).to have_gitlab_http_status(404) end it 'forks to not owned group when admin' do - post api("/projects/#{project.id}/fork", admin), namespace: group.name + post api("/projects/#{project.id}/fork", admin), params: { namespace: group.name } expect(response).to have_gitlab_http_status(201) expect(json_response['namespace']['name']).to eq(group.name) @@ -2100,19 +2100,19 @@ describe API::Projects do it 'transfers the project to the new namespace' do group.add_owner(user) - put api("/projects/#{project.id}/transfer", user), namespace: group.id + put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id } expect(response).to have_gitlab_http_status(200) end it 'fails when transferring to a non owned namespace' do - put api("/projects/#{project.id}/transfer", user), namespace: group.id + put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id } expect(response).to have_gitlab_http_status(404) end it 'fails when transferring to an unknown namespace' do - put api("/projects/#{project.id}/transfer", user), namespace: 'unknown' + put api("/projects/#{project.id}/transfer", user), params: { namespace: 'unknown' } expect(response).to have_gitlab_http_status(404) end diff --git a/spec/requests/api/protected_branches_spec.rb b/spec/requests/api/protected_branches_spec.rb index 69a601d7b40..f90558d77a9 100644 --- a/spec/requests/api/protected_branches_spec.rb +++ b/spec/requests/api/protected_branches_spec.rb @@ -14,7 +14,7 @@ describe API::ProtectedBranches do shared_examples_for 'protected branches' do it 'returns the protected branches' do - get api(route, user), per_page: 100 + get api(route, user), params: { per_page: 100 } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -114,7 +114,7 @@ describe API::ProtectedBranches do end it 'protects a single branch' do - post post_endpoint, name: branch_name + post post_endpoint, params: { name: branch_name } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(branch_name) @@ -123,7 +123,7 @@ describe API::ProtectedBranches do end it 'protects a single branch and developers can push' do - post post_endpoint, name: branch_name, push_access_level: 30 + post post_endpoint, params: { name: branch_name, push_access_level: 30 } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(branch_name) @@ -132,7 +132,7 @@ describe API::ProtectedBranches do end it 'protects a single branch and developers can merge' do - post post_endpoint, name: branch_name, merge_access_level: 30 + post post_endpoint, params: { name: branch_name, merge_access_level: 30 } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(branch_name) @@ -141,7 +141,7 @@ describe API::ProtectedBranches do end it 'protects a single branch and developers can push and merge' do - post post_endpoint, name: branch_name, push_access_level: 30, merge_access_level: 30 + post post_endpoint, params: { name: branch_name, push_access_level: 30, merge_access_level: 30 } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(branch_name) @@ -150,7 +150,7 @@ describe API::ProtectedBranches do end it 'protects a single branch and no one can push' do - post post_endpoint, name: branch_name, push_access_level: 0 + post post_endpoint, params: { name: branch_name, push_access_level: 0 } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(branch_name) @@ -159,7 +159,7 @@ describe API::ProtectedBranches do end it 'protects a single branch and no one can merge' do - post post_endpoint, name: branch_name, merge_access_level: 0 + post post_endpoint, params: { name: branch_name, merge_access_level: 0 } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(branch_name) @@ -168,7 +168,7 @@ describe API::ProtectedBranches do end it 'protects a single branch and no one can push or merge' do - post post_endpoint, name: branch_name, push_access_level: 0, merge_access_level: 0 + post post_endpoint, params: { name: branch_name, push_access_level: 0, merge_access_level: 0 } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(branch_name) @@ -177,7 +177,7 @@ describe API::ProtectedBranches do end it 'returns a 409 error if the same branch is protected twice' do - post post_endpoint, name: protected_name + post post_endpoint, params: { name: protected_name } expect(response).to have_gitlab_http_status(409) end @@ -186,7 +186,7 @@ describe API::ProtectedBranches do let(:branch_name) { 'feature/*' } it "protects multiple branches with a wildcard in the name" do - post post_endpoint, name: branch_name + post post_endpoint, params: { name: branch_name } expect_protection_to_be_successful expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER) @@ -201,7 +201,7 @@ describe API::ProtectedBranches do end it "prevents deletion of the protected branch rule" do - post post_endpoint, name: branch_name + post post_endpoint, params: { name: branch_name } expect(response).to have_gitlab_http_status(403) end @@ -214,7 +214,7 @@ describe API::ProtectedBranches do end it "returns a 403 error if guest" do - post post_endpoint, name: branch_name + post post_endpoint, params: { name: branch_name } expect(response).to have_gitlab_http_status(403) end diff --git a/spec/requests/api/protected_tags_spec.rb b/spec/requests/api/protected_tags_spec.rb index f4f3ef31bc3..41363dcc1c3 100644 --- a/spec/requests/api/protected_tags_spec.rb +++ b/spec/requests/api/protected_tags_spec.rb @@ -15,7 +15,7 @@ describe API::ProtectedTags do shared_examples_for 'protected tags' do it 'returns the protected tags' do - get api(route, user), per_page: 100 + get api(route, user), params: { per_page: 100 } expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers @@ -102,7 +102,7 @@ describe API::ProtectedTags do end it 'protects a single tag with maintainers can create tags' do - post api("/projects/#{project.id}/protected_tags", user), name: tag_name + post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(tag_name) @@ -111,7 +111,7 @@ describe API::ProtectedTags do it 'protects a single tag with developers can create tags' do post api("/projects/#{project.id}/protected_tags", user), - name: tag_name, create_access_level: 30 + params: { name: tag_name, create_access_level: 30 } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(tag_name) @@ -120,7 +120,7 @@ describe API::ProtectedTags do it 'protects a single tag with no one can create tags' do post api("/projects/#{project.id}/protected_tags", user), - name: tag_name, create_access_level: 0 + params: { name: tag_name, create_access_level: 0 } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(tag_name) @@ -128,15 +128,15 @@ describe API::ProtectedTags do end it 'returns a 422 error if the same tag is protected twice' do - post api("/projects/#{project.id}/protected_tags", user), name: protected_name + post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name } expect(response).to have_gitlab_http_status(422) expect(json_response['message'][0]).to eq('Name has already been taken') end it 'returns 201 if the same tag is proteted on different projects' do - post api("/projects/#{project.id}/protected_tags", user), name: protected_name - post api("/projects/#{project2.id}/protected_tags", user), name: protected_name + post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name } + post api("/projects/#{project2.id}/protected_tags", user), params: { name: protected_name } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(protected_name) @@ -146,7 +146,7 @@ describe API::ProtectedTags do let(:tag_name) { 'feature/*' } it 'protects multiple tags with a wildcard in the name' do - post api("/projects/#{project.id}/protected_tags", user), name: tag_name + post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(tag_name) @@ -161,7 +161,7 @@ describe API::ProtectedTags do end it 'returns a 403 error if guest' do - post api("/projects/#{project.id}/protected_tags/", user), name: tag_name + post api("/projects/#{project.id}/protected_tags/", user), params: { name: tag_name } expect(response).to have_gitlab_http_status(403) end diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index de141377793..181fe6246ae 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -297,7 +297,7 @@ describe API::Repositories do expect(::Gitlab::Git::Compare).to receive(:new).with(anything, anything, anything, { straight: false }).and_call_original - get api(route, current_user), from: 'master', to: 'feature' + get api(route, current_user), params: { from: 'master', to: 'feature' } expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present @@ -308,7 +308,7 @@ describe API::Repositories do expect(::Gitlab::Git::Compare).to receive(:new).with(anything, anything, anything, { straight: false }).and_call_original - get api(route, current_user), from: 'master', to: 'feature', straight: false + get api(route, current_user), params: { from: 'master', to: 'feature', straight: false } expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present @@ -319,7 +319,7 @@ describe API::Repositories do expect(::Gitlab::Git::Compare).to receive(:new).with(anything, anything, anything, { straight: true }).and_call_original - get api(route, current_user), from: 'master', to: 'feature', straight: true + get api(route, current_user), params: { from: 'master', to: 'feature', straight: true } expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present @@ -327,7 +327,7 @@ describe API::Repositories do end it "compares tags" do - get api(route, current_user), from: 'v1.0.0', to: 'v1.1.0' + get api(route, current_user), params: { from: 'v1.0.0', to: 'v1.1.0' } expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present @@ -335,7 +335,7 @@ describe API::Repositories do end it "compares commits" do - get api(route, current_user), from: sample_commit.id, to: sample_commit.parent_id + get api(route, current_user), params: { from: sample_commit.id, to: sample_commit.parent_id } expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty @@ -344,7 +344,7 @@ describe API::Repositories do end it "compares commits in reverse order" do - get api(route, current_user), from: sample_commit.parent_id, to: sample_commit.id + get api(route, current_user), params: { from: sample_commit.parent_id, to: sample_commit.id } expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present @@ -352,7 +352,7 @@ describe API::Repositories do end it "compares same refs" do - get api(route, current_user), from: 'master', to: 'master' + get api(route, current_user), params: { from: 'master', to: 'master' } expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty @@ -410,7 +410,7 @@ describe API::Repositories do context 'using sorting' do context 'by commits desc' do it 'returns the repository contribuors sorted by commits desc' do - get api(route, current_user), { order_by: 'commits', sort: 'desc' } + get api(route, current_user), params: { order_by: 'commits', sort: 'desc' } expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('contributors') @@ -420,7 +420,7 @@ describe API::Repositories do context 'by name desc' do it 'returns the repository contribuors sorted by name asc case insensitive' do - get api(route, current_user), { order_by: 'name', sort: 'asc' } + get api(route, current_user), params: { order_by: 'name', sort: 'asc' } expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('contributors') @@ -478,7 +478,7 @@ describe API::Repositories do end subject(:request) do - get(api("/projects/#{project.id}/repository/merge_base", current_user), refs: refs) + get(api("/projects/#{project.id}/repository/merge_base", current_user), params: { refs: refs }) end shared_examples 'merge base' do diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index b36087b86a7..c63621fe7d1 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -25,7 +25,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when invalid token is provided' do it 'returns 403 error' do - post api('/runners'), token: 'invalid' + post api('/runners'), params: { token: 'invalid' } expect(response).to have_gitlab_http_status 403 end @@ -33,7 +33,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when valid token is provided' do it 'creates runner with default values' do - post api('/runners'), token: registration_token + post api('/runners'), params: { token: registration_token } runner = Ci::Runner.first @@ -50,7 +50,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:project) { create(:project) } it 'creates project runner' do - post api('/runners'), token: project.runners_token + post api('/runners'), params: { token: project.runners_token } expect(response).to have_gitlab_http_status 201 expect(project.runners.size).to eq(1) @@ -65,7 +65,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:group) { create(:group) } it 'creates a group runner' do - post api('/runners'), token: group.runners_token + post api('/runners'), params: { token: group.runners_token } expect(response).to have_http_status 201 expect(group.runners.size).to eq(1) @@ -79,8 +79,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when runner description is provided' do it 'creates runner' do - post api('/runners'), token: registration_token, - description: 'server.hostname' + post api('/runners'), params: { + token: registration_token, + description: 'server.hostname' + } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.description).to eq('server.hostname') @@ -89,8 +91,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when runner tags are provided' do it 'creates runner' do - post api('/runners'), token: registration_token, - tag_list: 'tag1, tag2' + post api('/runners'), params: { + token: registration_token, + tag_list: 'tag1, tag2' + } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.tag_list.sort).to eq(%w(tag1 tag2)) @@ -100,9 +104,11 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when option for running untagged jobs is provided' do context 'when tags are provided' do it 'creates runner' do - post api('/runners'), token: registration_token, - run_untagged: false, - tag_list: ['tag'] + post api('/runners'), params: { + token: registration_token, + run_untagged: false, + tag_list: ['tag'] + } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.run_untagged).to be false @@ -112,8 +118,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when tags are not provided' do it 'returns 400 error' do - post api('/runners'), token: registration_token, - run_untagged: false + post api('/runners'), params: { + token: registration_token, + run_untagged: false + } expect(response).to have_gitlab_http_status 400 expect(json_response['message']).to include( @@ -124,8 +132,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when option for locking Runner is provided' do it 'creates runner' do - post api('/runners'), token: registration_token, - locked: true + post api('/runners'), params: { + token: registration_token, + locked: true + } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.locked).to be true @@ -135,8 +145,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when option for activating a Runner is provided' do context 'when active is set to true' do it 'creates runner' do - post api('/runners'), token: registration_token, - active: true + post api('/runners'), params: { + token: registration_token, + active: true + } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.active).to be true @@ -145,8 +157,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when active is set to false' do it 'creates runner' do - post api('/runners'), token: registration_token, - active: false + post api('/runners'), params: { + token: registration_token, + active: false + } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.active).to be false @@ -156,8 +170,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when maximum job timeout is specified' do it 'creates runner' do - post api('/runners'), token: registration_token, - maximum_timeout: 9000 + post api('/runners'), params: { + token: registration_token, + maximum_timeout: 9000 + } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.maximum_timeout).to eq(9000) @@ -165,8 +181,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when maximum job timeout is empty' do it 'creates runner' do - post api('/runners'), token: registration_token, - maximum_timeout: '' + post api('/runners'), params: { + token: registration_token, + maximum_timeout: '' + } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.maximum_timeout).to be_nil @@ -179,8 +197,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:value) { "#{param}_value" } it "updates provided Runner's parameter" do - post api('/runners'), token: registration_token, - info: { param => value } + post api('/runners'), params: { + token: registration_token, + info: { param => value } + } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.read_attribute(param.to_sym)).to eq(value) @@ -190,8 +210,8 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it "sets the runner's ip_address" do post api('/runners'), - { token: registration_token }, - { 'REMOTE_ADDR' => '123.111.123.111' } + params: { token: registration_token }, + headers: { 'REMOTE_ADDR' => '123.111.123.111' } expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.ip_address).to eq('123.111.123.111') @@ -209,7 +229,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when invalid token is provided' do it 'returns 403 error' do - delete api('/runners'), token: 'invalid' + delete api('/runners'), params: { token: 'invalid' } expect(response).to have_gitlab_http_status 403 end @@ -219,7 +239,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:runner) { create(:ci_runner) } it 'deletes Runner' do - delete api('/runners'), token: runner.token + delete api('/runners'), params: { token: runner.token } expect(response).to have_gitlab_http_status 204 expect(Ci::Runner.count).to eq(0) @@ -245,7 +265,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when invalid token is provided' do it 'returns 403 error' do - post api('/runners/verify'), token: 'invalid-token' + post api('/runners/verify'), params: { token: 'invalid-token' } expect(response).to have_gitlab_http_status 403 end @@ -253,7 +273,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when valid token is provided' do it 'verifies Runner credentials' do - post api('/runners/verify'), token: runner.token + post api('/runners/verify'), params: { token: runner.token } expect(response).to have_gitlab_http_status 200 end @@ -342,7 +362,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when invalid token is provided' do it 'returns 403 error' do - post api('/jobs/request'), token: 'invalid' + post api('/jobs/request'), params: { token: 'invalid' } expect(response).to have_gitlab_http_status 403 end @@ -499,8 +519,8 @@ describe API::Runner, :clean_gitlab_redis_shared_state do it "sets the runner's ip_address" do post api('/jobs/request'), - { token: runner.token }, - { 'User-Agent' => user_agent, 'REMOTE_ADDR' => '123.222.123.222' } + params: { token: runner.token }, + headers: { 'User-Agent' => user_agent, 'REMOTE_ADDR' => '123.222.123.222' } expect(response).to have_gitlab_http_status 201 expect(runner.reload.ip_address).to eq('123.222.123.222') @@ -752,7 +772,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do def request_job(token = runner.token, **params) new_params = params.merge(token: token, last_update: last_update) - post api('/jobs/request'), new_params, { 'User-Agent' => user_agent } + post api('/jobs/request'), params: new_params, headers: { 'User-Agent' => user_agent } end end end @@ -893,7 +913,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do def update_job(token = job.token, **params) new_params = params.merge(token: token) - put api("/jobs/#{job.id}"), new_params + put api("/jobs/#{job.id}"), params: new_params end def update_job_after_time(update_interval = 20.minutes, state = 'running') @@ -1113,7 +1133,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end Timecop.travel(job.updated_at + update_interval) do - patch api("/jobs/#{job.id}/trace"), content, request_headers + patch api("/jobs/#{job.id}/trace"), params: content, headers: request_headers job.reload end end @@ -1244,7 +1264,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do end def authorize_artifacts(params = {}, request_headers = headers) - post api("/jobs/#{job.id}/artifacts/authorize"), params, request_headers + post api("/jobs/#{job.id}/artifacts/authorize"), params: params, headers: request_headers end def authorize_artifacts_with_token_in_params(params = {}, request_headers = headers) @@ -1347,7 +1367,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'when artifacts post request does not contain file' do it 'fails to post artifacts without file' do - post api("/jobs/#{job.id}/artifacts"), {}, headers_with_token + post api("/jobs/#{job.id}/artifacts"), params: {}, headers: headers_with_token expect(response).to have_gitlab_http_status(400) end @@ -1355,7 +1375,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do context 'GitLab Workhorse is not configured' do it 'fails to post artifacts without GitLab-Workhorse' do - post api("/jobs/#{job.id}/artifacts"), { token: job.token }, {} + post api("/jobs/#{job.id}/artifacts"), params: { token: job.token }, headers: {} expect(response).to have_gitlab_http_status(403) end @@ -1372,7 +1392,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do before do stub_application_setting(default_artifacts_expire_in: default_artifacts_expire_in) - post(api("/jobs/#{job.id}/artifacts"), post_data, headers_with_token) + post(api("/jobs/#{job.id}/artifacts"), params: post_data, headers: headers_with_token) end context 'when an expire_in is given' do @@ -1427,7 +1447,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do let(:stored_metadata_sha256) { job.reload.job_artifacts_metadata.file_sha256 } before do - post(api("/jobs/#{job.id}/artifacts"), post_data, headers_with_token) + post(api("/jobs/#{job.id}/artifacts"), params: post_data, headers: headers_with_token) end context 'when posts data accelerated by workhorse is correct' do @@ -1545,7 +1565,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do 'file.name' => file.original_filename }) - post api("/jobs/#{job.id}/artifacts"), params, headers + post api("/jobs/#{job.id}/artifacts"), params: params, headers: headers end end @@ -1631,7 +1651,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do params = params.merge(token: token) job.reload - get api("/jobs/#{job.id}/artifacts"), params, request_headers + get api("/jobs/#{job.id}/artifacts"), params: params, headers: request_headers end end end diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 49a79d2ccf9..7f11c8c9fe8 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -400,14 +400,14 @@ describe API::Runners do end def update_runner(id, user, args) - put api("/runners/#{id}", user), args + put api("/runners/#{id}", user), params: args end end context 'authorized user' do context 'when runner is shared' do it 'does not update runner' do - put api("/runners/#{shared_runner.id}", user), description: 'test' + put api("/runners/#{shared_runner.id}", user), params: { description: 'test' } expect(response).to have_gitlab_http_status(403) end @@ -415,14 +415,14 @@ describe API::Runners do context 'when runner is not shared' do it 'does not update project runner without access to it' do - put api("/runners/#{project_runner.id}", user2), description: 'test' + put api("/runners/#{project_runner.id}", user2), params: { description: 'test' } expect(response).to have_http_status(403) end it 'updates project runner with access to it' do description = project_runner.description - put api("/runners/#{project_runner.id}", admin), description: 'test' + put api("/runners/#{project_runner.id}", admin), params: { description: 'test' } project_runner.reload expect(response).to have_gitlab_http_status(200) @@ -741,14 +741,14 @@ describe API::Runners do it 'enables specific runner' do expect do - post api("/projects/#{project.id}/runners", user), runner_id: project_runner2.id + post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id } end.to change { project.runners.count }.by(+1) expect(response).to have_gitlab_http_status(201) end it 'avoids changes when enabling already enabled runner' do expect do - post api("/projects/#{project.id}/runners", user), runner_id: project_runner.id + post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner.id } end.to change { project.runners.count }.by(0) expect(response).to have_gitlab_http_status(400) end @@ -757,20 +757,20 @@ describe API::Runners do project_runner2.update(locked: true) expect do - post api("/projects/#{project.id}/runners", user), runner_id: project_runner2.id + post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id } end.to change { project.runners.count }.by(0) expect(response).to have_gitlab_http_status(403) end it 'does not enable shared runner' do - post api("/projects/#{project.id}/runners", user), runner_id: shared_runner.id + post api("/projects/#{project.id}/runners", user), params: { runner_id: shared_runner.id } expect(response).to have_gitlab_http_status(403) end it 'does not enable group runner' do - post api("/projects/#{project.id}/runners", user), runner_id: group_runner.id + post api("/projects/#{project.id}/runners", user), params: { runner_id: group_runner.id } expect(response).to have_http_status(403) end @@ -781,7 +781,7 @@ describe API::Runners do it 'enables any specific runner' do expect do - post api("/projects/#{project.id}/runners", admin), runner_id: new_project_runner.id + post api("/projects/#{project.id}/runners", admin), params: { runner_id: new_project_runner.id } end.to change { project.runners.count }.by(+1) expect(response).to have_gitlab_http_status(201) end @@ -789,7 +789,7 @@ describe API::Runners do it 'enables a instance type runner' do expect do - post api("/projects/#{project.id}/runners", admin), runner_id: shared_runner.id + post api("/projects/#{project.id}/runners", admin), params: { runner_id: shared_runner.id } end.to change { project.runners.count }.by(1) expect(shared_runner.reload).not_to be_instance_type @@ -808,7 +808,7 @@ describe API::Runners do let!(:new_project_runner) { create(:ci_runner, :project) } it 'does not enable runner without access to' do - post api("/projects/#{project.id}/runners", user), runner_id: new_project_runner.id + post api("/projects/#{project.id}/runners", user), params: { runner_id: new_project_runner.id } expect(response).to have_gitlab_http_status(403) end diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb index f8e468be170..831f47debeb 100644 --- a/spec/requests/api/search_spec.rb +++ b/spec/requests/api/search_spec.rb @@ -16,7 +16,7 @@ describe API::Search do describe 'GET /search' do context 'when user is not authenticated' do it 'returns 401 error' do - get api('/search'), scope: 'projects', search: 'awesome' + get api('/search'), params: { scope: 'projects', search: 'awesome' } expect(response).to have_gitlab_http_status(401) end @@ -24,7 +24,7 @@ describe API::Search do context 'when scope is not supported' do it 'returns 400 error' do - get api('/search', user), scope: 'unsupported', search: 'awesome' + get api('/search', user), params: { scope: 'unsupported', search: 'awesome' } expect(response).to have_gitlab_http_status(400) end @@ -32,7 +32,7 @@ describe API::Search do context 'when scope is missing' do it 'returns 400 error' do - get api('/search', user), search: 'awesome' + get api('/search', user), params: { search: 'awesome' } expect(response).to have_gitlab_http_status(400) end @@ -41,7 +41,7 @@ describe API::Search do context 'with correct params' do context 'for projects scope' do before do - get api('/search', user), scope: 'projects', search: 'awesome' + get api('/search', user), params: { scope: 'projects', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/projects' @@ -51,7 +51,7 @@ describe API::Search do before do create(:issue, project: project, title: 'awesome issue') - get api('/search', user), scope: 'issues', search: 'awesome' + get api('/search', user), params: { scope: 'issues', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/issues' @@ -61,7 +61,7 @@ describe API::Search do before do create(:merge_request, source_project: repo_project, title: 'awesome mr') - get api('/search', user), scope: 'merge_requests', search: 'awesome' + get api('/search', user), params: { scope: 'merge_requests', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests' @@ -71,7 +71,7 @@ describe API::Search do before do create(:milestone, project: project, title: 'awesome milestone') - get api('/search', user), scope: 'milestones', search: 'awesome' + get api('/search', user), params: { scope: 'milestones', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' @@ -81,7 +81,7 @@ describe API::Search do before do create(:snippet, :public, title: 'awesome snippet', content: 'snippet content') - get api('/search', user), scope: 'snippet_titles', search: 'awesome' + get api('/search', user), params: { scope: 'snippet_titles', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/snippets' @@ -91,7 +91,7 @@ describe API::Search do before do create(:snippet, :public, title: 'awesome snippet', content: 'snippet content') - get api('/search', user), scope: 'snippet_blobs', search: 'content' + get api('/search', user), params: { scope: 'snippet_blobs', search: 'content' } end it_behaves_like 'response is correct', schema: 'public_api/v4/snippets' @@ -102,7 +102,7 @@ describe API::Search do describe "GET /groups/:id/search" do context 'when user is not authenticated' do it 'returns 401 error' do - get api("/groups/#{group.id}/search"), scope: 'projects', search: 'awesome' + get api("/groups/#{group.id}/search"), params: { scope: 'projects', search: 'awesome' } expect(response).to have_gitlab_http_status(401) end @@ -110,7 +110,7 @@ describe API::Search do context 'when scope is not supported' do it 'returns 400 error' do - get api("/groups/#{group.id}/search", user), scope: 'unsupported', search: 'awesome' + get api("/groups/#{group.id}/search", user), params: { scope: 'unsupported', search: 'awesome' } expect(response).to have_gitlab_http_status(400) end @@ -118,7 +118,7 @@ describe API::Search do context 'when scope is missing' do it 'returns 400 error' do - get api("/groups/#{group.id}/search", user), search: 'awesome' + get api("/groups/#{group.id}/search", user), params: { search: 'awesome' } expect(response).to have_gitlab_http_status(400) end @@ -126,7 +126,7 @@ describe API::Search do context 'when group does not exist' do it 'returns 404 error' do - get api('/groups/9999/search', user), scope: 'issues', search: 'awesome' + get api('/groups/9999/search', user), params: { scope: 'issues', search: 'awesome' } expect(response).to have_gitlab_http_status(404) end @@ -136,7 +136,7 @@ describe API::Search do it 'returns 404 error' do private_group = create(:group, :private) - get api("/groups/#{private_group.id}/search", user), scope: 'issues', search: 'awesome' + get api("/groups/#{private_group.id}/search", user), params: { scope: 'issues', search: 'awesome' } expect(response).to have_gitlab_http_status(404) end @@ -145,7 +145,7 @@ describe API::Search do context 'with correct params' do context 'for projects scope' do before do - get api("/groups/#{group.id}/search", user), scope: 'projects', search: 'awesome' + get api("/groups/#{group.id}/search", user), params: { scope: 'projects', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/projects' @@ -155,7 +155,7 @@ describe API::Search do before do create(:issue, project: project, title: 'awesome issue') - get api("/groups/#{group.id}/search", user), scope: 'issues', search: 'awesome' + get api("/groups/#{group.id}/search", user), params: { scope: 'issues', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/issues' @@ -165,7 +165,7 @@ describe API::Search do before do create(:merge_request, source_project: repo_project, title: 'awesome mr') - get api("/groups/#{group.id}/search", user), scope: 'merge_requests', search: 'awesome' + get api("/groups/#{group.id}/search", user), params: { scope: 'merge_requests', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests' @@ -175,7 +175,7 @@ describe API::Search do before do create(:milestone, project: project, title: 'awesome milestone') - get api("/groups/#{group.id}/search", user), scope: 'milestones', search: 'awesome' + get api("/groups/#{group.id}/search", user), params: { scope: 'milestones', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' @@ -187,7 +187,7 @@ describe API::Search do create(:milestone, project: project, title: 'awesome milestone') create(:milestone, project: another_project, title: 'awesome milestone other project') - get api("/groups/#{CGI.escape(group.full_path)}/search", user), scope: 'milestones', search: 'awesome' + get api("/groups/#{CGI.escape(group.full_path)}/search", user), params: { scope: 'milestones', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' @@ -198,7 +198,7 @@ describe API::Search do describe "GET /projects/:id/search" do context 'when user is not authenticated' do it 'returns 401 error' do - get api("/projects/#{project.id}/search"), scope: 'issues', search: 'awesome' + get api("/projects/#{project.id}/search"), params: { scope: 'issues', search: 'awesome' } expect(response).to have_gitlab_http_status(401) end @@ -206,7 +206,7 @@ describe API::Search do context 'when scope is not supported' do it 'returns 400 error' do - get api("/projects/#{project.id}/search", user), scope: 'unsupported', search: 'awesome' + get api("/projects/#{project.id}/search", user), params: { scope: 'unsupported', search: 'awesome' } expect(response).to have_gitlab_http_status(400) end @@ -214,7 +214,7 @@ describe API::Search do context 'when scope is missing' do it 'returns 400 error' do - get api("/projects/#{project.id}/search", user), search: 'awesome' + get api("/projects/#{project.id}/search", user), params: { search: 'awesome' } expect(response).to have_gitlab_http_status(400) end @@ -222,7 +222,7 @@ describe API::Search do context 'when project does not exist' do it 'returns 404 error' do - get api('/projects/9999/search', user), scope: 'issues', search: 'awesome' + get api('/projects/9999/search', user), params: { scope: 'issues', search: 'awesome' } expect(response).to have_gitlab_http_status(404) end @@ -232,7 +232,7 @@ describe API::Search do it 'returns 404 error' do project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE) - get api("/projects/#{project.id}/search", user), scope: 'issues', search: 'awesome' + get api("/projects/#{project.id}/search", user), params: { scope: 'issues', search: 'awesome' } expect(response).to have_gitlab_http_status(404) end @@ -243,7 +243,7 @@ describe API::Search do before do create(:issue, project: project, title: 'awesome issue') - get api("/projects/#{project.id}/search", user), scope: 'issues', search: 'awesome' + get api("/projects/#{project.id}/search", user), params: { scope: 'issues', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/issues' @@ -253,7 +253,7 @@ describe API::Search do before do create(:merge_request, source_project: repo_project, title: 'awesome mr') - get api("/projects/#{repo_project.id}/search", user), scope: 'merge_requests', search: 'awesome' + get api("/projects/#{repo_project.id}/search", user), params: { scope: 'merge_requests', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests' @@ -263,7 +263,7 @@ describe API::Search do before do create(:milestone, project: project, title: 'awesome milestone') - get api("/projects/#{project.id}/search", user), scope: 'milestones', search: 'awesome' + get api("/projects/#{project.id}/search", user), params: { scope: 'milestones', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/milestones' @@ -273,7 +273,7 @@ describe API::Search do before do create(:note_on_merge_request, project: project, note: 'awesome note') - get api("/projects/#{project.id}/search", user), scope: 'notes', search: 'awesome' + get api("/projects/#{project.id}/search", user), params: { scope: 'notes', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/notes' @@ -284,7 +284,7 @@ describe API::Search do wiki = create(:project_wiki, project: project) create(:wiki_page, wiki: wiki, attrs: { title: 'home', content: "Awesome page" }) - get api("/projects/#{project.id}/search", user), scope: 'wiki_blobs', search: 'awesome' + get api("/projects/#{project.id}/search", user), params: { scope: 'wiki_blobs', search: 'awesome' } end it_behaves_like 'response is correct', schema: 'public_api/v4/blobs' @@ -292,7 +292,7 @@ describe API::Search do context 'for commits scope' do before do - get api("/projects/#{repo_project.id}/search", user), scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6' + get api("/projects/#{repo_project.id}/search", user), params: { scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6' } end it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details' @@ -300,7 +300,7 @@ describe API::Search do context 'for commits scope with project path as id' do before do - get api("/projects/#{CGI.escape(repo_project.full_path)}/search", user), scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6' + get api("/projects/#{CGI.escape(repo_project.full_path)}/search", user), params: { scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6' } end it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details' @@ -308,14 +308,14 @@ describe API::Search do context 'for blobs scope' do before do - get api("/projects/#{repo_project.id}/search", user), scope: 'blobs', search: 'monitors' + get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'monitors' } end it_behaves_like 'response is correct', schema: 'public_api/v4/blobs', size: 2 context 'filters' do it 'by filename' do - get api("/projects/#{repo_project.id}/search", user), scope: 'blobs', search: 'mon filename:PROCESS.md' + get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon filename:PROCESS.md' } expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) @@ -323,14 +323,14 @@ describe API::Search do end it 'by path' do - get api("/projects/#{repo_project.id}/search", user), scope: 'blobs', search: 'mon path:markdown' + get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon path:markdown' } expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(8) end it 'by extension' do - get api("/projects/#{repo_project.id}/search", user), scope: 'blobs', search: 'mon extension:md' + get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon extension:md' } expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(11) diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index 236f8d7faf5..e260aa21e25 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -14,7 +14,7 @@ describe API::Services do include_context service it "updates #{service} settings" do - put api("/projects/#{project.id}/services/#{dashed_service}", user), service_attrs + put api("/projects/#{project.id}/services/#{dashed_service}", user), params: service_attrs expect(response).to have_gitlab_http_status(200) @@ -22,7 +22,7 @@ describe API::Services do event = current_service.event_names.empty? ? "foo" : current_service.event_names.first state = current_service[event] || false - put api("/projects/#{project.id}/services/#{dashed_service}?#{event}=#{!state}", user), service_attrs + put api("/projects/#{project.id}/services/#{dashed_service}?#{event}=#{!state}", user), params: service_attrs expect(response).to have_gitlab_http_status(200) expect(project.services.first[event]).not_to eq(state) unless event == "foo" @@ -44,7 +44,7 @@ describe API::Services do expected_code = 400 end - put api("/projects/#{project.id}/services/#{dashed_service}", user), attrs + put api("/projects/#{project.id}/services/#{dashed_service}", user), params: attrs expect(response.status).to eq(expected_code) end @@ -127,7 +127,7 @@ describe API::Services do end it 'when the service is inactive' do - post api("/projects/#{project.id}/services/#{service_name}/trigger"), params + post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params expect(response).to have_gitlab_http_status(404) end @@ -142,7 +142,7 @@ describe API::Services do end it 'returns status 200' do - post api("/projects/#{project.id}/services/#{service_name}/trigger"), params + post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params expect(response).to have_gitlab_http_status(200) end @@ -150,7 +150,7 @@ describe API::Services do context 'when the project can not be found' do it 'returns a generic 404' do - post api("/projects/404/services/#{service_name}/trigger"), params + post api("/projects/404/services/#{service_name}/trigger"), params: params expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to eq("404 Service Not Found") @@ -170,7 +170,7 @@ describe API::Services do end it 'returns status 200' do - post api("/projects/#{project.id}/services/#{service_name}/trigger"), token: 'token', text: 'help' + post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: { token: 'token', text: 'help' } expect(response).to have_gitlab_http_status(200) expect(json_response['response_type']).to eq("ephemeral") @@ -192,7 +192,7 @@ describe API::Services do end it 'accepts a username for update' do - put api("/projects/#{project.id}/services/mattermost", user), params.merge(username: 'new_username') + put api("/projects/#{project.id}/services/mattermost", user), params: params.merge(username: 'new_username') expect(response).to have_gitlab_http_status(200) expect(json_response['properties']['username']).to eq('new_username') diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index 84c7210f6bb..cfbda63bb30 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -42,27 +42,29 @@ describe API::Settings, 'Settings' do it "updates application settings" do put api("/application/settings", admin), - default_projects_limit: 3, - password_authentication_enabled_for_web: false, - repository_storages: ['custom'], - plantuml_enabled: true, - plantuml_url: 'http://plantuml.example.com', - default_snippet_visibility: 'internal', - restricted_visibility_levels: ['public'], - default_artifacts_expire_in: '2 days', - help_page_text: 'custom help text', - help_page_hide_commercial_content: true, - help_page_support_url: 'http://example.com/help', - project_export_enabled: false, - rsa_key_restriction: ApplicationSetting::FORBIDDEN_KEY_VALUE, - dsa_key_restriction: 2048, - ecdsa_key_restriction: 384, - ed25519_key_restriction: 256, - enforce_terms: true, - terms: 'Hello world!', - performance_bar_allowed_group_path: group.full_path, - instance_statistics_visibility_private: true, - diff_max_patch_bytes: 150_000 + params: { + default_projects_limit: 3, + password_authentication_enabled_for_web: false, + repository_storages: ['custom'], + plantuml_enabled: true, + plantuml_url: 'http://plantuml.example.com', + default_snippet_visibility: 'internal', + restricted_visibility_levels: ['public'], + default_artifacts_expire_in: '2 days', + help_page_text: 'custom help text', + help_page_hide_commercial_content: true, + help_page_support_url: 'http://example.com/help', + project_export_enabled: false, + rsa_key_restriction: ApplicationSetting::FORBIDDEN_KEY_VALUE, + dsa_key_restriction: 2048, + ecdsa_key_restriction: 384, + ed25519_key_restriction: 256, + enforce_terms: true, + terms: 'Hello world!', + performance_bar_allowed_group_path: group.full_path, + instance_statistics_visibility_private: true, + diff_max_patch_bytes: 150_000 + } expect(response).to have_gitlab_http_status(200) expect(json_response['default_projects_limit']).to eq(3) @@ -91,7 +93,7 @@ describe API::Settings, 'Settings' do it "supports legacy performance_bar_allowed_group_id" do put api("/application/settings", admin), - performance_bar_allowed_group_id: group.full_path + params: { performance_bar_allowed_group_id: group.full_path } expect(response).to have_gitlab_http_status(200) expect(json_response['performance_bar_allowed_group_id']).to eq(group.id) @@ -99,8 +101,10 @@ describe API::Settings, 'Settings' do it "supports legacy performance_bar_enabled" do put api("/application/settings", admin), - performance_bar_enabled: false, - performance_bar_allowed_group_id: group.full_path + params: { + performance_bar_enabled: false, + performance_bar_allowed_group_id: group.full_path + } expect(response).to have_gitlab_http_status(200) expect(json_response['performance_bar_allowed_group_id']).to be_nil @@ -108,7 +112,7 @@ describe API::Settings, 'Settings' do context "missing plantuml_url value when plantuml_enabled is true" do it "returns a blank parameter error message" do - put api("/application/settings", admin), plantuml_enabled: true + put api("/application/settings", admin), params: { plantuml_enabled: true } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('plantuml_url is missing') diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index c546ba3e127..7c8512f7589 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -143,7 +143,7 @@ describe API::Snippets do it 'creates a new snippet' do expect do - post api("/snippets/", user), params + post api("/snippets/", user), params: params end.to change { PersonalSnippet.count }.by(1) expect(response).to have_gitlab_http_status(201) @@ -156,14 +156,14 @@ describe API::Snippets do it 'returns 400 for missing parameters' do params.delete(:title) - post api("/snippets/", user), params + post api("/snippets/", user), params: params expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do def create_snippet(snippet_params = {}) - post api('/snippets', user), params.merge(snippet_params) + post api('/snippets', user), params: params.merge(snippet_params) end before do @@ -205,7 +205,7 @@ describe API::Snippets do new_content = 'New content' new_description = 'New description' - put api("/snippets/#{snippet.id}", user), content: new_content, description: new_description + put api("/snippets/#{snippet.id}", user), params: { content: new_content, description: new_description } expect(response).to have_gitlab_http_status(200) snippet.reload @@ -214,14 +214,14 @@ describe API::Snippets do end it 'returns 404 for invalid snippet id' do - put api("/snippets/1234", user), title: 'foo' + put api("/snippets/1234", user), params: { title: 'foo' } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it "returns 404 for another user's snippet" do - put api("/snippets/#{snippet.id}", other_user), title: 'fubar' + put api("/snippets/#{snippet.id}", other_user), params: { title: 'fubar' } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') @@ -235,7 +235,7 @@ describe API::Snippets do context 'when the snippet is spam' do def update_snippet(snippet_params = {}) - put api("/snippets/#{snippet.id}", user), snippet_params + put api("/snippets/#{snippet.id}", user), params: snippet_params end before do diff --git a/spec/requests/api/submodules_spec.rb b/spec/requests/api/submodules_spec.rb index fa447c028c2..c482a85c68f 100644 --- a/spec/requests/api/submodules_spec.rb +++ b/spec/requests/api/submodules_spec.rb @@ -31,7 +31,7 @@ describe API::Submodules do describe "PUT /projects/:id/repository/submodule/:submodule" do context 'when unauthenticated' do it 'returns 401' do - put api(route(submodule)), params + put api(route(submodule)), params: params expect(response).to have_gitlab_http_status(401) end @@ -39,7 +39,7 @@ describe API::Submodules do context 'when authenticated', 'as a guest' do it 'returns 403' do - put api(route(submodule), guest), params + put api(route(submodule), guest), params: params expect(response).to have_gitlab_http_status(403) end @@ -53,13 +53,13 @@ describe API::Submodules do end it 'returns 400 if branch is missing' do - put api(route(submodule), user), params.except(:branch) + put api(route(submodule), user), params: params.except(:branch) expect(response).to have_gitlab_http_status(400) end it 'returns 400 if commit_sha is missing' do - put api(route(submodule), user), params.except(:commit_sha) + put api(route(submodule), user), params: params.except(:commit_sha) expect(response).to have_gitlab_http_status(400) end @@ -67,7 +67,7 @@ describe API::Submodules do it 'returns the commmit' do head_commit = project.repository.commit.id - put api(route(submodule), user), params + put api(route(submodule), user), params: params expect(response).to have_gitlab_http_status(200) expect(json_response['message']).to eq commit_message @@ -87,7 +87,7 @@ describe API::Submodules do .with(any_args, hash_including(submodule: submodule)) .and_call_original - put api(route(encoded_submodule), user), params + put api(route(encoded_submodule), user), params: params expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq project.repository.commit(branch).id diff --git a/spec/requests/api/suggestions_spec.rb b/spec/requests/api/suggestions_spec.rb index 8e9f737fbd5..3c2842e5725 100644 --- a/spec/requests/api/suggestions_spec.rb +++ b/spec/requests/api/suggestions_spec.rb @@ -38,7 +38,7 @@ describe API::Suggestions do it 'returns 200 with json content' do project.add_maintainer(user) - put api(url, user), id: suggestion.id + put api(url, user), params: { id: suggestion.id } expect(response).to have_gitlab_http_status(200) expect(json_response) @@ -56,7 +56,7 @@ describe API::Suggestions do it 'returns 400 with json content' do project.add_maintainer(user) - put api(url, user), id: suggestion.id + put api(url, user), params: { id: suggestion.id } expect(response).to have_gitlab_http_status(400) expect(json_response).to eq({ 'message' => 'Suggestion is not appliable' }) @@ -73,7 +73,7 @@ describe API::Suggestions do it 'returns 403 with json content' do project.add_reporter(user) - put api(url, user), id: suggestion.id + put api(url, user), params: { id: suggestion.id } expect(response).to have_gitlab_http_status(403) expect(json_response).to eq({ 'message' => '403 Forbidden' }) diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index 6c57d443cbf..b6e8d74c2e9 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -45,7 +45,7 @@ describe API::SystemHooks do describe "POST /hooks" do it "creates new hook" do expect do - post api("/hooks", admin), url: 'http://example.com' + post api("/hooks", admin), params: { url: 'http://example.com' } end.to change { SystemHook.count }.by(1) end @@ -56,7 +56,7 @@ describe API::SystemHooks do end it "responds with 400 if url is invalid" do - post api("/hooks", admin), url: 'hp://mep.mep' + post api("/hooks", admin), params: { url: 'hp://mep.mep' } expect(response).to have_gitlab_http_status(400) end @@ -68,7 +68,7 @@ describe API::SystemHooks do end it 'sets default values for events' do - post api('/hooks', admin), url: 'http://mep.mep' + post api('/hooks', admin), params: { url: 'http://mep.mep' } expect(response).to have_gitlab_http_status(201) expect(json_response['enable_ssl_verification']).to be true @@ -79,11 +79,13 @@ describe API::SystemHooks do it 'sets explicit values for events' do post api('/hooks', admin), - url: 'http://mep.mep', - enable_ssl_verification: false, - push_events: true, - tag_push_events: true, - merge_requests_events: true + params: { + url: 'http://mep.mep', + enable_ssl_verification: false, + push_events: true, + tag_push_events: true, + merge_requests_events: true + } expect(response).to have_http_status(201) expect(json_response['enable_ssl_verification']).to be false diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb index 98f995df06f..12cfac96d31 100644 --- a/spec/requests/api/tags_spec.rb +++ b/spec/requests/api/tags_spec.rb @@ -193,7 +193,7 @@ describe API::Tags do shared_examples_for 'repository new tag' do it 'creates a new tag' do - post api(route, current_user), tag_name: tag_name, ref: 'master' + post api(route, current_user), params: { tag_name: tag_name, ref: 'master' } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/tag') @@ -248,26 +248,26 @@ describe API::Tags do end it 'returns 400 if tag name is invalid' do - post api(route, current_user), tag_name: 'new design', ref: 'master' + post api(route, current_user), params: { tag_name: 'new design', ref: 'master' } expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Tag name invalid') end it 'returns 400 if tag already exists' do - post api(route, current_user), tag_name: 'new_design1', ref: 'master' + post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/tag') - post api(route, current_user), tag_name: 'new_design1', ref: 'master' + post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' } expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Tag new_design1 already exists') end it 'returns 400 if ref name is invalid' do - post api(route, current_user), tag_name: 'new_design3', ref: 'foo' + post api(route, current_user), params: { tag_name: 'new_design3', ref: 'foo' } expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Target foo is invalid') @@ -275,7 +275,7 @@ describe API::Tags do context 'lightweight tags with release notes' do it 'creates a new tag' do - post api(route, current_user), tag_name: tag_name, ref: 'master', release_description: 'Wow' + post api(route, current_user), params: { tag_name: tag_name, ref: 'master', release_description: 'Wow' } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/tag') @@ -294,7 +294,7 @@ describe API::Tags do system(*%W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.name #{user.name})) system(*%W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.email #{user.email})) - post api(route, current_user), tag_name: 'v7.1.0', ref: 'master', message: 'Release 7.1.0' + post api(route, current_user), params: { tag_name: 'v7.1.0', ref: 'master', message: 'Release 7.1.0' } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/tag') @@ -360,7 +360,7 @@ describe API::Tags do shared_examples_for 'repository new release' do it 'creates description for existing git tag' do - post api(route, user), description: description + post api(route, user), params: { description: description } expect(response).to have_gitlab_http_status(201) expect(response).to match_response_schema('public_api/v4/release') @@ -372,7 +372,7 @@ describe API::Tags do let(:tag_name) { 'unknown' } it_behaves_like '404 response' do - let(:request) { post api(route, current_user), description: description } + let(:request) { post api(route, current_user), params: { description: description } } let(:message) { 'Tag does not exist' } end end @@ -381,7 +381,7 @@ describe API::Tags do include_context 'disabled repository' it_behaves_like '403 response' do - let(:request) { post api(route, current_user), description: description } + let(:request) { post api(route, current_user), params: { description: description } } end end end @@ -404,7 +404,7 @@ describe API::Tags do end it 'returns 409 if there is already a release' do - post api(route, user), description: description + post api(route, user), params: { description: description } expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Release already exists') @@ -426,7 +426,7 @@ describe API::Tags do end it 'updates the release description' do - put api(route, current_user), description: new_description + put api(route, current_user), params: { description: new_description } expect(response).to have_gitlab_http_status(200) expect(json_response['tag_name']).to eq(tag_name) @@ -438,7 +438,7 @@ describe API::Tags do let(:tag_name) { 'unknown' } it_behaves_like '404 response' do - let(:request) { put api(route, current_user), description: new_description } + let(:request) { put api(route, current_user), params: { description: new_description } } let(:message) { 'Tag does not exist' } end end @@ -447,7 +447,7 @@ describe API::Tags do include_context 'disabled repository' it_behaves_like '403 response' do - let(:request) { put api(route, current_user), description: new_description } + let(:request) { put api(route, current_user), params: { description: new_description } } end end end @@ -465,7 +465,7 @@ describe API::Tags do context 'when release does not exist' do it_behaves_like '404 response' do - let(:request) { put api(route, current_user), description: new_description } + let(:request) { put api(route, current_user), params: { description: new_description } } let(:message) { 'Release does not exist' } end end diff --git a/spec/requests/api/todos_spec.rb b/spec/requests/api/todos_spec.rb index b5cf04e7f22..f121a1d3b78 100644 --- a/spec/requests/api/todos_spec.rb +++ b/spec/requests/api/todos_spec.rb @@ -49,7 +49,7 @@ describe API::Todos do context 'and using the author filter' do it 'filters based on author_id param' do - get api('/todos', john_doe), { author_id: author_2.id } + get api('/todos', john_doe), params: { author_id: author_2.id } expect(response.status).to eq(200) expect(response).to include_pagination_headers @@ -62,7 +62,7 @@ describe API::Todos do it 'filters based on type param' do create(:todo, project: project_1, author: author_2, user: john_doe, target: merge_request) - get api('/todos', john_doe), { type: 'MergeRequest' } + get api('/todos', john_doe), params: { type: 'MergeRequest' } expect(response.status).to eq(200) expect(response).to include_pagination_headers @@ -73,7 +73,7 @@ describe API::Todos do context 'and using the state filter' do it 'filters based on state param' do - get api('/todos', john_doe), { state: 'done' } + get api('/todos', john_doe), params: { state: 'done' } expect(response.status).to eq(200) expect(response).to include_pagination_headers @@ -84,7 +84,7 @@ describe API::Todos do context 'and using the project filter' do it 'filters based on project_id param' do - get api('/todos', john_doe), { project_id: project_2.id } + get api('/todos', john_doe), params: { project_id: project_2.id } expect(response.status).to eq(200) expect(response).to include_pagination_headers @@ -95,7 +95,7 @@ describe API::Todos do context 'and using the group filter' do it 'filters based on project_id param' do - get api('/todos', john_doe), { group_id: group.id, sort: :target_id } + get api('/todos', john_doe), params: { group_id: group.id, sort: :target_id } expect(response.status).to eq(200) expect(response).to include_pagination_headers @@ -106,7 +106,7 @@ describe API::Todos do context 'and using the action filter' do it 'filters based on action param' do - get api('/todos', john_doe), { action: 'mentioned' } + get api('/todos', john_doe), params: { action: 'mentioned' } expect(response.status).to eq(200) expect(response).to include_pagination_headers diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index 658df6945d2..15dc901d06e 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -26,13 +26,13 @@ describe API::Triggers do context 'Handles errors' do it 'returns bad request if token is missing' do - post api("/projects/#{project.id}/trigger/pipeline"), ref: 'master' + post api("/projects/#{project.id}/trigger/pipeline"), params: { ref: 'master' } expect(response).to have_gitlab_http_status(400) end it 'returns not found if project is not found' do - post api('/projects/0/trigger/pipeline'), options.merge(ref: 'master') + post api('/projects/0/trigger/pipeline'), params: options.merge(ref: 'master') expect(response).to have_gitlab_http_status(404) end @@ -42,7 +42,7 @@ describe API::Triggers do let(:pipeline) { project.ci_pipelines.last } it 'creates pipeline' do - post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master') + post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: 'master') expect(response).to have_gitlab_http_status(201) expect(json_response).to include('id' => pipeline.id) @@ -52,7 +52,7 @@ describe API::Triggers do end it 'returns bad request with no pipeline created if there\'s no commit for that ref' do - post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'other-branch') + post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: 'other-branch') expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('base' => ["Reference not found"]) @@ -64,21 +64,21 @@ describe API::Triggers do end it 'validates variables to be a hash' do - post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: 'value', ref: 'master') + post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: 'value', ref: 'master') expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('variables is invalid') end it 'validates variables needs to be a map of key-valued strings' do - post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: { key: %w(1 2) }, ref: 'master') + post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: { key: %w(1 2) }, ref: 'master') expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('variables needs to be a map of key-valued strings') end it 'creates trigger request with variables' do - post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: variables, ref: 'master') + post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: variables, ref: 'master') expect(response).to have_gitlab_http_status(201) expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables) @@ -91,7 +91,7 @@ describe API::Triggers do end it 'creates pipeline' do - post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master') + post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: 'master') expect(response).to have_gitlab_http_status(201) expect(json_response).to include('id' => pipeline.id) @@ -104,14 +104,14 @@ describe API::Triggers do context 'when triggering a pipeline from a trigger token' do it 'does not leak the presence of project when token is for different project' do - post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } + post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' } expect(response).to have_gitlab_http_status(404) end it 'creates builds from the ref given in the URL, not in the body' do expect do - post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } + post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(5) expect(response).to have_gitlab_http_status(201) @@ -122,7 +122,7 @@ describe API::Triggers do project.repository.create_file(user, '.gitlab/gitlabhq/new_feature.md', 'something valid', message: 'new_feature', branch_name: 'v.1-branch') expect do - post api("/projects/#{project.id}/ref/v.1-branch/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } + post api("/projects/#{project.id}/ref/v.1-branch/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(4) expect(response).to have_gitlab_http_status(201) @@ -199,7 +199,7 @@ describe API::Triggers do it 'creates trigger' do expect do post api("/projects/#{project.id}/triggers", user), - description: 'trigger' + params: { description: 'trigger' } end.to change {project.triggers.count}.by(1) expect(response).to have_gitlab_http_status(201) @@ -219,7 +219,7 @@ describe API::Triggers do context 'authenticated user with invalid permissions' do it 'does not create trigger' do post api("/projects/#{project.id}/triggers", user2), - description: 'trigger' + params: { description: 'trigger' } expect(response).to have_gitlab_http_status(403) end @@ -228,7 +228,7 @@ describe API::Triggers do context 'unauthenticated user' do it 'does not create trigger' do post api("/projects/#{project.id}/triggers"), - description: 'trigger' + params: { description: 'trigger' } expect(response).to have_gitlab_http_status(401) end @@ -241,7 +241,7 @@ describe API::Triggers do it 'updates description' do put api("/projects/#{project.id}/triggers/#{trigger.id}", user), - description: new_description + params: { description: new_description } expect(response).to have_gitlab_http_status(200) expect(json_response).to include('description' => new_description) diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index bb913ae0e79..f3431e0be3d 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -43,7 +43,7 @@ describe API::Users do end it "returns the user when a valid `username` parameter is passed" do - get api("/users"), username: user.username + get api("/users"), params: { username: user.username } expect(response).to match_response_schema('public_api/v4/user/basics') expect(json_response.size).to eq(1) @@ -52,7 +52,7 @@ describe API::Users do end it "returns the user when a valid `username` parameter is passed (case insensitive)" do - get api("/users"), username: user.username.upcase + get api("/users"), params: { username: user.username.upcase } expect(response).to match_response_schema('public_api/v4/user/basics') expect(json_response.size).to eq(1) @@ -61,7 +61,7 @@ describe API::Users do end it "returns an empty response when an invalid `username` parameter is passed" do - get api("/users"), username: 'invalid' + get api("/users"), params: { username: 'invalid' } expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array @@ -74,7 +74,7 @@ describe API::Users do end it "returns authorization error when the `username` parameter refers to an inaccessible user" do - get api("/users"), username: user.username + get api("/users"), params: { username: user.username } expect(response).to have_gitlab_http_status(403) end @@ -243,7 +243,7 @@ describe API::Users do admin user - get api('/users', admin), { order_by: 'id', sort: 'asc' } + get api('/users', admin), params: { order_by: 'id', sort: 'asc' } expect(response).to match_response_schema('public_api/v4/user/admins') expect(json_response.size).to eq(2) @@ -256,7 +256,7 @@ describe API::Users do user user_with_2fa = create(:user, :two_factor_via_otp) - get api('/users', admin), { two_factor: 'enabled' } + get api('/users', admin), params: { two_factor: 'enabled' } expect(response).to match_response_schema('public_api/v4/user/admins') expect(json_response.size).to eq(1) @@ -264,7 +264,7 @@ describe API::Users do end it 'returns 400 when provided incorrect sort params' do - get api('/users', admin), { order_by: 'magic', sort: 'asc' } + get api('/users', admin), params: { order_by: 'magic', sort: 'asc' } expect(response).to have_gitlab_http_status(400) end @@ -375,12 +375,12 @@ describe API::Users do it "creates user" do expect do - post api("/users", admin), attributes_for(:user, projects_limit: 3) + post api("/users", admin), params: attributes_for(:user, projects_limit: 3) end.to change { User.count }.by(1) end it "creates user with correct attributes" do - post api('/users', admin), attributes_for(:user, admin: true, can_create_group: true) + post api('/users', admin), params: attributes_for(:user, admin: true, can_create_group: true) expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) @@ -393,13 +393,13 @@ describe API::Users do optional_attributes = { confirm: true } attributes = attributes_for(:user).merge(optional_attributes) - post api('/users', admin), attributes + post api('/users', admin), params: attributes expect(response).to have_gitlab_http_status(201) end it "creates non-admin user" do - post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false) + post api('/users', admin), params: attributes_for(:user, admin: false, can_create_group: false) expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) @@ -409,7 +409,7 @@ describe API::Users do end it "creates non-admin users by default" do - post api('/users', admin), attributes_for(:user) + post api('/users', admin), params: attributes_for(:user) expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) @@ -418,12 +418,12 @@ describe API::Users do end it "returns 201 Created on success" do - post api("/users", admin), attributes_for(:user, projects_limit: 3) + post api("/users", admin), params: attributes_for(:user, projects_limit: 3) expect(response).to have_gitlab_http_status(201) end it 'creates non-external users by default' do - post api("/users", admin), attributes_for(:user) + post api("/users", admin), params: attributes_for(:user) expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] @@ -433,7 +433,7 @@ describe API::Users do end it 'allows an external user to be created' do - post api("/users", admin), attributes_for(:user, external: true) + post api("/users", admin), params: attributes_for(:user, external: true) expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] @@ -443,7 +443,7 @@ describe API::Users do end it "creates user with reset password" do - post api('/users', admin), attributes_for(:user, reset_password: true).except(:password) + post api('/users', admin), params: attributes_for(:user, reset_password: true).except(:password) expect(response).to have_gitlab_http_status(201) @@ -455,7 +455,7 @@ describe API::Users do end it "creates user with private profile" do - post api('/users', admin), attributes_for(:user, private_profile: true) + post api('/users', admin), params: attributes_for(:user, private_profile: true) expect(response).to have_gitlab_http_status(201) @@ -468,40 +468,44 @@ describe API::Users do it "does not create user with invalid email" do post api('/users', admin), - email: 'invalid email', - password: 'password', - name: 'test' + params: { + email: 'invalid email', + password: 'password', + name: 'test' + } expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if name not given' do - post api('/users', admin), attributes_for(:user).except(:name) + post api('/users', admin), params: attributes_for(:user).except(:name) expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if password not given' do - post api('/users', admin), attributes_for(:user).except(:password) + post api('/users', admin), params: attributes_for(:user).except(:password) expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if email not given' do - post api('/users', admin), attributes_for(:user).except(:email) + post api('/users', admin), params: attributes_for(:user).except(:email) expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if username not given' do - post api('/users', admin), attributes_for(:user).except(:username) + post api('/users', admin), params: attributes_for(:user).except(:username) expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if user does not validate' do post api('/users', admin), - password: 'pass', - email: 'test@example.com', - username: 'test!', - name: 'test', - bio: 'g' * 256, - projects_limit: -1 + params: { + password: 'pass', + email: 'test@example.com', + username: 'test!', + name: 'test', + bio: 'g' * 256, + projects_limit: -1 + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['password']) .to eq(['is too short (minimum is 8 characters)']) @@ -514,26 +518,30 @@ describe API::Users do end it "is not available for non admin users" do - post api("/users", user), attributes_for(:user) + post api("/users", user), params: attributes_for(:user) expect(response).to have_gitlab_http_status(403) end context 'with existing user' do before do post api('/users', admin), - email: 'test@example.com', - password: 'password', - username: 'test', - name: 'foo' + params: { + email: 'test@example.com', + password: 'password', + username: 'test', + name: 'foo' + } end it 'returns 409 conflict error if user with same email exists' do expect do post api('/users', admin), - name: 'foo', - email: 'test@example.com', - password: 'password', - username: 'foo' + params: { + name: 'foo', + email: 'test@example.com', + password: 'password', + username: 'foo' + } end.to change { User.count }.by(0) expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Email has already been taken') @@ -542,10 +550,12 @@ describe API::Users do it 'returns 409 conflict error if same username exists' do expect do post api('/users', admin), - name: 'foo', - email: 'foo@example.com', - password: 'password', - username: 'test' + params: { + name: 'foo', + email: 'foo@example.com', + password: 'password', + username: 'test' + } end.to change { User.count }.by(0) expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Username has already been taken') @@ -554,17 +564,19 @@ describe API::Users do it 'returns 409 conflict error if same username exists (case insensitive)' do expect do post api('/users', admin), - name: 'foo', - email: 'foo@example.com', - password: 'password', - username: 'TEST' + params: { + name: 'foo', + email: 'foo@example.com', + password: 'password', + username: 'TEST' + } end.to change { User.count }.by(0) expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Username has already been taken') end it 'creates user with new identity' do - post api("/users", admin), attributes_for(:user, provider: 'github', extern_uid: '67890') + post api("/users", admin), params: attributes_for(:user, provider: 'github', extern_uid: '67890') expect(response).to have_gitlab_http_status(201) expect(json_response['identities'].first['extern_uid']).to eq('67890') @@ -593,7 +605,7 @@ describe API::Users do let!(:admin_user) { create(:admin) } it "updates user with new bio" do - put api("/users/#{user.id}", admin), { bio: 'new test bio' } + put api("/users/#{user.id}", admin), params: { bio: 'new test bio' } expect(response).to have_gitlab_http_status(200) expect(json_response['bio']).to eq('new test bio') @@ -601,14 +613,14 @@ describe API::Users do end it "updates user with new password and forces reset on next login" do - put api("/users/#{user.id}", admin), password: '12345678' + put api("/users/#{user.id}", admin), params: { password: '12345678' } expect(response).to have_gitlab_http_status(200) expect(user.reload.password_expires_at).to be <= Time.now end it "updates user with organization" do - put api("/users/#{user.id}", admin), { organization: 'GitLab' } + put api("/users/#{user.id}", admin), params: { organization: 'GitLab' } expect(response).to have_gitlab_http_status(200) expect(json_response['organization']).to eq('GitLab') @@ -616,7 +628,7 @@ describe API::Users do end it 'updates user with avatar' do - put api("/users/#{user.id}", admin), { avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') } + put api("/users/#{user.id}", admin), params: { avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') } user.reload @@ -628,7 +640,7 @@ describe API::Users do it 'updates user with a new email' do old_email = user.email old_notification_email = user.notification_email - put api("/users/#{user.id}", admin), email: 'new@email.com' + put api("/users/#{user.id}", admin), params: { email: 'new@email.com' } user.reload @@ -640,7 +652,7 @@ describe API::Users do end it 'skips reconfirmation when requested' do - put api("/users/#{user.id}", admin), email: 'new@email.com', skip_reconfirmation: true + put api("/users/#{user.id}", admin), params: { email: 'new@email.com', skip_reconfirmation: true } user.reload @@ -650,7 +662,7 @@ describe API::Users do end it 'updates user with his own username' do - put api("/users/#{user.id}", admin), username: user.username + put api("/users/#{user.id}", admin), params: { username: user.username } expect(response).to have_gitlab_http_status(200) expect(json_response['username']).to eq(user.username) @@ -658,14 +670,14 @@ describe API::Users do end it "updates user's existing identity" do - put api("/users/#{omniauth_user.id}", admin), provider: 'ldapmain', extern_uid: '654321' + put api("/users/#{omniauth_user.id}", admin), params: { provider: 'ldapmain', extern_uid: '654321' } expect(response).to have_gitlab_http_status(200) expect(omniauth_user.reload.identities.first.extern_uid).to eq('654321') end it 'updates user with new identity' do - put api("/users/#{user.id}", admin), provider: 'github', extern_uid: 'john' + put api("/users/#{user.id}", admin), params: { provider: 'github', extern_uid: 'john' } expect(response).to have_gitlab_http_status(200) expect(user.reload.identities.first.extern_uid).to eq('john') @@ -673,14 +685,14 @@ describe API::Users do end it "updates admin status" do - put api("/users/#{user.id}", admin), { admin: true } + put api("/users/#{user.id}", admin), params: { admin: true } expect(response).to have_gitlab_http_status(200) expect(user.reload.admin).to eq(true) end it "updates external status" do - put api("/users/#{user.id}", admin), { external: true } + put api("/users/#{user.id}", admin), params: { external: true } expect(response.status).to eq 200 expect(json_response['external']).to eq(true) @@ -688,14 +700,14 @@ describe API::Users do end it "updates private profile" do - put api("/users/#{user.id}", admin), { private_profile: true } + put api("/users/#{user.id}", admin), params: { private_profile: true } expect(response).to have_gitlab_http_status(200) expect(user.reload.private_profile).to eq(true) end it "does not update admin status" do - put api("/users/#{admin_user.id}", admin), { can_create_group: false } + put api("/users/#{admin_user.id}", admin), params: { can_create_group: false } expect(response).to have_gitlab_http_status(200) expect(admin_user.reload.admin).to eq(true) @@ -703,7 +715,7 @@ describe API::Users do end it "does not allow invalid update" do - put api("/users/#{user.id}", admin), { email: 'invalid email' } + put api("/users/#{user.id}", admin), params: { email: 'invalid email' } expect(response).to have_gitlab_http_status(400) expect(user.reload.email).not_to eq('invalid email') @@ -712,7 +724,7 @@ describe API::Users do context 'when the current user is not an admin' do it "is not available" do expect do - put api("/users/#{user.id}", user), attributes_for(:user) + put api("/users/#{user.id}", user), params: attributes_for(:user) end.not_to change { user.reload.attributes } expect(response).to have_gitlab_http_status(403) @@ -720,7 +732,7 @@ describe API::Users do end it "returns 404 for non-existing user" do - put api("/users/999999", admin), { bio: 'update should fail' } + put api("/users/999999", admin), params: { bio: 'update should fail' } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') @@ -734,12 +746,14 @@ describe API::Users do it 'returns 400 error if user does not validate' do put api("/users/#{user.id}", admin), - password: 'pass', - email: 'test@example.com', - username: 'test!', - name: 'test', - bio: 'g' * 256, - projects_limit: -1 + params: { + password: 'pass', + email: 'test@example.com', + username: 'test!', + name: 'test', + bio: 'g' * 256, + projects_limit: -1 + } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['password']) .to eq(['is too short (minimum is 8 characters)']) @@ -752,26 +766,26 @@ describe API::Users do end it 'returns 400 if provider is missing for identity update' do - put api("/users/#{omniauth_user.id}", admin), extern_uid: '654321' + put api("/users/#{omniauth_user.id}", admin), params: { extern_uid: '654321' } expect(response).to have_gitlab_http_status(400) end it 'returns 400 if external UID is missing for identity update' do - put api("/users/#{omniauth_user.id}", admin), provider: 'ldap' + put api("/users/#{omniauth_user.id}", admin), params: { provider: 'ldap' } expect(response).to have_gitlab_http_status(400) end context "with existing user" do before do - post api("/users", admin), { email: 'test@example.com', password: 'password', username: 'test', name: 'test' } - post api("/users", admin), { email: 'foo@bar.com', password: 'password', username: 'john', name: 'john' } + post api("/users", admin), params: { email: 'test@example.com', password: 'password', username: 'test', name: 'test' } + post api("/users", admin), params: { email: 'foo@bar.com', password: 'password', username: 'john', name: 'john' } @user = User.all.last end it 'returns 409 conflict error if email address exists' do - put api("/users/#{@user.id}", admin), email: 'test@example.com' + put api("/users/#{@user.id}", admin), params: { email: 'test@example.com' } expect(response).to have_gitlab_http_status(409) expect(@user.reload.email).to eq(@user.email) @@ -779,7 +793,7 @@ describe API::Users do it 'returns 409 conflict error if username taken' do @user_id = User.all.last.id - put api("/users/#{@user.id}", admin), username: 'test' + put api("/users/#{@user.id}", admin), params: { username: 'test' } expect(response).to have_gitlab_http_status(409) expect(@user.reload.username).to eq(@user.username) @@ -787,7 +801,7 @@ describe API::Users do it 'returns 409 conflict error if username taken (case insensitive)' do @user_id = User.all.last.id - put api("/users/#{@user.id}", admin), username: 'TEST' + put api("/users/#{@user.id}", admin), params: { username: 'TEST' } expect(response).to have_gitlab_http_status(409) expect(@user.reload.username).to eq(@user.username) @@ -801,14 +815,14 @@ describe API::Users do end it "does not create invalid ssh key" do - post api("/users/#{user.id}/keys", admin), { title: "invalid key" } + post api("/users/#{user.id}/keys", admin), params: { title: "invalid key" } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'does not create key without title' do - post api("/users/#{user.id}/keys", admin), key: 'some key' + post api("/users/#{user.id}/keys", admin), params: { key: 'some key' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') @@ -817,7 +831,7 @@ describe API::Users do it "creates ssh key" do key_attrs = attributes_for :key expect do - post api("/users/#{user.id}/keys", admin), key_attrs + post api("/users/#{user.id}/keys", admin), params: key_attrs end.to change { user.keys.count }.by(1) end @@ -909,7 +923,7 @@ describe API::Users do it 'creates GPG key' do key_attrs = attributes_for :gpg_key expect do - post api("/users/#{user.id}/gpg_keys", admin), key_attrs + post api("/users/#{user.id}/gpg_keys", admin), params: key_attrs expect(response).to have_gitlab_http_status(201) end.to change { user.gpg_keys.count }.by(1) @@ -1058,7 +1072,7 @@ describe API::Users do end it "does not create invalid email" do - post api("/users/#{user.id}/emails", admin), {} + post api("/users/#{user.id}/emails", admin), params: {} expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('email is missing') @@ -1067,7 +1081,7 @@ describe API::Users do it "creates unverified email" do email_attrs = attributes_for :email expect do - post api("/users/#{user.id}/emails", admin), email_attrs + post api("/users/#{user.id}/emails", admin), params: email_attrs end.to change { user.emails.count }.by(1) email = Email.find_by(user_id: user.id, email: email_attrs[:email]) @@ -1084,7 +1098,7 @@ describe API::Users do email_attrs = attributes_for :email email_attrs[:skip_confirmation] = true - post api("/users/#{user.id}/emails", admin), email_attrs + post api("/users/#{user.id}/emails", admin), params: email_attrs expect(response).to have_gitlab_http_status(201) @@ -1379,32 +1393,32 @@ describe API::Users do it "creates ssh key" do key_attrs = attributes_for :key expect do - post api("/user/keys", user), key_attrs + post api("/user/keys", user), params: key_attrs end.to change { user.keys.count }.by(1) expect(response).to have_gitlab_http_status(201) end it "returns a 401 error if unauthorized" do - post api("/user/keys"), title: 'some title', key: 'some key' + post api("/user/keys"), params: { title: 'some title', key: 'some key' } expect(response).to have_gitlab_http_status(401) end it "does not create ssh key without key" do - post api("/user/keys", user), title: 'title' + post api("/user/keys", user), params: { title: 'title' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'does not create ssh key without title' do - post api('/user/keys', user), key: 'some key' + post api('/user/keys', user), params: { key: 'some key' } expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') end it "does not create ssh key without title" do - post api("/user/keys", user), key: "somekey" + post api("/user/keys", user), params: { key: "somekey" } expect(response).to have_gitlab_http_status(400) end end @@ -1523,14 +1537,14 @@ describe API::Users do it 'creates a GPG key' do key_attrs = attributes_for :gpg_key expect do - post api('/user/gpg_keys', user), key_attrs + post api('/user/gpg_keys', user), params: key_attrs expect(response).to have_gitlab_http_status(201) end.to change { user.gpg_keys.count }.by(1) end it 'returns a 401 error if unauthorized' do - post api('/user/gpg_keys'), key: 'some key' + post api('/user/gpg_keys'), params: { key: 'some key' } expect(response).to have_gitlab_http_status(401) end @@ -1685,18 +1699,18 @@ describe API::Users do it "creates email" do email_attrs = attributes_for :email expect do - post api("/user/emails", user), email_attrs + post api("/user/emails", user), params: email_attrs end.to change { user.emails.count }.by(1) expect(response).to have_gitlab_http_status(201) end it "returns a 401 error if unauthorized" do - post api("/user/emails"), email: 'some email' + post api("/user/emails"), params: { email: 'some email' } expect(response).to have_gitlab_http_status(401) end it "does not create email with invalid email" do - post api("/user/emails", user), {} + post api("/user/emails", user), params: {} expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('email is missing') @@ -1864,14 +1878,14 @@ describe API::Users do describe 'PUT /user/status' do it 'saves the status' do - put api('/user/status', user), { emoji: 'smirk', message: 'hello world' } + put api('/user/status', user), params: { emoji: 'smirk', message: 'hello world' } expect(response).to have_gitlab_http_status(:success) expect(json_response['emoji']).to eq('smirk') end it 'renders errors when the status was invalid' do - put api('/user/status', user), { emoji: 'does not exist', message: 'hello world' } + put api('/user/status', user), params: { emoji: 'does not exist', message: 'hello world' } expect(response).to have_gitlab_http_status(400) expect(json_response['message']['emoji']).to be_present @@ -1950,8 +1964,10 @@ describe API::Users do it 'returns a 404 error if user not found' do post api("/users/#{not_existing_user_id}/impersonation_tokens", admin), - name: name, - expires_at: expires_at + params: { + name: name, + expires_at: expires_at + } expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') @@ -1959,8 +1975,10 @@ describe API::Users do it 'returns a 403 error when authenticated as normal user' do post api("/users/#{user.id}/impersonation_tokens", user), - name: name, - expires_at: expires_at + params: { + name: name, + expires_at: expires_at + } expect(response).to have_gitlab_http_status(403) expect(json_response['message']).to eq('403 Forbidden') @@ -1968,10 +1986,12 @@ describe API::Users do it 'creates a impersonation token' do post api("/users/#{user.id}/impersonation_tokens", admin), - name: name, - expires_at: expires_at, - scopes: scopes, - impersonation: impersonation + params: { + name: name, + expires_at: expires_at, + scopes: scopes, + impersonation: impersonation + } expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(name) diff --git a/spec/requests/api/variables_spec.rb b/spec/requests/api/variables_spec.rb index be333df1d78..cdac5b2f400 100644 --- a/spec/requests/api/variables_spec.rb +++ b/spec/requests/api/variables_spec.rb @@ -73,7 +73,7 @@ describe API::Variables do context 'authorized user with proper permissions' do it 'creates variable' do expect do - post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true + post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true } end.to change {project.variables.count}.by(1) expect(response).to have_gitlab_http_status(201) @@ -84,7 +84,7 @@ describe API::Variables do it 'creates variable with optional attributes' do expect do - post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2' + post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'VALUE_2' } end.to change {project.variables.count}.by(1) expect(response).to have_gitlab_http_status(201) @@ -95,7 +95,7 @@ describe API::Variables do it 'does not allow to duplicate variable key' do expect do - post api("/projects/#{project.id}/variables", user), key: variable.key, value: 'VALUE_2' + post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' } end.to change {project.variables.count}.by(0) expect(response).to have_gitlab_http_status(400) @@ -125,7 +125,7 @@ describe API::Variables do initial_variable = project.variables.reload.first value_before = initial_variable.value - put api("/projects/#{project.id}/variables/#{variable.key}", user), value: 'VALUE_1_UP', protected: true + put api("/projects/#{project.id}/variables/#{variable.key}", user), params: { value: 'VALUE_1_UP', protected: true } updated_variable = project.variables.reload.first diff --git a/spec/requests/api/wikis_spec.rb b/spec/requests/api/wikis_spec.rb index 08bada44178..f5092e8e2b5 100644 --- a/spec/requests/api/wikis_spec.rb +++ b/spec/requests/api/wikis_spec.rb @@ -39,7 +39,7 @@ describe API::Wikis do end it 'returns the list of wiki pages with content' do - get api(url, user), with_content: 1 + get api(url, user), params: { with_content: 1 } expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) @@ -74,7 +74,7 @@ describe API::Wikis do shared_examples_for 'creates wiki page' do it 'creates the wiki page' do - post(api(url, user), payload) + post(api(url, user), params: payload) expect(response).to have_gitlab_http_status(201) expect(json_response.size).to eq(4) @@ -89,7 +89,7 @@ describe API::Wikis do it "responds with validation error on empty #{part}" do payload.delete(part) - post(api(url, user), payload) + post(api(url, user), params: payload) expect(response).to have_gitlab_http_status(400) expect(json_response.size).to eq(1) @@ -143,7 +143,7 @@ describe API::Wikis do it 'pushes attachment to the wiki repository' do allow(SecureRandom).to receive(:hex).and_return('fixed_hex') - post(api(url, user), payload) + post(api(url, user), params: payload) expect(response).to have_gitlab_http_status(201) expect(json_response).to eq result_hash.deep_stringify_keys @@ -152,7 +152,7 @@ describe API::Wikis do it 'responds with validation error on empty file' do payload.delete(:file) - post(api(url, user), payload) + post(api(url, user), params: payload) expect(response).to have_gitlab_http_status(400) expect(json_response.size).to eq(1) @@ -162,7 +162,7 @@ describe API::Wikis do it 'responds with validation error on invalid temp file' do payload[:file] = { tempfile: '/etc/hosts' } - post(api(url, user), payload) + post(api(url, user), params: payload) expect(response).to have_gitlab_http_status(400) expect(json_response.size).to eq(1) @@ -395,7 +395,7 @@ describe API::Wikis do context 'when user is guest' do before do - post(api(url), payload) + post(api(url), params: payload) end include_examples '404 Project Not Found' @@ -404,7 +404,7 @@ describe API::Wikis do context 'when user is developer' do before do project.add_developer(user) - post(api(url, user), payload) + post(api(url, user), params: payload) end include_examples '403 Forbidden' @@ -413,7 +413,7 @@ describe API::Wikis do context 'when user is maintainer' do before do project.add_maintainer(user) - post(api(url, user), payload) + post(api(url, user), params: payload) end include_examples '403 Forbidden' @@ -425,7 +425,7 @@ describe API::Wikis do context 'when user is guest' do before do - post(api(url), payload) + post(api(url), params: payload) end include_examples '404 Project Not Found' @@ -453,7 +453,7 @@ describe API::Wikis do context 'when user is guest' do before do - post(api(url), payload) + post(api(url), params: payload) end include_examples '404 Project Not Found' @@ -487,7 +487,7 @@ describe API::Wikis do context 'when user is guest' do before do - put(api(url), payload) + put(api(url), params: payload) end include_examples '404 Project Not Found' @@ -497,7 +497,7 @@ describe API::Wikis do before do project.add_developer(user) - put(api(url, user), payload) + put(api(url, user), params: payload) end include_examples '403 Forbidden' @@ -507,7 +507,7 @@ describe API::Wikis do before do project.add_maintainer(user) - put(api(url, user), payload) + put(api(url, user), params: payload) end include_examples '403 Forbidden' @@ -519,7 +519,7 @@ describe API::Wikis do context 'when user is guest' do before do - put(api(url), payload) + put(api(url), params: payload) end include_examples '404 Project Not Found' @@ -529,7 +529,7 @@ describe API::Wikis do before do project.add_developer(user) - put(api(url, user), payload) + put(api(url, user), params: payload) end include_examples 'updates wiki page' @@ -545,7 +545,7 @@ describe API::Wikis do before do project.add_maintainer(user) - put(api(url, user), payload) + put(api(url, user), params: payload) end include_examples 'updates wiki page' @@ -563,7 +563,7 @@ describe API::Wikis do context 'when user is guest' do before do - put(api(url), payload) + put(api(url), params: payload) end include_examples '404 Project Not Found' @@ -573,7 +573,7 @@ describe API::Wikis do before do project.add_developer(user) - put(api(url, user), payload) + put(api(url, user), params: payload) end include_examples 'updates wiki page' @@ -589,7 +589,7 @@ describe API::Wikis do before do project.add_maintainer(user) - put(api(url, user), payload) + put(api(url, user), params: payload) end include_examples 'updates wiki page' @@ -606,7 +606,7 @@ describe API::Wikis do let(:project) { create(:project, :wiki_repo, namespace: group) } before do - put(api(url, user), payload) + put(api(url, user), params: payload) end include_examples 'updates wiki page' @@ -751,7 +751,7 @@ describe API::Wikis do context 'when user is guest' do before do - post(api(url), payload) + post(api(url), params: payload) end include_examples '404 Project Not Found' @@ -760,7 +760,7 @@ describe API::Wikis do context 'when user is developer' do before do project.add_developer(user) - post(api(url, user), payload) + post(api(url, user), params: payload) end include_examples '403 Forbidden' @@ -769,7 +769,7 @@ describe API::Wikis do context 'when user is maintainer' do before do project.add_maintainer(user) - post(api(url, user), payload) + post(api(url, user), params: payload) end include_examples '403 Forbidden' @@ -781,7 +781,7 @@ describe API::Wikis do context 'when user is guest' do before do - post(api(url), payload) + post(api(url), params: payload) end include_examples '404 Project Not Found' @@ -809,7 +809,7 @@ describe API::Wikis do context 'when user is guest' do before do - post(api(url), payload) + post(api(url), params: payload) end include_examples '404 Project Not Found' diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index 0dc459d9b5a..939e870ec53 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -726,7 +726,7 @@ describe 'Git HTTP requests' do let(:params) { { service: 'git-upload-pack' } } before do - get path, params + get path, params: params end it "redirects to the .git suffix version" do @@ -738,7 +738,7 @@ describe 'Git HTTP requests' do let(:params) { { service: 'git-receive-pack' } } before do - get path, params + get path, params: params end it "redirects to the .git suffix version" do @@ -750,7 +750,7 @@ describe 'Git HTTP requests' do let(:params) { { service: 'git-implode-pack' } } before do - get path, params + get path, params: params end it "redirects to the sign-in page" do diff --git a/spec/requests/jwt_controller_spec.rb b/spec/requests/jwt_controller_spec.rb index 2d87d236d61..4bb3b848e17 100644 --- a/spec/requests/jwt_controller_spec.rb +++ b/spec/requests/jwt_controller_spec.rb @@ -11,7 +11,7 @@ describe JwtController do end context 'existing service' do - subject! { get '/jwt/auth', parameters } + subject! { get '/jwt/auth', params: parameters } it { expect(response).to have_gitlab_http_status(200) } @@ -29,7 +29,7 @@ describe JwtController do let(:headers) { { authorization: credentials('gitlab-ci-token', build.token) } } context 'project with enabled CI' do - subject! { get '/jwt/auth', parameters, headers } + subject! { get '/jwt/auth', params: parameters, headers: headers } it { expect(service_class).to have_received(:new).with(project, nil, ActionController::Parameters.new(parameters).permit!) } end @@ -39,7 +39,7 @@ describe JwtController do project.project_feature.update_attribute(:builds_access_level, ProjectFeature::DISABLED) end - subject! { get '/jwt/auth', parameters, headers } + subject! { get '/jwt/auth', params: parameters, headers: headers } it { expect(response).to have_gitlab_http_status(401) } end @@ -53,7 +53,7 @@ describe JwtController do stub_container_registry_config(enabled: true) end - subject! { get '/jwt/auth', parameters, headers } + subject! { get '/jwt/auth', params: parameters, headers: headers } it 'authenticates correctly' do expect(response).to have_gitlab_http_status(200) @@ -66,7 +66,7 @@ describe JwtController do let(:user) { create(:user) } let(:headers) { { authorization: credentials(user.username, user.password) } } - subject! { get '/jwt/auth', parameters, headers } + subject! { get '/jwt/auth', params: parameters, headers: headers } it { expect(service_class).to have_received(:new).with(nil, user, ActionController::Parameters.new(parameters).permit!) } @@ -115,7 +115,7 @@ describe JwtController do context 'when internal auth is enabled' do it 'rejects the authorization attempt' do - get '/jwt/auth', parameters, headers + get '/jwt/auth', params: parameters, headers: headers expect(response).to have_gitlab_http_status(401) expect(response.body).not_to include('You must use a personal access token with \'api\' scope for Git over HTTP') @@ -125,7 +125,7 @@ describe JwtController do context 'when internal auth is disabled' do it 'rejects the authorization attempt with personal access token message' do allow_any_instance_of(ApplicationSetting).to receive(:password_authentication_enabled_for_git?) { false } - get '/jwt/auth', parameters, headers + get '/jwt/auth', params: parameters, headers: headers expect(response).to have_gitlab_http_status(401) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') @@ -136,7 +136,7 @@ describe JwtController do context 'when using unauthenticated request' do it 'accepts the authorization attempt' do - get '/jwt/auth', parameters + get '/jwt/auth', params: parameters expect(response).to have_gitlab_http_status(200) end @@ -144,12 +144,12 @@ describe JwtController do it 'allows read access' do expect(service).to receive(:execute).with(authentication_abilities: Gitlab::Auth.read_authentication_abilities) - get '/jwt/auth', parameters + get '/jwt/auth', params: parameters end end context 'unknown service' do - subject! { get '/jwt/auth', service: 'unknown' } + subject! { get '/jwt/auth', params: { service: 'unknown' } } it { expect(response).to have_gitlab_http_status(404) } end diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index e349181b794..3cc29a7076d 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -79,7 +79,7 @@ describe 'Git LFS API and storage' do end it 'responds with a 501 message on download' do - get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers + get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers expect(response).to have_gitlab_http_status(501) end @@ -97,7 +97,7 @@ describe 'Git LFS API and storage' do end it 'responds with a 501 message on download' do - get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers + get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers expect(response).to have_gitlab_http_status(501) end @@ -123,7 +123,7 @@ describe 'Git LFS API and storage' do end it 'responds with a 403 message on download' do - get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers + get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers expect(response).to have_gitlab_http_status(403) expect(json_response).to include('message' => 'Access forbidden. Check your access level.') @@ -143,7 +143,7 @@ describe 'Git LFS API and storage' do end it 'responds with a 200 message on download' do - get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers + get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers expect(response).to have_gitlab_http_status(200) end @@ -172,7 +172,7 @@ describe 'Git LFS API and storage' do let(:authorization) { authorize_user } before do - get "#{project.http_url_to_repo}/info/lfs/objects/#{sample_oid}", nil, headers + get "#{project.http_url_to_repo}/info/lfs/objects/#{sample_oid}", params: {}, headers: headers end it_behaves_like 'a deprecated' @@ -197,7 +197,7 @@ describe 'Git LFS API and storage' do enable_lfs update_permissions before_get - get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers + get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers end context 'and request comes from gitlab-workhorse' do @@ -1347,8 +1347,9 @@ describe 'Git LFS API and storage' do context 'when pushing the same lfs object to the second project' do before do - put "#{second_project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}", nil, - headers.merge('X-Gitlab-Lfs-Tmp' => lfs_tmp_file).compact + put "#{second_project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}", + params: {}, + headers: headers.merge('X-Gitlab-Lfs-Tmp' => lfs_tmp_file).compact end it 'responds with status 200' do @@ -1366,7 +1367,7 @@ describe 'Git LFS API and storage' do authorize_headers = headers authorize_headers.merge!(workhorse_internal_api_request_header) if verified - put "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}/authorize", nil, authorize_headers + put "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}/authorize", params: {}, headers: authorize_headers end def put_finalize(lfs_tmp = lfs_tmp_file, with_tempfile: false, args: {}) @@ -1387,7 +1388,7 @@ describe 'Git LFS API and storage' do end def put_finalize_with_args(args) - put "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}", args, headers + put "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}", params: args, headers: headers end def lfs_tmp_file @@ -1420,7 +1421,10 @@ describe 'Git LFS API and storage' do end def post_lfs_json(url, body = nil, headers = nil) - post(url, body.try(:to_json), (headers || {}).merge('Content-Type' => LfsRequest::CONTENT_TYPE)) + params = body.try(:to_json) + headers = (headers || {}).merge('Content-Type' => LfsRequest::CONTENT_TYPE) + + post(url, params: params, headers: headers) end def json_response diff --git a/spec/requests/lfs_locks_api_spec.rb b/spec/requests/lfs_locks_api_spec.rb index a44b43a591f..28cb90e450e 100644 --- a/spec/requests/lfs_locks_api_spec.rb +++ b/spec/requests/lfs_locks_api_spec.rb @@ -146,11 +146,11 @@ describe 'Git LFS File Locking API' do end def post_lfs_json(url, body = nil, headers = nil) - post(url, body.try(:to_json), (headers || {}).merge('Content-Type' => LfsRequest::CONTENT_TYPE)) + post(url, params: body.try(:to_json), headers: (headers || {}).merge('Content-Type' => LfsRequest::CONTENT_TYPE)) end def do_get(url, params = nil, headers = nil) - get(url, (params || {}), (headers || {}).merge('Content-Type' => LfsRequest::CONTENT_TYPE)) + get(url, params: (params || {}), headers: (headers || {}).merge('Content-Type' => LfsRequest::CONTENT_TYPE)) end def json_response diff --git a/spec/requests/oauth_tokens_spec.rb b/spec/requests/oauth_tokens_spec.rb index 000c3a2b868..3873e754060 100644 --- a/spec/requests/oauth_tokens_spec.rb +++ b/spec/requests/oauth_tokens_spec.rb @@ -6,11 +6,13 @@ describe 'OAuth Tokens requests' do def request_access_token(user) post '/oauth/token', - grant_type: 'authorization_code', - code: generate_access_grant(user).token, - redirect_uri: application.redirect_uri, - client_id: application.uid, - client_secret: application.secret + params: { + grant_type: 'authorization_code', + code: generate_access_grant(user).token, + redirect_uri: application.redirect_uri, + client_id: application.uid, + client_secret: application.secret + } end def generate_access_grant(user) diff --git a/spec/requests/openid_connect_spec.rb b/spec/requests/openid_connect_spec.rb index b1cf7a531f4..ec546db335a 100644 --- a/spec/requests/openid_connect_spec.rb +++ b/spec/requests/openid_connect_spec.rb @@ -47,15 +47,17 @@ describe 'OpenID Connect requests' do login_as user post '/oauth/token', - grant_type: 'authorization_code', - code: access_grant.token, - redirect_uri: application.redirect_uri, - client_id: application.uid, - client_secret: application.secret + params: { + grant_type: 'authorization_code', + code: access_grant.token, + redirect_uri: application.redirect_uri, + client_id: application.uid, + client_secret: application.secret + } end def request_user_info! - get '/oauth/userinfo', nil, 'Authorization' => "Bearer #{access_token.token}" + get '/oauth/userinfo', params: {}, headers: { 'Authorization' => "Bearer #{access_token.token}" } end context 'Application without OpenID scope' do diff --git a/spec/requests/rack_attack_global_spec.rb b/spec/requests/rack_attack_global_spec.rb index c0a3ea397df..c27e27d3648 100644 --- a/spec/requests/rack_attack_global_spec.rb +++ b/spec/requests/rack_attack_global_spec.rb @@ -177,7 +177,7 @@ describe 'Rack Attack global throttles' do context 'when the request is to the api internal endpoints' do it 'allows requests over the rate limit' do (1 + requests_per_period).times do - get url_api_internal, secret_token: Gitlab::Shell.secret_token + get url_api_internal, params: { secret_token: Gitlab::Shell.secret_token } expect(response).to have_http_status 200 end end diff --git a/spec/requests/request_profiler_spec.rb b/spec/requests/request_profiler_spec.rb index 9afeb2983b0..284a51fcc32 100644 --- a/spec/requests/request_profiler_spec.rb +++ b/spec/requests/request_profiler_spec.rb @@ -18,7 +18,7 @@ describe 'Request Profiler' do path = "/#{project.full_path}" Timecop.freeze(time) do - get path, nil, 'X-Profile-Token' => Gitlab::RequestProfiler.profile_token + get path, params: {}, headers: { 'X-Profile-Token' => Gitlab::RequestProfiler.profile_token } end profile_path = "#{Gitlab.config.shared.path}/tmp/requests_profiles/#{path.tr('/', '|')}_#{time.to_i}.html" |