mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-25 05:45:15 +00:00
Activate background report processing by default
Many report specs are still testing the old behaviour. We need to migrate them to background reports. Some tests may be better as unit tests instead of system tests.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class EnableFeatureBackroundReports < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
Flipper.enable("background_reports")
|
||||
end
|
||||
end
|
||||
@@ -10,6 +10,17 @@ module OpenFoodNetwork
|
||||
# Please add your new feature here to appear in the Flipper UI.
|
||||
# We way move this to a YAML file when it becomes too awkward.
|
||||
# **WARNING:** Features not in this list will be removed.
|
||||
#
|
||||
# Once the feature is ready for general production use,
|
||||
# copy the feature declaration to ACTIVE_BY_DEFAULT below and
|
||||
# activate it for all instances with a migration:
|
||||
#
|
||||
# ./bin/rails generate migration EnableFeatureDragonMode
|
||||
#
|
||||
# Replace the `change` method with an `up` method and add this line:
|
||||
#
|
||||
# Flipper.enable("dragon_mode")
|
||||
#
|
||||
CURRENT_FEATURES = {
|
||||
"admin_style_v3" => <<~DESC,
|
||||
Test the work-in-progress design updates.
|
||||
@@ -38,10 +49,23 @@ module OpenFoodNetwork
|
||||
DESC
|
||||
}.freeze
|
||||
|
||||
# Features you would like to be enabled to start with.
|
||||
#
|
||||
# Copy features here that were activated in a migration so that new
|
||||
# instances, development and test environments have the feature active.
|
||||
ACTIVE_BY_DEFAULT = {
|
||||
"background_reports" => <<~DESC,
|
||||
Generate reports in a background process to limit memory consumption.
|
||||
DESC
|
||||
}.freeze
|
||||
|
||||
def self.setup!
|
||||
CURRENT_FEATURES.each_key do |name|
|
||||
feature = Flipper.feature(name)
|
||||
feature.add unless feature.exist?
|
||||
unless feature.exist?
|
||||
feature.add
|
||||
feature.enable if ACTIVE_BY_DEFAULT[name]
|
||||
end
|
||||
end
|
||||
|
||||
Flipper.features.each do |feature|
|
||||
|
||||
@@ -88,6 +88,33 @@ RSpec.configure do |config|
|
||||
expectations.syntax = :expect
|
||||
end
|
||||
|
||||
# Reset all feature toggles to prevent leaking.
|
||||
config.before(:suite) do
|
||||
Flipper.features.each(&:remove)
|
||||
OpenFoodNetwork::FeatureToggle.setup!
|
||||
end
|
||||
|
||||
config.before(:each) do |example|
|
||||
Flipper.disable(:background_reports) if example.file_path.in?(
|
||||
[
|
||||
# rubocop:disable Layout/LineLength
|
||||
"./spec/controllers/admin/reports_controller_spec.rb",
|
||||
"./spec/system/admin/reports/enterprise_fee_summaries_spec.rb",
|
||||
"./spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_order_spec.rb",
|
||||
"./spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_producer_spec.rb",
|
||||
"./spec/system/admin/reports/orders_and_fulfillment_spec.rb",
|
||||
"./spec/system/admin/reports/packing_report_spec.rb",
|
||||
"./spec/system/admin/reports/payments_report_spec.rb",
|
||||
"./spec/system/admin/reports/revenues_by_hub_spec.rb",
|
||||
"./spec/system/admin/reports/sales_tax/sales_tax_totals_by_order_spec.rb",
|
||||
"./spec/system/admin/reports/sales_tax/sales_tax_totals_by_producer_spec.rb",
|
||||
"./spec/system/admin/reports/users_and_enterprises_spec.rb",
|
||||
"./spec/system/admin/reports_spec.rb",
|
||||
# rubocop:enable Layout/LineLength
|
||||
]
|
||||
)
|
||||
end
|
||||
|
||||
config.before(:each, :feature) do |example|
|
||||
feature = example.metadata[:feature].to_s
|
||||
|
||||
|
||||
Reference in New Issue
Block a user