summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Leitzen <pleitzen@gitlab.com>2018-12-11 17:10:27 +0100
committerPeter Leitzen <pleitzen@gitlab.com>2019-01-02 19:41:49 +0100
commitaca42a71673add8bc01c1a86fed25c02c8d87506 (patch)
tree49c5468553dbe8c5b82d7da4f4745381814ac16d
parentd90e44bbb5ed6c86906d3b6c3d5cf72596e47360 (diff)
downloadgitlab-ce-aca42a71673add8bc01c1a86fed25c02c8d87506.tar.gz
Add and check feature flag `error_tracking`
-rw-r--r--app/controllers/projects/error_tracking_controller.rb8
-rw-r--r--spec/controllers/projects/error_tracking_controller_spec.rb24
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