From f065cbe2512cded05122f2739d3437bc49c6eee8 Mon Sep 17 00:00:00 2001 From: stveep Date: Wed, 23 Aug 2017 09:22:04 +0100 Subject: [PATCH] Fix specs for saved credit cards: Add payment profile ID to fixture (now denotes that a card has been saved), check for current user to avoid error attempting to inject saved cards as a guest --- Gemfile.lock | 4 ++-- app/helpers/injection_helper.rb | 5 ++++- spec/features/consumer/shopping/checkout_spec.rb | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1afefa3d73..d41516fe5e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -639,7 +639,7 @@ GEM tilt (~> 1.1, != 1.3.0) state_machine (1.2.0) stringex (1.3.3) - stripe (3.0.1) + stripe (3.3.1) faraday (~> 0.9) therubyracer (0.12.0) libv8 (~> 3.16.14.0) @@ -777,7 +777,7 @@ DEPENDENCIES spree_auth_devise! spree_i18n! spree_paypal_express! - stripe (~> 3.0.1) + stripe (~> 3.3.1) therubyracer timecop truncate_html diff --git a/app/helpers/injection_helper.rb b/app/helpers/injection_helper.rb index c0e83b5b90..b750d3f46b 100644 --- a/app/helpers/injection_helper.rb +++ b/app/helpers/injection_helper.rb @@ -74,7 +74,10 @@ module InjectionHelper end def inject_saved_credit_cards - data = spree_current_user.credit_cards.with_payment_profile.all + if spree_current_user + data = spree_current_user.credit_cards.with_payment_profile.all + end + inject_json_ams "savedCreditCards", data, Api::CreditCardSerializer end diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index 1c4ea9bb65..a5da47e8ef 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -150,7 +150,8 @@ feature "As a consumer I want to check out my cart", js: true, retry: 3 do year: "2025", cc_type: "Visa", number: "1111111111111111", - payment_method_id: stripe_pm.id) + payment_method_id: stripe_pm.id, + gateway_customer_profile_id: "i_am_saved") } let(:response_mock) { { id: "ch_1234", object: "charge", amount: 2000} }