diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-12-19 10:11:12 +0300 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-12-19 10:11:12 +0300 |
commit | b1b7fa7802eecbacff04a9434eff69b0f3cbaaad (patch) | |
tree | a9ac9a5c7fa512dfec9c7460089992d353a4d907 /spec/support/shared_examples | |
parent | fca9e0f3641d63ed2a15b26b3bf3fb838b79e3d5 (diff) | |
parent | b44a2c801a64fb282cea794871fcfcf81e4ec539 (diff) |
Merge branch 'blackst0ne-convert-specs-rails5-style' into 'master'
[Rails5.1] Update functional specs to use new keyword format
Closes #54062
See merge request gitlab-org/gitlab-ce!23095
Diffstat (limited to 'spec/support/shared_examples')
6 files changed, 27 insertions, 27 deletions
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 |