diff options
-rw-r--r-- | app/controllers/projects/settings/operations/error_tracking_controller.rb | 5 | ||||
-rw-r--r-- | spec/controllers/projects/settings/operations/error_tracking_controller_spec.rb | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/app/controllers/projects/settings/operations/error_tracking_controller.rb b/app/controllers/projects/settings/operations/error_tracking_controller.rb index d0f4b6f287c..9409fcdc541 100644 --- a/app/controllers/projects/settings/operations/error_tracking_controller.rb +++ b/app/controllers/projects/settings/operations/error_tracking_controller.rb @@ -5,6 +5,7 @@ module Projects module Operations class ErrorTrackingController < Projects::ApplicationController before_action :authorize_update_environment! + before_action :check_feature_flag def create result = ::Projects::ErrorTracking::SettingService @@ -22,6 +23,10 @@ module Projects private + def check_feature_flag + render_404 unless Feature.enabled?(:error_tracking, current_user) + end + def setting_params params .require(:error_tracking_setting) diff --git a/spec/controllers/projects/settings/operations/error_tracking_controller_spec.rb b/spec/controllers/projects/settings/operations/error_tracking_controller_spec.rb index 0f39ffcca87..2001cfd440f 100644 --- a/spec/controllers/projects/settings/operations/error_tracking_controller_spec.rb +++ b/spec/controllers/projects/settings/operations/error_tracking_controller_spec.rb @@ -59,6 +59,18 @@ describe Projects::Settings::Operations::ErrorTrackingController do end end + context 'with feature flag disabled' do + before do + stub_feature_flags(error_tracking: false) + end + + it 'renders 404' do + post :create, params: project_params(project) + + expect(response).to have_gitlab_http_status(:not_found) + end + end + context 'as a reporter' do before do project.add_reporter(user) |