diff options
Diffstat (limited to 'spec/controllers/admin')
22 files changed, 76 insertions, 25 deletions
diff --git a/spec/controllers/admin/appearances_controller_spec.rb b/spec/controllers/admin/appearances_controller_spec.rb index 621aa148301..ee6a4a4c7af 100644 --- a/spec/controllers/admin/appearances_controller_spec.rb +++ b/spec/controllers/admin/appearances_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::AppearancesController do +RSpec.describe Admin::AppearancesController do let(:admin) { create(:admin) } let(:header_message) { 'Header message' } let(:footer_message) { 'Footer' } diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb index fe28e791ade..8ab29a72477 100644 --- a/spec/controllers/admin/application_settings_controller_spec.rb +++ b/spec/controllers/admin/application_settings_controller_spec.rb @@ -2,8 +2,9 @@ require 'spec_helper' -describe Admin::ApplicationSettingsController do +RSpec.describe Admin::ApplicationSettingsController do include StubENV + include UsageDataHelpers let(:group) { create(:group) } let(:project) { create(:project, namespace: group) } @@ -16,7 +17,7 @@ describe Admin::ApplicationSettingsController do describe 'GET #usage_data with no access' do before do - allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false) + stub_usage_data_connections sign_in(user) end @@ -29,7 +30,7 @@ describe Admin::ApplicationSettingsController do describe 'GET #usage_data' do before do - allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false) + stub_usage_data_connections sign_in(admin) end @@ -120,6 +121,13 @@ describe Admin::ApplicationSettingsController do expect(ApplicationSetting.current.namespace_storage_size_limit).not_to eq(-100) end + it 'updates repository_storages_weighted setting' do + put :update, params: { application_setting: { repository_storages_weighted_default: 75 } } + + expect(response).to redirect_to(general_admin_application_settings_path) + expect(ApplicationSetting.current.repository_storages_weighted_default).to eq(75) + end + context 'external policy classification settings' do let(:settings) do { diff --git a/spec/controllers/admin/applications_controller_spec.rb b/spec/controllers/admin/applications_controller_spec.rb index 163a2033b58..732d20666cb 100644 --- a/spec/controllers/admin/applications_controller_spec.rb +++ b/spec/controllers/admin/applications_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::ApplicationsController do +RSpec.describe Admin::ApplicationsController do let(:admin) { create(:admin) } let(:application) { create(:oauth_application, owner_id: nil, owner_type: nil) } diff --git a/spec/controllers/admin/ci/variables_controller_spec.rb b/spec/controllers/admin/ci/variables_controller_spec.rb index 57f2dd21f39..9f0a1bd3be1 100644 --- a/spec/controllers/admin/ci/variables_controller_spec.rb +++ b/spec/controllers/admin/ci/variables_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::Ci::VariablesController do +RSpec.describe Admin::Ci::VariablesController do let_it_be(:variable) { create(:ci_instance_variable) } before do diff --git a/spec/controllers/admin/clusters/applications_controller_spec.rb b/spec/controllers/admin/clusters/applications_controller_spec.rb index 44693505c4f..2a77693061c 100644 --- a/spec/controllers/admin/clusters/applications_controller_spec.rb +++ b/spec/controllers/admin/clusters/applications_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::Clusters::ApplicationsController do +RSpec.describe Admin::Clusters::ApplicationsController do include AccessMatchersForController def current_application diff --git a/spec/controllers/admin/clusters_controller_spec.rb b/spec/controllers/admin/clusters_controller_spec.rb index d4a12e0dc52..d899e86ae5f 100644 --- a/spec/controllers/admin/clusters_controller_spec.rb +++ b/spec/controllers/admin/clusters_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::ClustersController do +RSpec.describe Admin::ClustersController do include AccessMatchersForController include GoogleApi::CloudPlatformHelpers @@ -42,6 +42,13 @@ describe Admin::ClustersController do expect(response).to match_response_schema('cluster_list') end + it 'sets the polling interval header for json requests' do + get_index(format: :json) + + expect(response).to have_gitlab_http_status(:ok) + expect(response.headers['Poll-Interval']).to eq("10000") + end + context 'when page is specified' do let(:last_page) { Clusters::Cluster.instance_type.page.total_pages } let(:total_count) { Clusters::Cluster.instance_type.page.total_count } diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index 4de69a9aea1..283d82a3ab8 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::DashboardController do +RSpec.describe Admin::DashboardController do describe '#index' do context 'with pending_delete projects' do render_views diff --git a/spec/controllers/admin/gitaly_servers_controller_spec.rb b/spec/controllers/admin/gitaly_servers_controller_spec.rb index db94ea06f59..53f8a06ab52 100644 --- a/spec/controllers/admin/gitaly_servers_controller_spec.rb +++ b/spec/controllers/admin/gitaly_servers_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::GitalyServersController do +RSpec.describe Admin::GitalyServersController do describe '#index' do before do sign_in(create(:admin)) diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb index 1123563c1e3..3f32209543f 100644 --- a/spec/controllers/admin/groups_controller_spec.rb +++ b/spec/controllers/admin/groups_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::GroupsController do +RSpec.describe Admin::GroupsController do let(:group) { create(:group) } let(:project) { create(:project, namespace: group) } let(:admin) { create(:admin) } diff --git a/spec/controllers/admin/health_check_controller_spec.rb b/spec/controllers/admin/health_check_controller_spec.rb index cf5b27156c0..06aace429e3 100644 --- a/spec/controllers/admin/health_check_controller_spec.rb +++ b/spec/controllers/admin/health_check_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::HealthCheckController do +RSpec.describe Admin::HealthCheckController do let(:admin) { create(:admin) } before do diff --git a/spec/controllers/admin/hooks_controller_spec.rb b/spec/controllers/admin/hooks_controller_spec.rb index 9973ef93cd9..8975f746dd7 100644 --- a/spec/controllers/admin/hooks_controller_spec.rb +++ b/spec/controllers/admin/hooks_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::HooksController do +RSpec.describe Admin::HooksController do let(:admin) { create(:admin) } before do diff --git a/spec/controllers/admin/identities_controller_spec.rb b/spec/controllers/admin/identities_controller_spec.rb index f483c88d18d..6ac5ce13884 100644 --- a/spec/controllers/admin/identities_controller_spec.rb +++ b/spec/controllers/admin/identities_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::IdentitiesController do +RSpec.describe Admin::IdentitiesController do let(:admin) { create(:admin) } before do diff --git a/spec/controllers/admin/impersonations_controller_spec.rb b/spec/controllers/admin/impersonations_controller_spec.rb index fa3923bca8c..326003acaf8 100644 --- a/spec/controllers/admin/impersonations_controller_spec.rb +++ b/spec/controllers/admin/impersonations_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::ImpersonationsController do +RSpec.describe Admin::ImpersonationsController do let(:impersonator) { create(:admin) } let(:user) { create(:user) } diff --git a/spec/controllers/admin/integrations_controller_spec.rb b/spec/controllers/admin/integrations_controller_spec.rb index 817223bd91a..7e7b60db2dc 100644 --- a/spec/controllers/admin/integrations_controller_spec.rb +++ b/spec/controllers/admin/integrations_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::IntegrationsController do +RSpec.describe Admin::IntegrationsController do let(:admin) { create(:admin) } before do @@ -36,7 +36,9 @@ describe Admin::IntegrationsController do let(:integration) { create(:jira_service, :instance) } before do - put :update, params: { id: integration.class.to_param, service: { url: url } } + allow(PropagateIntegrationWorker).to receive(:perform_async) + + put :update, params: { id: integration.class.to_param, overwrite: true, service: { url: url } } end context 'valid params' do @@ -46,6 +48,10 @@ describe Admin::IntegrationsController do expect(response).to have_gitlab_http_status(:found) expect(integration.reload.url).to eq(url) end + + it 'calls to PropagateIntegrationWorker' do + expect(PropagateIntegrationWorker).to have_received(:perform_async).with(integration.id, true) + end end context 'invalid params' do @@ -56,6 +62,10 @@ describe Admin::IntegrationsController do expect(response).to render_template(:edit) expect(integration.reload.url).not_to eq(url) end + + it 'does not call to PropagateIntegrationWorker' do + expect(PropagateIntegrationWorker).not_to have_received(:perform_async) + end end end end diff --git a/spec/controllers/admin/projects_controller_spec.rb b/spec/controllers/admin/projects_controller_spec.rb index f0157fb4260..b5f411c9121 100644 --- a/spec/controllers/admin/projects_controller_spec.rb +++ b/spec/controllers/admin/projects_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::ProjectsController do +RSpec.describe Admin::ProjectsController do let!(:project) { create(:project, :public) } before do diff --git a/spec/controllers/admin/requests_profiles_controller_spec.rb b/spec/controllers/admin/requests_profiles_controller_spec.rb index 629233b04e7..7ee46b5b28a 100644 --- a/spec/controllers/admin/requests_profiles_controller_spec.rb +++ b/spec/controllers/admin/requests_profiles_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::RequestsProfilesController do +RSpec.describe Admin::RequestsProfilesController do let_it_be(:admin) { create(:admin) } before do diff --git a/spec/controllers/admin/runners_controller_spec.rb b/spec/controllers/admin/runners_controller_spec.rb index 803fcf90135..013eee19409 100644 --- a/spec/controllers/admin/runners_controller_spec.rb +++ b/spec/controllers/admin/runners_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::RunnersController do +RSpec.describe Admin::RunnersController do let_it_be(:runner) { create(:ci_runner) } before do diff --git a/spec/controllers/admin/serverless/domains_controller_spec.rb b/spec/controllers/admin/serverless/domains_controller_spec.rb index 43c3f0117bc..e7503fb37fa 100644 --- a/spec/controllers/admin/serverless/domains_controller_spec.rb +++ b/spec/controllers/admin/serverless/domains_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::Serverless::DomainsController do +RSpec.describe Admin::Serverless::DomainsController do let(:admin) { create(:admin) } let(:user) { create(:user) } diff --git a/spec/controllers/admin/services_controller_spec.rb b/spec/controllers/admin/services_controller_spec.rb index 5dde0d57293..2ad4989af4f 100644 --- a/spec/controllers/admin/services_controller_spec.rb +++ b/spec/controllers/admin/services_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::ServicesController do +RSpec.describe Admin::ServicesController do let(:admin) { create(:admin) } before do diff --git a/spec/controllers/admin/sessions_controller_spec.rb b/spec/controllers/admin/sessions_controller_spec.rb index 351148dbc65..82366cc6952 100644 --- a/spec/controllers/admin/sessions_controller_spec.rb +++ b/spec/controllers/admin/sessions_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::SessionsController, :do_not_mock_admin_mode do +RSpec.describe Admin::SessionsController, :do_not_mock_admin_mode do include_context 'custom session' let(:user) { create(:user) } diff --git a/spec/controllers/admin/spam_logs_controller_spec.rb b/spec/controllers/admin/spam_logs_controller_spec.rb index ec0d8c47660..13038339d08 100644 --- a/spec/controllers/admin/spam_logs_controller_spec.rb +++ b/spec/controllers/admin/spam_logs_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::SpamLogsController do +RSpec.describe Admin::SpamLogsController do let(:admin) { create(:admin) } let(:user) { create(:user) } let!(:first_spam) { create(:spam_log, user: user) } diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 7a7201a6454..08a1d7c9fa9 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Admin::UsersController do +RSpec.describe Admin::UsersController do let(:user) { create(:user) } let_it_be(:admin) { create(:admin) } @@ -254,6 +254,18 @@ describe Admin::UsersController do errors = assigns[:user].errors expect(errors).to contain_exactly(errors.full_message(:email, I18n.t('errors.messages.invalid'))) end + + context 'admin notes' do + it 'creates the user with note' do + note = '2020-05-12 | Note | DCMA | Link' + user_params = attributes_for(:user, note: note) + + expect { post :create, params: { user: user_params } }.to change { User.count }.by(1) + + new_user = User.last + expect(new_user.note).to eq(note) + end + end end describe 'POST update' do @@ -338,6 +350,20 @@ describe Admin::UsersController do end end end + + context 'admin notes' do + it 'updates the note for the user' do + note = '2020-05-12 | Note | DCMA | Link' + params = { + id: user.to_param, + user: { + note: note + } + } + + expect { post :update, params: params }.to change { user.reload.note }.to(note) + end + end end describe "DELETE #remove_email" do |