diff --git a/app/controllers/api/configurations_controller.rb b/app/controllers/api/configurations_controller.rb index 7fdb4f7594..71cf4c6a0b 100644 --- a/app/controllers/api/configurations_controller.rb +++ b/app/controllers/api/configurations_controller.rb @@ -237,6 +237,7 @@ def update enabled: @user.enabled, configuration_hash: @user.configuration_hash, hidden_mapper_fields: @user.hidden_mapper_fields, + hidden_sync_pref_fields: @user.hidden_sync_pref_fields, } end diff --git a/lib/stripe-force/db/user.rb b/lib/stripe-force/db/user.rb index 6c4c9b4033..e6d7b914a3 100644 --- a/lib/stripe-force/db/user.rb +++ b/lib/stripe-force/db/user.rb @@ -340,6 +340,16 @@ def hidden_mapper_fields hidden_mapper_fields end + def hidden_sync_pref_fields + hidden_sync_pref_fields = [] + + if !feature_enabled?(FeatureFlags::NON_ANNIVERSARY_AMENDMENTS) + hidden_sync_pref_fields << "cpq_prorate_precision" + end + + hidden_sync_pref_fields + end + sig { params(feature: FeatureFlags, update: T::Boolean).void } def enable_feature(feature, update: false) if !feature_flags.include?(feature.serialize.to_sym) diff --git a/test/controllers/test_configurations_controller.rb b/test/controllers/test_configurations_controller.rb index af3cd743e2..e4e0375f8a 100644 --- a/test/controllers/test_configurations_controller.rb +++ b/test/controllers/test_configurations_controller.rb @@ -314,6 +314,28 @@ class Critic::ConfigurationsControllerTest < ApplicationIntegrationTest # if mappings change, hash should be different assert_equal([], result['hidden_mapper_fields']) end + + it 'hidden sync management fields are updated when features are enabled' do + get api_configuration_path, headers: authentication_headers + assert_response :success + result = parsed_json + + # initially the hidden mapper fields should contain values + # if no feature flag is enabled for the user + assert(1, result['hidden_sync_pref_fields'].count) + assert_equal(["cpq_prorate_precision"], result['hidden_sync_pref_fields']) + + # enable features + @user.enable_feature(FeatureFlags::NON_ANNIVERSARY_AMENDMENTS) + @user.save + + get api_configuration_path, headers: authentication_headers + assert_response :success + result = parsed_json + + # if mappings change, hash should be different + assert_equal([], result['hidden_sync_pref_fields']) + end end describe '#configuration' do