diff options
author | Peter Leitzen <pleitzen@gitlab.com> | 2018-12-11 19:10:27 +0300 |
---|---|---|
committer | Peter Leitzen <pleitzen@gitlab.com> | 2018-12-11 19:10:27 +0300 |
commit | 53212d77f1f7a88963e7ea1bce109c9aa1be1b5b (patch) | |
tree | de8004dafe68708d55edc54b796d41336fd309c1 | |
parent | d7d51181bf3a99a99880e3c16f7eb24e3016c842 (diff) |
Add and check feature flag `error_tracking`
-rw-r--r-- | app/controllers/projects/error_tracking_controller.rb | 8 | ||||
-rw-r--r-- | spec/controllers/projects/error_tracking_controller_spec.rb | 24 |
2 files changed, 32 insertions, 0 deletions
diff --git a/app/controllers/projects/error_tracking_controller.rb b/app/controllers/projects/error_tracking_controller.rb index 0d0472c6afb..bba5a5e8730 100644 --- a/app/controllers/projects/error_tracking_controller.rb +++ b/app/controllers/projects/error_tracking_controller.rb @@ -1,10 +1,18 @@ # frozen_string_literal: true class Projects::ErrorTrackingController < Projects::ApplicationController + before_action :check_feature_flag! + def list end def index render json: [] end + + private + + def check_feature_flag! + render_404 unless Feature.enabled?(:error_tracking, project) + end end diff --git a/spec/controllers/projects/error_tracking_controller_spec.rb b/spec/controllers/projects/error_tracking_controller_spec.rb index 75ae0e1eb79..0e1b34405fb 100644 --- a/spec/controllers/projects/error_tracking_controller_spec.rb +++ b/spec/controllers/projects/error_tracking_controller_spec.rb @@ -21,6 +21,18 @@ RSpec.describe Projects::ErrorTrackingController, type: :controller do expect(response).to render_template(:list) end + context 'with feature flag disabled' do + before do + stub_feature_flags(error_tracking: false) + end + + it 'returns 404' do + get :list, project_params + + expect(response).to have_gitlab_http_status(:not_found) + end + end + context 'with an anonymous user' do before do sign_out(user) @@ -41,6 +53,18 @@ RSpec.describe Projects::ErrorTrackingController, type: :controller do expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq([]) end + + context 'with feature flag disabled' do + before do + stub_feature_flags(error_tracking: false) + end + + it 'returns 404' do + get :index, project_params + + expect(response).to have_gitlab_http_status(:not_found) + end + end end private |