diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-07-20 18:40:28 +0300 |
commit | b595cb0c1dec83de5bdee18284abe86614bed33b (patch) | |
tree | 8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/controllers/admin | |
parent | 2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff) |
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/controllers/admin')
-rw-r--r-- | spec/controllers/admin/application_settings_controller_spec.rb | 18 | ||||
-rw-r--r-- | spec/controllers/admin/hooks_controller_spec.rb | 36 | ||||
-rw-r--r-- | spec/controllers/admin/topics_controller_spec.rb | 22 |
3 files changed, 73 insertions, 3 deletions
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb index 4a92911f914..e02589ddc83 100644 --- a/spec/controllers/admin/application_settings_controller_spec.rb +++ b/spec/controllers/admin/application_settings_controller_spec.rb @@ -382,6 +382,24 @@ RSpec.describe Admin::ApplicationSettingsController, :do_not_mock_admin_mode_set end end + describe 'PUT #reset_error_tracking_access_token' do + before do + sign_in(admin) + end + + subject { put :reset_error_tracking_access_token } + + it 'resets error_tracking_access_token' do + expect { subject }.to change { ApplicationSetting.current.error_tracking_access_token } + end + + it 'redirects the user to application settings page' do + subject + + expect(response).to redirect_to(general_admin_application_settings_path) + end + end + describe 'GET #lets_encrypt_terms_of_service' do include LetsEncryptHelpers diff --git a/spec/controllers/admin/hooks_controller_spec.rb b/spec/controllers/admin/hooks_controller_spec.rb index 17c4222530d..14f4a2f40e7 100644 --- a/spec/controllers/admin/hooks_controller_spec.rb +++ b/spec/controllers/admin/hooks_controller_spec.rb @@ -17,16 +17,46 @@ RSpec.describe Admin::HooksController do url: "http://example.com", push_events: true, - tag_push_events: true, + tag_push_events: false, repository_update_events: true, - merge_requests_events: true + merge_requests_events: false, + url_variables: [{ key: 'token', value: 'some secret value' }] } post :create, params: { hook: hook_params } expect(response).to have_gitlab_http_status(:found) expect(SystemHook.all.size).to eq(1) - expect(SystemHook.first).to have_attributes(hook_params) + expect(SystemHook.first).to have_attributes(hook_params.except(:url_variables)) + expect(SystemHook.first).to have_attributes(url_variables: { 'token' => 'some secret value' }) + end + end + + describe 'POST #update' do + let!(:hook) { create(:system_hook) } + + it 'sets all parameters' do + hook.update!(url_variables: { 'foo' => 'bar', 'baz' => 'woo' }) + + hook_params = { + url: 'http://example.com/{baz}?token={token}', + enable_ssl_verification: false, + url_variables: [ + { key: 'token', value: 'some secret value' }, + { key: 'foo', value: nil } + ] + } + + put :update, params: { id: hook.id, hook: hook_params } + + hook.reload + + expect(response).to have_gitlab_http_status(:found) + expect(flash[:notice]).to include('successfully updated') + expect(hook).to have_attributes(hook_params.except(:url_variables)) + expect(hook).to have_attributes( + url_variables: { 'token' => 'some secret value', 'baz' => 'woo' } + ) end end diff --git a/spec/controllers/admin/topics_controller_spec.rb b/spec/controllers/admin/topics_controller_spec.rb index 67943525687..ee36d5f1def 100644 --- a/spec/controllers/admin/topics_controller_spec.rb +++ b/spec/controllers/admin/topics_controller_spec.rb @@ -151,4 +151,26 @@ RSpec.describe Admin::TopicsController do end end end + + describe 'DELETE #destroy' do + it 'removes topic' do + delete :destroy, params: { id: topic.id } + + expect(response).to redirect_to(admin_topics_path) + expect { topic.reload }.to raise_error(ActiveRecord::RecordNotFound) + end + + context 'as a normal user' do + before do + sign_in(user) + end + + it 'renders a 404 error' do + delete :destroy, params: { id: topic.id } + + expect(response).to have_gitlab_http_status(:not_found) + expect { topic.reload }.not_to raise_error + end + end + end end |