mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
Replace Flipper's built-in test helper
It fails in CI and features are not seen as enabled. So we copy the important part of the test helper into our code, which works. It's probably about the point in time when the adapter is instantiated.
This commit is contained in:
@@ -2,8 +2,23 @@ require "flipper"
|
||||
require "flipper/adapters/active_record"
|
||||
require "open_food_network/feature_toggle"
|
||||
|
||||
Flipper.register(:admins) { |actor| actor.respond_to?(:admin?) && actor.admin? }
|
||||
Rails.application.configure do
|
||||
# Disable Flipper's built-in test helper.
|
||||
# It fails in CI and feature don't get activated.
|
||||
config.flipper.test_help = false
|
||||
end
|
||||
|
||||
Flipper.configure do |flipper|
|
||||
# Still use recommended test setup with faster memory adapter:
|
||||
if Rails.env.test?
|
||||
# Use a shared Memory adapter for all tests. The adapter is instantiated
|
||||
# outside of the block so the same instance is returned in new threads.
|
||||
adapter = Flipper::Adapters::Memory.new
|
||||
flipper.adapter { adapter }
|
||||
end
|
||||
end
|
||||
|
||||
Flipper.register(:admins) { |actor| actor.respond_to?(:admin?) && actor.admin? }
|
||||
Flipper::UI.configure do |config|
|
||||
config.descriptions_source = ->(_keys) do
|
||||
# return has to be hash of {String key => String description}
|
||||
|
||||
@@ -102,7 +102,7 @@ RSpec.configure do |config|
|
||||
end
|
||||
|
||||
# Reset all feature toggles to prevent leaking.
|
||||
config.before(:suite) do
|
||||
config.before(:each) do
|
||||
Flipper.features.each(&:remove)
|
||||
OpenFoodNetwork::FeatureToggle.setup!
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user