Make payment source_views/gateway work with nil credit card

This will happen if user deletes a saved credit card used previously. In this case, the admin payment details page will render empty details and the payment amount
This commit is contained in:
Luis Ramos
2020-02-26 11:55:17 +00:00
parent 5848a46149
commit 677f31ffa8
2 changed files with 21 additions and 10 deletions

View File

@@ -6,28 +6,28 @@
%dt
= Spree.t(:card_number)
\:
%dd= payment.source.display_number
%dd= payment.source&.display_number
%dt
= Spree.t(:expiration)
\:
%dd
= payment.source.month
= payment.source&.month
\/
= payment.source.year
= payment.source&.year
%dt
= Spree.t(:card_code)
\:
%dd= payment.source.verification_value
%dd= payment.source&.verification_value
.omega.six.columns
%dl
%dt
= t(:maestro_or_solo_cards)
\:
%dd= payment.source.issue_number
%dd= payment.source&.issue_number
%dt
= Spree.t(:start_date)
\:
%dd
= payment.source.start_month
= payment.source&.start_month
\/
= payment.source.start_year
= payment.source&.start_year

View File

@@ -10,7 +10,6 @@ feature '
scenario "visiting the payment form" do
quick_login_as_admin
visit spree.new_admin_order_payment_path order
expect(page).to have_content "New Payment"
@@ -28,7 +27,6 @@ feature '
scenario "visiting the payment form" do
quick_login_as_admin
visit spree.new_admin_order_payment_path order
expect(page).to have_content "New Payment"
@@ -43,11 +41,24 @@ feature '
it "renders the payment details" do
quick_login_as_admin
visit spree.admin_order_payments_path order
page.click_link("StripeSCA")
expect(page).to have_content order.payments.last.source.last_digits
end
context "with a deleted credit card" do
before do
order.payments.last.update_attribute(:source, nil)
end
it "renders the payment details" do
quick_login_as_admin
visit spree.admin_order_payments_path order
page.click_link("StripeSCA")
expect(page).to have_content order.payments.last.amount
end
end
end
end