Skip to content

Commit

Permalink
Misc fixes for coupons test (#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadaismail-stripe authored Dec 14, 2022
1 parent c020e5d commit dab0d6e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions lib/stripe-force/translate/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ def self.sf_object_metadata_name(sf_object)
# if we are mapping a subfield on order_item, it will be long
.gsub('order_item_', 'oi_')

# remove the namespace prefix since Stripe errors if key length > 40 chars
namespace_prefixes = [StripeForce::Constants::SalesforceNamespaceOptions::QA, StripeForce::Constants::SalesforceNamespaceOptions::PRODUCTION].map(&:serialize).map(&:underscore)
if key.include? namespace_prefixes.first
key.slice! namespace_prefixes.first
elsif key.include? namespace_prefixes[1]
key.slice! namespace_prefixes[1]
# TODO refactor to be more clear where these strings are coming from
# namespace_prefixes = [StripeForce::Constants::SalesforceNamespaceOptions::QA, StripeForce::Constants::SalesforceNamespaceOptions::PRODUCTION].map(&:serialize).map(&:underscore)
if key.include? "qa_stripe_connect"
key.slice! "qa_stripe_connect__"
elsif key.include? "stripe_connector"
key.slice! "stripe_connector__"
end

key
Expand Down
8 changes: 4 additions & 4 deletions test/integration/translate/test_coupon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ class Critic::CouponTranslation < Critic::FunctionalTest
order_coupon = sf.find(prefixed_stripe_field(ORDER_SF_STRIPE_COUPON), order_associations.first[prefixed_stripe_field('Order_Stripe_Coupon__c')])
assert_equal('$10 off coupon', order_coupon[prefixed_stripe_field('Name__c')])
assert_equal(10, order_coupon[prefixed_stripe_field('Amount_Off__c')])
assert_equal(sf_amount_off_coupon_id, order_coupon[prefixed_stripe_field('Quote_Stripe_Coupon__c')])
assert_empty(order_coupon[prefixed_stripe_field('Percent_Off__c')])
assert_empty(order_coupon[prefixed_stripe_field('Max_Redemptions__c')])
assert_equal(sf_amount_off_coupon_id, order_coupon[prefixed_stripe_field('Quote_Stripe_Coupon_Id__c')])
assert_nil(order_coupon[prefixed_stripe_field('Percent_Off__c')])
assert_nil(order_coupon[prefixed_stripe_field('Max_Redemptions__c')])
end
end

describe 'order translation with coupons' do
it 'translate sf order with multiple coupons on an order line' do
# add a custom metadata field mapping
@user.field_mappings['coupon'] = {
'metadata.sf_mapped_metadata_field' => 'Name__c',
'metadata.sf_mapped_metadata_field' => prefixed_stripe_field('Name__c'),
}
@user.save

Expand Down

0 comments on commit dab0d6e

Please sign in to comment.