diff --git a/lib/open_food_network/subscription_payment_updater.rb b/lib/open_food_network/subscription_payment_updater.rb index 2a166def68..eb33aaf2f2 100644 --- a/lib/open_food_network/subscription_payment_updater.rb +++ b/lib/open_food_network/subscription_payment_updater.rb @@ -47,7 +47,7 @@ module OpenFoodNetwork end def saved_credit_card - order.subscription.credit_card + order.user.default_card end def errors_present? diff --git a/spec/lib/open_food_network/subscription_payment_updater_spec.rb b/spec/lib/open_food_network/subscription_payment_updater_spec.rb index 5fb76a0c86..8d590f59b7 100644 --- a/spec/lib/open_food_network/subscription_payment_updater_spec.rb +++ b/spec/lib/open_food_network/subscription_payment_updater_spec.rb @@ -151,7 +151,7 @@ module OpenFoodNetwork let!(:payment) { create(:payment, source: nil) } before { allow(updater).to receive(:payment) { payment } } - context "when no credit card is specified by the subscription" do + context "when no saved credit card is found" do before { allow(updater).to receive(:saved_credit_card) { nil } } it "returns false and down not update the payment source" do @@ -161,7 +161,7 @@ module OpenFoodNetwork end end - context "when a credit card is specified by the subscription" do + context "when a saved credit card is found" do let(:credit_card) { create(:credit_card) } before { allow(updater).to receive(:saved_credit_card) { credit_card } }