From 3084a6ad28b146ad952f9a61eced2d1adaae3976 Mon Sep 17 00:00:00 2001 From: Luuk Veenis Date: Thu, 27 Oct 2016 11:07:01 -0700 Subject: [PATCH] Hide backend new card form by default When the page first loads, this form should not be visible. We want it to be displayed when the user selects "new card". Otherwise it's visible when a reusable source is selected. --- .../admin/payments/source_forms/_paypal_braintree.html.erb | 4 +++- app/views/spree/shared/_braintree_hosted_fields.html.erb | 2 +- spec/features/braintree_credit_card_checkout_spec.rb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/spree/admin/payments/source_forms/_paypal_braintree.html.erb b/app/views/spree/admin/payments/source_forms/_paypal_braintree.html.erb index 2ec56f14..b7d23648 100644 --- a/app/views/spree/admin/payments/source_forms/_paypal_braintree.html.erb +++ b/app/views/spree/admin/payments/source_forms/_paypal_braintree.html.erb @@ -10,5 +10,7 @@ <% end %> - <%= render partial: "spree/shared/braintree_hosted_fields", locals: { id: id } %> + diff --git a/app/views/spree/shared/_braintree_hosted_fields.html.erb b/app/views/spree/shared/_braintree_hosted_fields.html.erb index 4fbee72a..c7d24e56 100644 --- a/app/views/spree/shared/_braintree_hosted_fields.html.erb +++ b/app/views/spree/shared/_braintree_hosted_fields.html.erb @@ -1,6 +1,6 @@ <% prefix = "payment_source[#{id}]" %> -
+
<%= label_tag "card_number#{id}", Spree::CreditCard.human_attribute_name(:number), class: "required" %>
diff --git a/spec/features/braintree_credit_card_checkout_spec.rb b/spec/features/braintree_credit_card_checkout_spec.rb index 41053bae..8eaeb486 100644 --- a/spec/features/braintree_credit_card_checkout_spec.rb +++ b/spec/features/braintree_credit_card_checkout_spec.rb @@ -22,7 +22,7 @@ visit spree.checkout_state_path(:delivery) click_button "Save and Continue" choose("Braintree") - expect(page).to have_selector("#card_form#{braintree.id}", visible: true) + expect(page).to have_selector("#payment_method_#{braintree.id}", visible: true) expect(page).to have_selector("iframe#braintree-hosted-field-number") end end