From 0063e7b4d84bc3805a0ea6abd4e2fdb63a0a3fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Thu, 23 Nov 2017 12:11:27 +0100 Subject: [PATCH] Add feature flag for the GraphQL API --- app/controllers/graphql_controller.rb | 3 +++ app/models/setting.rb | 1 + config/locales/en/settings.yml | 1 + config/locales/es/settings.yml | 1 + spec/controllers/graphql_controller_spec.rb | 9 +++++++++ 5 files changed, 15 insertions(+) diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb index af28094d5..e9bcf7080 100644 --- a/app/controllers/graphql_controller.rb +++ b/app/controllers/graphql_controller.rb @@ -1,4 +1,7 @@ class GraphqlController < ApplicationController + include FeatureFlags + + feature_flag :graphql_api skip_before_action :verify_authenticity_token skip_authorization_check diff --git a/app/models/setting.rb b/app/models/setting.rb index 3770aca1d..db0b6645c 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -99,6 +99,7 @@ class Setting < ApplicationRecord "feature.translation_interface": nil, "feature.remote_census": nil, "feature.valuation_comment_notification": true, + "feature.graphql_api": true, "homepage.widgets.feeds.debates": true, "homepage.widgets.feeds.processes": true, "homepage.widgets.feeds.proposals": true, diff --git a/config/locales/en/settings.yml b/config/locales/en/settings.yml index f2eef602a..9c5ed3ab7 100644 --- a/config/locales/en/settings.yml +++ b/config/locales/en/settings.yml @@ -124,6 +124,7 @@ en: remote_census_description: "Allows to configure the connection to the remote census of each institution" valuation_comment_notification: "Valuation comment notification" valuation_comment_notification_description: "Send an email to all associated users except valuation commenter to budget investment when a new valuation comment is created" + graphql_api: "GraphQL API" remote_census: general: endpoint: "Endpoint" diff --git a/config/locales/es/settings.yml b/config/locales/es/settings.yml index df376f702..4dfc5edff 100644 --- a/config/locales/es/settings.yml +++ b/config/locales/es/settings.yml @@ -124,6 +124,7 @@ es: remote_census_description: "Permite configurar la conexión al censo remoto de cada institución" valuation_comment_notification: "Notificar comentarios de evaluación" valuation_comment_notification_description: "Envía un email a todos los usuarios menos al que haya comentado asociados a un presupuesto participativo cuando se cree un nuevo comentario de evaluación" + graphql_api: "API GraphQL" remote_census: general: endpoint: "Endpoint" diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index b55816e39..6fe974e5e 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -90,4 +90,13 @@ describe GraphqlController, type: :request do expect(response).to have_http_status(:ok) end end + + context "feature flag is set to false" do + before { Setting["feature.graphql_api"] = false } + + it "is disabled" do + expect { get "/graphql" }.to raise_exception(FeatureFlags::FeatureDisabled) + expect { post "/graphql" }.to raise_exception(FeatureFlags::FeatureDisabled) + end + end end