Add feature toggle for API v1 use

Dev, test and staging need to activate the feature toggle now before
it's accessible.
This commit is contained in:
Maikel Linke
2022-03-08 10:44:33 +11:00
parent 3e00ab261e
commit 379eda7c41
2 changed files with 8 additions and 7 deletions

View File

@@ -87,13 +87,11 @@ Openfoodnetwork::Application.routes.draw do
constraints: lambda { |_| Flipper.enabled?(:api_reports) }
end
unless Rails.env.production?
namespace :v1 do
resources :customers
namespace :v1, constraints: ->(request) { Flipper.enabled?(:api_v1, request.env["warden"].user) } do
resources :customers
resources :enterprises do
resources :customers, only: :index
end
resources :enterprises do
resources :customers, only: :index
end
end

View File

@@ -17,7 +17,10 @@ describe "Customers", type: :request do
let!(:customer2) { create(:customer, enterprise: enterprise1) }
let!(:customer3) { create(:customer, enterprise: enterprise2) }
before { login_as enterprise1.owner }
before do
Flipper.enable(:api_v1)
login_as enterprise1.owner
end
path "/api/v1/customers" do
get "List customers" do