mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Consistently use our FeatureToggle module
Direct calls to Flipper have the downside that we can't add any new functionality like storing the feature in the database when used.
This commit is contained in:
@@ -40,7 +40,7 @@ module Api
|
||||
end
|
||||
|
||||
def restrict_feature
|
||||
not_found unless Flipper.enabled?(:api_v1, @current_api_user)
|
||||
not_found unless OpenFoodNetwork::FeatureToggle.enabled?(:api_v1, @current_api_user)
|
||||
end
|
||||
|
||||
def current_ability
|
||||
|
||||
@@ -39,7 +39,7 @@ module OrderStockCheck
|
||||
end
|
||||
|
||||
def reset_order_to_cart
|
||||
return if Flipper.enabled? :split_checkout, spree_current_user
|
||||
return if OpenFoodNetwork::FeatureToggle.enabled? :split_checkout, spree_current_user
|
||||
|
||||
OrderCheckoutRestart.new(@order).call
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ module Spree
|
||||
order.payment_required?
|
||||
}
|
||||
go_to_state :confirmation, if: ->(order) {
|
||||
Flipper.enabled? :split_checkout, order.created_by
|
||||
OpenFoodNetwork::FeatureToggle.enabled? :split_checkout, order.created_by
|
||||
}
|
||||
go_to_state :complete
|
||||
end
|
||||
@@ -311,7 +311,7 @@ module Spree
|
||||
# Creates new tax charges if there are any applicable rates. If prices already
|
||||
# include taxes then price adjustments are created instead.
|
||||
def create_tax_charge!
|
||||
return if state.in?(["cart", "address", "delivery"]) && Flipper.enabled?(:split_checkout)
|
||||
return if state.in?(["cart", "address", "delivery"]) && OpenFoodNetwork::FeatureToggle.enabled?(:split_checkout)
|
||||
|
||||
clear_legacy_taxes!
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ Openfoodnetwork::Application.routes.draw do
|
||||
end
|
||||
|
||||
get '/reports/:report_type(/:report_subtype)', to: 'reports#show',
|
||||
constraints: lambda { |_| Flipper.enabled?(:api_reports) }
|
||||
constraints: lambda { |_| OpenFoodNetwork::FeatureToggle.enabled?(:api_reports) }
|
||||
end
|
||||
|
||||
namespace :v1 do
|
||||
|
||||
@@ -88,8 +88,10 @@ module PaymentGateways
|
||||
|
||||
context "using split checkout" do
|
||||
before do
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout) { true }
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout, anything) { true }
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout) { true }
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout, anything) { true }
|
||||
|
||||
order.update_attribute :state, "confirmation"
|
||||
end
|
||||
|
||||
@@ -16,8 +16,10 @@ describe SplitCheckoutController, type: :controller do
|
||||
let(:shipping_method) { distributor.shipping_methods.first }
|
||||
|
||||
before do
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout) { true }
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout, anything) { true }
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout) { true }
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout, anything) { true }
|
||||
|
||||
exchange.variants << order.line_items.first.variant
|
||||
allow(controller).to receive(:current_order) { order }
|
||||
|
||||
@@ -83,8 +83,8 @@ describe "As a consumer I want to check out my cart", js: true do
|
||||
|
||||
context "split checkout" do
|
||||
before do
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout) { true }
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout, anything) { true }
|
||||
allow(OpenFoodNetwork::FeatureToggle).to receive(:enabled?).with(:split_checkout) { true }
|
||||
allow(OpenFoodNetwork::FeatureToggle).to receive(:enabled?).with(:split_checkout, anything) { true }
|
||||
end
|
||||
include_examples "with different checkout types", "split_checkout"
|
||||
end
|
||||
|
||||
@@ -65,8 +65,8 @@ describe "As a consumer, I want to checkout my order", js: true do
|
||||
}
|
||||
|
||||
before do
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
|
||||
add_enterprise_fee enterprise_fee
|
||||
set_order order
|
||||
|
||||
@@ -111,8 +111,10 @@ describe "As a consumer, I want to see adjustment breakdown" do
|
||||
|
||||
context "on split-checkout" do
|
||||
before do
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
|
||||
set_order order_within_zone
|
||||
login_as(user_within_zone)
|
||||
@@ -169,8 +171,10 @@ describe "As a consumer, I want to see adjustment breakdown" do
|
||||
|
||||
context "on split-checkout" do
|
||||
before do
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
|
||||
set_order order_outside_zone
|
||||
login_as(user_outside_zone)
|
||||
|
||||
@@ -118,8 +118,10 @@ describe "As a consumer, I want to see adjustment breakdown" do
|
||||
|
||||
context "on split-checkout" do
|
||||
before do
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
|
||||
set_order order_within_zone
|
||||
login_as(user_within_zone)
|
||||
@@ -179,8 +181,10 @@ describe "As a consumer, I want to see adjustment breakdown" do
|
||||
|
||||
context "on split-checkout" do
|
||||
before do
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(Flipper).to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout).and_return(true)
|
||||
allow(OpenFoodNetwork::FeatureToggle).
|
||||
to receive(:enabled?).with(:split_checkout, anything).and_return(true)
|
||||
|
||||
set_order order_outside_zone
|
||||
login_as(user_outside_zone)
|
||||
|
||||
Reference in New Issue
Block a user