diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-12-18 09:52:17 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-12-19 10:04:31 +1100 |
commit | b44a2c801a64fb282cea794871fcfcf81e4ec539 (patch) | |
tree | 32e699b6efa548048abe11f29f84e85e3d2a034f /spec/controllers/admin | |
parent | 5d68c23792e87e710877e4baf57605bcf11a6cb5 (diff) | |
download | gitlab-ce-b44a2c801a64fb282cea794871fcfcf81e4ec539.tar.gz |
Update specs to rails5 formatblackst0ne-convert-specs-rails5-style
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/controllers/admin')
10 files changed, 63 insertions, 57 deletions
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb index 2e0f79cd313..9af472df74e 100644 --- a/spec/controllers/admin/application_settings_controller_spec.rb +++ b/spec/controllers/admin/application_settings_controller_spec.rb @@ -52,35 +52,35 @@ describe Admin::ApplicationSettingsController do end it 'updates the password_authentication_enabled_for_git setting' do - put :update, application_setting: { password_authentication_enabled_for_git: "0" } + put :update, params: { application_setting: { password_authentication_enabled_for_git: "0" } } expect(response).to redirect_to(admin_application_settings_path) expect(ApplicationSetting.current.password_authentication_enabled_for_git).to eq(false) end it 'updates the default_project_visibility for string value' do - put :update, application_setting: { default_project_visibility: "20" } + put :update, params: { application_setting: { default_project_visibility: "20" } } expect(response).to redirect_to(admin_application_settings_path) expect(ApplicationSetting.current.default_project_visibility).to eq(Gitlab::VisibilityLevel::PUBLIC) end it 'update the restricted levels for string values' do - put :update, application_setting: { restricted_visibility_levels: %w[10 20] } + put :update, params: { application_setting: { restricted_visibility_levels: %w[10 20] } } expect(response).to redirect_to(admin_application_settings_path) expect(ApplicationSetting.current.restricted_visibility_levels).to eq([10, 20]) end it 'updates the restricted_visibility_levels when empty array is passed' do - put :update, application_setting: { restricted_visibility_levels: [""] } + put :update, params: { application_setting: { restricted_visibility_levels: [""] } } expect(response).to redirect_to(admin_application_settings_path) expect(ApplicationSetting.current.restricted_visibility_levels).to be_empty end it 'updates the receive_max_input_size setting' do - put :update, application_setting: { receive_max_input_size: "1024" } + put :update, params: { application_setting: { receive_max_input_size: "1024" } } expect(response).to redirect_to(admin_application_settings_path) expect(ApplicationSetting.current.receive_max_input_size).to eq(1024) diff --git a/spec/controllers/admin/applications_controller_spec.rb b/spec/controllers/admin/applications_controller_spec.rb index 7bd6c0e6117..7e1ce70dc7d 100644 --- a/spec/controllers/admin/applications_controller_spec.rb +++ b/spec/controllers/admin/applications_controller_spec.rb @@ -19,7 +19,7 @@ describe Admin::ApplicationsController do describe 'GET #edit' do it 'renders the application form' do - get :edit, id: application.id + get :edit, params: { id: application.id } expect(response).to render_template :edit expect(assigns[:scopes]).to be_kind_of(Doorkeeper::OAuth::Scopes) @@ -31,7 +31,7 @@ describe Admin::ApplicationsController do create_params = attributes_for(:application, trusted: true) expect do - post :create, doorkeeper_application: create_params + post :create, params: { doorkeeper_application: create_params } end.to change { Doorkeeper::Application.count }.by(1) application = Doorkeeper::Application.last @@ -42,7 +42,7 @@ describe Admin::ApplicationsController do it 'renders the application form on errors' do expect do - post :create, doorkeeper_application: attributes_for(:application).merge(redirect_uri: nil) + post :create, params: { doorkeeper_application: attributes_for(:application).merge(redirect_uri: nil) } end.not_to change { Doorkeeper::Application.count } expect(response).to render_template :new @@ -52,7 +52,7 @@ describe Admin::ApplicationsController do describe 'PATCH #update' do it 'updates the application' do - patch :update, id: application.id, doorkeeper_application: { redirect_uri: 'http://example.com/', trusted: true } + patch :update, params: { id: application.id, doorkeeper_application: { redirect_uri: 'http://example.com/', trusted: true } } application.reload @@ -61,7 +61,7 @@ describe Admin::ApplicationsController do end it 'renders the application form on errors' do - patch :update, id: application.id, doorkeeper_application: { redirect_uri: nil } + patch :update, params: { id: application.id, doorkeeper_application: { redirect_uri: nil } } expect(response).to render_template :edit expect(assigns[:scopes]).to be_kind_of(Doorkeeper::OAuth::Scopes) diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb index 0dad95e418f..647fce0ecef 100644 --- a/spec/controllers/admin/groups_controller_spec.rb +++ b/spec/controllers/admin/groups_controller_spec.rb @@ -12,12 +12,12 @@ describe Admin::GroupsController do describe 'DELETE #destroy' do it 'schedules a group destroy' do Sidekiq::Testing.fake! do - expect { delete :destroy, id: project.group.path }.to change(GroupDestroyWorker.jobs, :size).by(1) + expect { delete :destroy, params: { id: project.group.path } }.to change(GroupDestroyWorker.jobs, :size).by(1) end end it 'redirects to the admin group path' do - delete :destroy, id: project.group.path + delete :destroy, params: { id: project.group.path } expect(response).to redirect_to(admin_groups_path) end @@ -27,9 +27,11 @@ describe Admin::GroupsController do let(:group_user) { create(:user) } it 'adds user to members' do - put :members_update, id: group, - user_ids: group_user.id, - access_level: Gitlab::Access::GUEST + put :members_update, params: { + id: group, + user_ids: group_user.id, + access_level: Gitlab::Access::GUEST + } expect(response).to set_flash.to 'Users were successfully added.' expect(response).to redirect_to(admin_group_path(group)) @@ -37,18 +39,22 @@ describe Admin::GroupsController do end it 'can add unlimited members' do - put :members_update, id: group, - user_ids: 1.upto(1000).to_a.join(','), - access_level: Gitlab::Access::GUEST + put :members_update, params: { + id: group, + user_ids: 1.upto(1000).to_a.join(','), + access_level: Gitlab::Access::GUEST + } expect(response).to set_flash.to 'Users were successfully added.' expect(response).to redirect_to(admin_group_path(group)) end it 'adds no user to members' do - put :members_update, id: group, - user_ids: '', - access_level: Gitlab::Access::GUEST + put :members_update, params: { + id: group, + user_ids: '', + access_level: Gitlab::Access::GUEST + } expect(response).to set_flash.to 'No users specified.' expect(response).to redirect_to(admin_group_path(group)) diff --git a/spec/controllers/admin/hooks_controller_spec.rb b/spec/controllers/admin/hooks_controller_spec.rb index d2c1e634930..9bc58344e4e 100644 --- a/spec/controllers/admin/hooks_controller_spec.rb +++ b/spec/controllers/admin/hooks_controller_spec.rb @@ -20,7 +20,7 @@ describe Admin::HooksController do merge_requests_events: true } - post :create, hook: hook_params + post :create, params: { hook: hook_params } expect(response).to have_gitlab_http_status(302) expect(SystemHook.all.size).to eq(1) diff --git a/spec/controllers/admin/identities_controller_spec.rb b/spec/controllers/admin/identities_controller_spec.rb index a29853bf8df..e5428c8ddeb 100644 --- a/spec/controllers/admin/identities_controller_spec.rb +++ b/spec/controllers/admin/identities_controller_spec.rb @@ -13,7 +13,7 @@ describe Admin::IdentitiesController do it 'repairs ldap blocks' do expect_any_instance_of(RepairLdapBlockedUserService).to receive(:execute) - put :update, user_id: user.username, id: user.ldap_identity.id, identity: { provider: 'twitter' } + put :update, params: { user_id: user.username, id: user.ldap_identity.id, identity: { provider: 'twitter' } } end end @@ -23,7 +23,7 @@ describe Admin::IdentitiesController do it 'repairs ldap blocks' do expect_any_instance_of(RepairLdapBlockedUserService).to receive(:execute) - delete :destroy, user_id: user.username, id: user.ldap_identity.id + delete :destroy, params: { user_id: user.username, id: user.ldap_identity.id } end end end diff --git a/spec/controllers/admin/projects_controller_spec.rb b/spec/controllers/admin/projects_controller_spec.rb index ee1aff09bdf..8166657f674 100644 --- a/spec/controllers/admin/projects_controller_spec.rb +++ b/spec/controllers/admin/projects_controller_spec.rb @@ -11,13 +11,13 @@ describe Admin::ProjectsController do render_views it 'retrieves the project for the given visibility level' do - get :index, visibility_level: [Gitlab::VisibilityLevel::PUBLIC] + get :index, params: { visibility_level: [Gitlab::VisibilityLevel::PUBLIC] } expect(response.body).to match(project.name) end it 'does not retrieve the project' do - get :index, visibility_level: [Gitlab::VisibilityLevel::INTERNAL] + get :index, params: { visibility_level: [Gitlab::VisibilityLevel::INTERNAL] } expect(response.body).not_to match(project.name) end @@ -47,7 +47,7 @@ describe Admin::ProjectsController do render_views it 'renders show page' do - get :show, namespace_id: project.namespace.path, id: project.path + get :show, params: { namespace_id: project.namespace.path, id: project.path } expect(response).to have_gitlab_http_status(200) expect(response.body).to match(project.name) diff --git a/spec/controllers/admin/runners_controller_spec.rb b/spec/controllers/admin/runners_controller_spec.rb index 312dbdd0624..4cf14030ca1 100644 --- a/spec/controllers/admin/runners_controller_spec.rb +++ b/spec/controllers/admin/runners_controller_spec.rb @@ -17,13 +17,13 @@ describe Admin::RunnersController do describe '#show' do it 'shows a particular runner' do - get :show, id: runner.id + get :show, params: { id: runner.id } expect(response).to have_gitlab_http_status(200) end it 'shows 404 for unknown runner' do - get :show, id: 0 + get :show, params: { id: 0 } expect(response).to have_gitlab_http_status(404) end @@ -34,7 +34,7 @@ describe Admin::RunnersController do new_desc = runner.description.swapcase expect do - post :update, id: runner.id, runner: { description: new_desc } + post :update, params: { id: runner.id, runner: { description: new_desc } } end.to change { runner.ensure_runner_queue_value } runner.reload @@ -46,7 +46,7 @@ describe Admin::RunnersController do describe '#destroy' do it 'destroys the runner' do - delete :destroy, id: runner.id + delete :destroy, params: { id: runner.id } expect(response).to have_gitlab_http_status(302) expect(Ci::Runner.find_by(id: runner.id)).to be_nil @@ -58,7 +58,7 @@ describe Admin::RunnersController do runner.update(active: false) expect do - post :resume, id: runner.id + post :resume, params: { id: runner.id } end.to change { runner.ensure_runner_queue_value } runner.reload @@ -73,7 +73,7 @@ describe Admin::RunnersController do runner.update(active: true) expect do - post :pause, id: runner.id + post :pause, params: { id: runner.id } end.to change { runner.ensure_runner_queue_value } runner.reload diff --git a/spec/controllers/admin/services_controller_spec.rb b/spec/controllers/admin/services_controller_spec.rb index 4439ea4a533..ec161b92245 100644 --- a/spec/controllers/admin/services_controller_spec.rb +++ b/spec/controllers/admin/services_controller_spec.rb @@ -18,7 +18,7 @@ describe Admin::ServicesController do end it 'successfully displays the template' do - get :edit, id: service.id + get :edit, params: { id: service.id } expect(response).to have_gitlab_http_status(200) end @@ -44,7 +44,7 @@ describe Admin::ServicesController do it 'calls the propagation worker when service is active' do expect(PropagateServiceTemplateWorker).to receive(:perform_async).with(service.id) - put :update, id: service.id, service: { active: true } + put :update, params: { id: service.id, service: { active: true } } expect(response).to have_gitlab_http_status(302) end @@ -52,7 +52,7 @@ describe Admin::ServicesController do it 'does not call the propagation worker when service is not active' do expect(PropagateServiceTemplateWorker).not_to receive(:perform_async) - put :update, id: service.id, service: { properties: {} } + put :update, params: { id: service.id, service: { properties: {} } } expect(response).to have_gitlab_http_status(302) end diff --git a/spec/controllers/admin/spam_logs_controller_spec.rb b/spec/controllers/admin/spam_logs_controller_spec.rb index 7a96ef6a5cc..2b946ec1c68 100644 --- a/spec/controllers/admin/spam_logs_controller_spec.rb +++ b/spec/controllers/admin/spam_logs_controller_spec.rb @@ -20,13 +20,13 @@ describe Admin::SpamLogsController do describe '#destroy' do it 'removes only the spam log when removing log' do - expect { delete :destroy, id: first_spam.id }.to change { SpamLog.count }.by(-1) + expect { delete :destroy, params: { id: first_spam.id } }.to change { SpamLog.count }.by(-1) expect(User.find(user.id)).to be_truthy expect(response).to have_gitlab_http_status(200) end it 'removes user and his spam logs when removing the user' do - delete :destroy, id: first_spam.id, remove_user: true + delete :destroy, params: { id: first_spam.id, remove_user: true } expect(flash[:notice]).to eq "User #{user.username} was successfully removed." expect(response).to have_gitlab_http_status(302) @@ -40,7 +40,7 @@ describe Admin::SpamLogsController do allow_any_instance_of(AkismetService).to receive(:submit_ham).and_return(true) end it 'submits the log as ham' do - post :mark_as_ham, id: first_spam.id + post :mark_as_ham, params: { id: first_spam.id } expect(response).to have_gitlab_http_status(302) expect(SpamLog.find(first_spam.id).submitted_as_ham).to be_truthy diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 3dd0b2623ac..6b66cbd2651 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -17,7 +17,7 @@ describe Admin::UsersController do end it 'deletes user and ghosts their contributions' do - delete :destroy, id: user.username, format: :json + delete :destroy, params: { id: user.username }, format: :json expect(response).to have_gitlab_http_status(200) expect(User.exists?(user.id)).to be_falsy @@ -25,7 +25,7 @@ describe Admin::UsersController do end it 'deletes the user and their contributions when hard delete is specified' do - delete :destroy, id: user.username, hard_delete: true, format: :json + delete :destroy, params: { id: user.username, hard_delete: true }, format: :json expect(response).to have_gitlab_http_status(200) expect(User.exists?(user.id)).to be_falsy @@ -35,7 +35,7 @@ describe Admin::UsersController do describe 'PUT block/:id' do it 'blocks user' do - put :block, id: user.username + put :block, params: { id: user.username } user.reload expect(user.blocked?).to be_truthy expect(flash[:notice]).to eq 'Successfully blocked' @@ -51,7 +51,7 @@ describe Admin::UsersController do end it 'does not unblock user' do - put :unblock, id: user.username + put :unblock, params: { id: user.username } user.reload expect(user.blocked?).to be_truthy expect(flash[:alert]).to eq 'This user cannot be unlocked manually from GitLab' @@ -64,7 +64,7 @@ describe Admin::UsersController do end it 'unblocks user' do - put :unblock, id: user.username + put :unblock, params: { id: user.username } user.reload expect(user.blocked?).to be_falsey expect(flash[:notice]).to eq 'Successfully unblocked' @@ -79,7 +79,7 @@ describe Admin::UsersController do end it 'unlocks user' do - put :unlock, id: user.username + put :unlock, params: { id: user.username } user.reload expect(user.access_locked?).to be_falsey end @@ -93,7 +93,7 @@ describe Admin::UsersController do end it 'confirms user' do - put :confirm, id: user.username + put :confirm, params: { id: user.username } user.reload expect(user.confirmed?).to be_truthy end @@ -121,17 +121,17 @@ describe Admin::UsersController do end def go - patch :disable_two_factor, id: user.to_param + patch :disable_two_factor, params: { id: user.to_param } end end describe 'POST create' do it 'creates the user' do - expect { post :create, user: attributes_for(:user) }.to change { User.count }.by(1) + expect { post :create, params: { user: attributes_for(:user) } }.to change { User.count }.by(1) end it 'shows only one error message for an invalid email' do - post :create, user: attributes_for(:user, email: 'bogus') + post :create, params: { user: attributes_for(:user, email: 'bogus') } expect(assigns[:user].errors).to contain_exactly("Email is invalid") end end @@ -147,7 +147,7 @@ describe Admin::UsersController do } } - post :update, params + post :update, params: params end context 'when the admin changes his own password' do @@ -227,13 +227,13 @@ describe Admin::UsersController do end it "shows a notice" do - post :impersonate, id: user.username + post :impersonate, params: { id: user.username } expect(flash[:alert]).to eq("You cannot impersonate a blocked user") end it "doesn't sign us in as the user" do - post :impersonate, id: user.username + post :impersonate, params: { id: user.username } expect(warden.user).to eq(admin) end @@ -241,25 +241,25 @@ describe Admin::UsersController do context "when the user is not blocked" do it "stores the impersonator in the session" do - post :impersonate, id: user.username + post :impersonate, params: { id: user.username } expect(session[:impersonator_id]).to eq(admin.id) end it "signs us in as the user" do - post :impersonate, id: user.username + post :impersonate, params: { id: user.username } expect(warden.user).to eq(user) end it "redirects to root" do - post :impersonate, id: user.username + post :impersonate, params: { id: user.username } expect(response).to redirect_to(root_path) end it "shows a notice" do - post :impersonate, id: user.username + post :impersonate, params: { id: user.username } expect(flash[:alert]).to eq("You are now impersonating #{user.username}") end @@ -271,7 +271,7 @@ describe Admin::UsersController do end it "shows error page" do - post :impersonate, id: user.username + post :impersonate, params: { id: user.username } expect(response).to have_gitlab_http_status(404) end |