diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 15:09:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 15:09:08 +0300 |
commit | 7cc6872401eb487ed20dbb9d455f8bb9c97d9e39 (patch) | |
tree | 63f6ed5d4e6c5cec31c43363626d9f5b178eddf8 /app/controllers/admin | |
parent | 46b10c0fc884400941c17e2777b242ac54d111e5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/admin')
-rw-r--r-- | app/controllers/admin/application_settings_controller.rb | 36 | ||||
-rw-r--r-- | app/controllers/admin/spam_logs_controller.rb | 2 |
2 files changed, 25 insertions, 13 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 20daf6d71b3..f4e79ae6060 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -3,7 +3,13 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController include InternalRedirect + # NOTE: Use @application_setting in this controller when you need to access + # application_settings after it has been modified. This is because the + # ApplicationSetting model uses Gitlab::ThreadMemoryCache for caching and the + # cache might be stale immediately after an update. + # https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/30233 before_action :set_application_setting + before_action :whitelist_query_limiting, only: [:usage_data] before_action :validate_self_monitoring_feature_flag_enabled, only: [ :create_self_monitoring_project, @@ -79,6 +85,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController redirect_to ::Gitlab::LetsEncrypt.terms_of_service_url end + # Specs are in spec/requests/self_monitoring_project_spec.rb def create_self_monitoring_project job_id = SelfMonitoringProjectCreateWorker.perform_async @@ -88,6 +95,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController } end + # Specs are in spec/requests/self_monitoring_project_spec.rb def status_create_self_monitoring_project job_id = params[:job_id].to_s @@ -98,10 +106,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController } end - if Gitlab::CurrentSettings.self_monitoring_project_id.present? - return render status: :ok, json: self_monitoring_data - - elsif SelfMonitoringProjectCreateWorker.in_progress?(job_id) + if SelfMonitoringProjectCreateWorker.in_progress?(job_id) ::Gitlab::PollingInterval.set_header(response, interval: 3_000) return render status: :accepted, json: { @@ -109,12 +114,17 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController } end + if @application_setting.self_monitoring_project_id.present? + return render status: :ok, json: self_monitoring_data + end + render status: :bad_request, json: { message: _('Self-monitoring project does not exist. Please check logs ' \ 'for any error messages') } end + # Specs are in spec/requests/self_monitoring_project_spec.rb def delete_self_monitoring_project job_id = SelfMonitoringProjectDeleteWorker.perform_async @@ -124,6 +134,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController } end + # Specs are in spec/requests/self_monitoring_project_spec.rb def status_delete_self_monitoring_project job_id = params[:job_id].to_s @@ -134,12 +145,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController } end - if Gitlab::CurrentSettings.self_monitoring_project_id.nil? - return render status: :ok, json: { - message: _('Self-monitoring project has been successfully deleted') - } - - elsif SelfMonitoringProjectDeleteWorker.in_progress?(job_id) + if SelfMonitoringProjectDeleteWorker.in_progress?(job_id) ::Gitlab::PollingInterval.set_header(response, interval: 3_000) return render status: :accepted, json: { @@ -147,6 +153,12 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController } end + if @application_setting.self_monitoring_project_id.nil? + return render status: :ok, json: { + message: _('Self-monitoring project has been successfully deleted') + } + end + render status: :bad_request, json: { message: _('Self-monitoring project was not deleted. Please check logs ' \ 'for any error messages') @@ -161,8 +173,8 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController def self_monitoring_data { - project_id: Gitlab::CurrentSettings.self_monitoring_project_id, - project_full_path: Gitlab::CurrentSettings.self_monitoring_project&.full_path + project_id: @application_setting.self_monitoring_project_id, + project_full_path: @application_setting.self_monitoring_project&.full_path } end diff --git a/app/controllers/admin/spam_logs_controller.rb b/app/controllers/admin/spam_logs_controller.rb index a41d8a22650..a317f4086c6 100644 --- a/app/controllers/admin/spam_logs_controller.rb +++ b/app/controllers/admin/spam_logs_controller.rb @@ -24,7 +24,7 @@ class Admin::SpamLogsController < Admin::ApplicationController def mark_as_ham spam_log = SpamLog.find(params[:id]) - if HamService.new(spam_log).mark_as_ham! + if Spam::HamService.new(spam_log).mark_as_ham! redirect_to admin_spam_logs_path, notice: _('Spam log successfully submitted as ham.') else redirect_to admin_spam_logs_path, alert: _('Error with Akismet. Please check the logs for more info.') |