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/support | |
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/support')
7 files changed, 34 insertions, 34 deletions
diff --git a/spec/support/controllers/sessionless_auth_controller_shared_examples.rb b/spec/support/controllers/sessionless_auth_controller_shared_examples.rb index 7e4958f177a..355555d9d19 100644 --- a/spec/support/controllers/sessionless_auth_controller_shared_examples.rb +++ b/spec/support/controllers/sessionless_auth_controller_shared_examples.rb @@ -16,14 +16,14 @@ shared_examples 'authenticates sessionless user' do |path, format, params| .and increment(:user_session_override_counter) .and increment(:user_sessionless_authentication_counter) - get path, default_params.merge(private_token: personal_access_token.token) + get path, params: default_params.merge(private_token: personal_access_token.token) expect(response).to have_gitlab_http_status(200) expect(controller.current_user).to eq(user) end it 'does not log the user in if page is public', if: params[:public] do - get path, default_params + get path, params: default_params expect(response).to have_gitlab_http_status(200) expect(controller.current_user).to be_nil @@ -37,7 +37,7 @@ shared_examples 'authenticates sessionless user' do |path, format, params| personal_access_token.update(scopes: [:read_user]) - get path, default_params.merge(private_token: personal_access_token.token) + get path, params: default_params.merge(private_token: personal_access_token.token) expect(response).not_to have_gitlab_http_status(200) end @@ -51,7 +51,7 @@ shared_examples 'authenticates sessionless user' do |path, format, params| .and increment(:user_sessionless_authentication_counter) @request.headers['PRIVATE-TOKEN'] = personal_access_token.token - get path, default_params + get path, params: default_params expect(response).to have_gitlab_http_status(200) end @@ -64,7 +64,7 @@ shared_examples 'authenticates sessionless user' do |path, format, params| .and increment(:user_session_override_counter) .and increment(:user_sessionless_authentication_counter) - get path, default_params.merge(feed_token: user.feed_token) + get path, params: default_params.merge(feed_token: user.feed_token) expect(response).to have_gitlab_http_status 200 end @@ -75,7 +75,7 @@ shared_examples 'authenticates sessionless user' do |path, format, params| expect(authentication_metrics) .to increment(:user_unauthenticated_counter) - get path, default_params.merge(feed_token: 'token') + get path, params: default_params.merge(feed_token: 'token') expect(response.status).not_to eq 200 end @@ -85,7 +85,7 @@ shared_examples 'authenticates sessionless user' do |path, format, params| expect(authentication_metrics) .to increment(:user_unauthenticated_counter) - get path, default_params.merge(private_token: 'token') + get path, params: default_params.merge(private_token: 'token') expect(response.status).not_to eq(200) end diff --git a/spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb b/spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb index 95e69328080..dbdca99b5aa 100644 --- a/spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb +++ b/spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb @@ -2,7 +2,7 @@ shared_examples 'issuable notes filter' do it 'sets discussion filter' do notes_filter = UserPreference::NOTES_FILTERS[:only_comments] - get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter + get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter } expect(user.reload.notes_filter_for(issuable)).to eq(notes_filter) expect(UserPreference.count).to eq(1) @@ -13,7 +13,7 @@ shared_examples 'issuable notes filter' do expect_any_instance_of(issuable.class).to receive(:expire_note_etag_cache) - get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter + get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter } end it 'does not expires notes e-tag cache for issuable if filter did not change' do @@ -22,14 +22,14 @@ shared_examples 'issuable notes filter' do expect_any_instance_of(issuable.class).not_to receive(:expire_note_etag_cache) - get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter + get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter } end it 'does not set notes filter when database is in read only mode' do allow(Gitlab::Database).to receive(:read_only?).and_return(true) notes_filter = UserPreference::NOTES_FILTERS[:only_comments] - get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter + get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issuable.iid, notes_filter: notes_filter } expect(user.reload.notes_filter_for(issuable)).to eq(0) end @@ -37,7 +37,7 @@ shared_examples 'issuable notes filter' do it 'returns only user comments' do user.set_notes_filter(UserPreference::NOTES_FILTERS[:only_comments], issuable) - get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid + get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issuable.iid } discussions = JSON.parse(response.body) expect(discussions.count).to eq(1) @@ -47,7 +47,7 @@ shared_examples 'issuable notes filter' do it 'returns only activity notes' do user.set_notes_filter(UserPreference::NOTES_FILTERS[:only_activity], issuable) - get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid + get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issuable.iid } discussions = JSON.parse(response.body) expect(discussions.count).to eq(1) @@ -60,7 +60,7 @@ shared_examples 'issuable notes filter' do expect(ResourceEvents::MergeIntoNotesService).not_to receive(:new) - get :discussions, namespace_id: project.namespace, project_id: project, id: issuable.iid + get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issuable.iid } end end end diff --git a/spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb b/spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb index b34948be670..d86838719d4 100644 --- a/spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb +++ b/spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb @@ -15,7 +15,7 @@ shared_examples 'set sort order from user preference' do expect_any_instance_of(UserPreference).not_to receive(:update_attribute).with(sorting_field, sorting_param) - get :index, namespace_id: project.namespace, project_id: project, sort: sorting_param + get :index, params: { namespace_id: project.namespace, project_id: project, sort: sorting_param } end end @@ -25,7 +25,7 @@ shared_examples 'set sort order from user preference' do expect_any_instance_of(UserPreference).to receive(:update_attribute).with(sorting_field, sorting_param) - get :index, namespace_id: project.namespace, project_id: project, sort: sorting_param + get :index, params: { namespace_id: project.namespace, project_id: project, sort: sorting_param } end end end diff --git a/spec/support/shared_examples/issuables_list_metadata_shared_examples.rb b/spec/support/shared_examples/issuables_list_metadata_shared_examples.rb index f4bc6f8efa5..90d67fd00fc 100644 --- a/spec/support/shared_examples/issuables_list_metadata_shared_examples.rb +++ b/spec/support/shared_examples/issuables_list_metadata_shared_examples.rb @@ -3,9 +3,9 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil| def get_action(action, project) if action - get action, author_id: project.creator.id + get action, params: { author_id: project.creator.id } else - get :index, namespace_id: project.namespace, project_id: project + get :index, params: { namespace_id: project.namespace, project_id: project } end end @@ -51,9 +51,9 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil| it "doesn't execute any queries with false conditions" do get_empty = if action - proc { get action, author_id: project.creator.id } + proc { get action, params: { author_id: project.creator.id } } else - proc { get :index, namespace_id: project2.namespace, project_id: project2 } + proc { get :index, params: { namespace_id: project2.namespace, project_id: project2 } } end expect(&get_empty).not_to make_queries_matching(/WHERE (?:1=0|0=1)/) diff --git a/spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb b/spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb index 9fc2fbef449..8a7fcf856a1 100644 --- a/spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb @@ -9,7 +9,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| context 'with an unauthorized user' do it 'does not filter by custom attributes' do - get api("/#{attributable_name}", user), custom_attributes: { foo: 'foo', bar: 'bar' } + get api("/#{attributable_name}", user), params: { custom_attributes: { foo: 'foo', bar: 'bar' } } expect(response).to have_gitlab_http_status(200) expect(json_response.size).to be 2 @@ -19,7 +19,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| context 'with an authorized user' do it 'filters by custom attributes' do - get api("/#{attributable_name}", admin), custom_attributes: { foo: 'foo', bar: 'bar' } + get api("/#{attributable_name}", admin), params: { custom_attributes: { foo: 'foo', bar: 'bar' } } expect(response).to have_gitlab_http_status(200) expect(json_response.size).to be 1 @@ -35,7 +35,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| context 'with an unauthorized user' do it 'does not include custom attributes' do - get api("/#{attributable_name}", user), with_custom_attributes: true + get api("/#{attributable_name}", user), params: { with_custom_attributes: true } expect(response).to have_gitlab_http_status(200) expect(json_response.size).to be 2 @@ -54,7 +54,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| end it 'includes custom attributes if requested' do - get api("/#{attributable_name}", admin), with_custom_attributes: true + get api("/#{attributable_name}", admin), params: { with_custom_attributes: true } expect(response).to have_gitlab_http_status(200) expect(json_response.size).to be 2 @@ -75,7 +75,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| describe "GET /#{attributable_name}/:id with custom attributes" do context 'with an unauthorized user' do it 'does not include custom attributes' do - get api("/#{attributable_name}/#{attributable.id}", user), with_custom_attributes: true + get api("/#{attributable_name}/#{attributable.id}", user), params: { with_custom_attributes: true } expect(response).to have_gitlab_http_status(200) expect(json_response).not_to include 'custom_attributes' @@ -91,7 +91,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| end it 'includes custom attributes if requested' do - get api("/#{attributable_name}/#{attributable.id}", admin), with_custom_attributes: true + get api("/#{attributable_name}/#{attributable.id}", admin), params: { with_custom_attributes: true } expect(response).to have_gitlab_http_status(200) expect(json_response['custom_attributes']).to contain_exactly( @@ -141,7 +141,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| describe "PUT /#{attributable_name}/:id/custom_attributes/:key" do context 'with an unauthorized user' do - subject { put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", user), value: 'new' } + subject { put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", user), params: { value: 'new' } } it_behaves_like 'an unauthorized API user' end @@ -149,7 +149,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| context 'with an authorized user' do it 'creates a new custom attribute' do expect do - put api("/#{attributable_name}/#{attributable.id}/custom_attributes/new", admin), value: 'new' + put api("/#{attributable_name}/#{attributable.id}/custom_attributes/new", admin), params: { value: 'new' } end.to change { attributable.custom_attributes.count }.by(1) expect(response).to have_gitlab_http_status(200) @@ -159,7 +159,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| it 'updates an existing custom attribute' do expect do - put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin), value: 'new' + put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin), params: { value: 'new' } end.not_to change { attributable.custom_attributes.count } expect(response).to have_gitlab_http_status(200) diff --git a/spec/support/shared_examples/requests/api/status_shared_examples.rb b/spec/support/shared_examples/requests/api/status_shared_examples.rb index 0ed917e448a..ebfc5fed3bb 100644 --- a/spec/support/shared_examples/requests/api/status_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/status_shared_examples.rb @@ -54,7 +54,7 @@ shared_examples_for '412 response' do context 'for a modified ressource' do before do - delete request, params, { 'HTTP_IF_UNMODIFIED_SINCE' => '1990-01-12T00:00:48-0600' } + delete request, params: params, headers: { 'HTTP_IF_UNMODIFIED_SINCE' => '1990-01-12T00:00:48-0600' } end it 'returns 412' do @@ -64,7 +64,7 @@ shared_examples_for '412 response' do context 'for an unmodified ressource' do before do - delete request, params, { 'HTTP_IF_UNMODIFIED_SINCE' => Time.now } + delete request, params: params, headers: { 'HTTP_IF_UNMODIFIED_SINCE' => Time.now } end it 'returns accepted' do diff --git a/spec/support/shared_examples/update_invalid_issuable.rb b/spec/support/shared_examples/update_invalid_issuable.rb index 1490287681b..64568de424e 100644 --- a/spec/support/shared_examples/update_invalid_issuable.rb +++ b/spec/support/shared_examples/update_invalid_issuable.rb @@ -26,7 +26,7 @@ shared_examples 'update invalid issuable' do |klass| end it 'renders edit when format is html' do - put :update, params + put :update, params: params expect(response).to render_template(:edit) expect(assigns[:conflict]).to be_truthy @@ -35,7 +35,7 @@ shared_examples 'update invalid issuable' do |klass| it 'renders json error message when format is json' do params[:format] = "json" - put :update, params + put :update, params: params expect(response.status).to eq(409) expect(JSON.parse(response.body)).to have_key('errors') @@ -49,7 +49,7 @@ shared_examples 'update invalid issuable' do |klass| end it 'renders edit when merge request is invalid' do - put :update, params + put :update, params: params expect(response).to render_template(:edit) end |