Skip to content

Commit

Permalink
Hide Sync Preferences field 'CPQ prorate precision' if ff non anniver…
Browse files Browse the repository at this point in the history
…sary is not enabled (#1122)
  • Loading branch information
nadaismail-stripe authored Jun 15, 2023
1 parent a23845b commit 3af0145
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/api/configurations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions lib/stripe-force/db/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions test/controllers/test_configurations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3af0145

Please sign in to comment.