From 5ed5ed28733fa520bcdcf0a9598db2a23943e8ea Mon Sep 17 00:00:00 2001 From: Eduardo Date: Sat, 30 May 2020 18:04:43 -0300 Subject: [PATCH 1/2] fix payment methods table to show proper provider name --- app/views/spree/admin/payment_methods/index.html.haml | 2 +- spec/features/admin/payment_method_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/spree/admin/payment_methods/index.html.haml b/app/views/spree/admin/payment_methods/index.html.haml index ab1333f2c5..adb14d5caa 100644 --- a/app/views/spree/admin/payment_methods/index.html.haml +++ b/app/views/spree/admin/payment_methods/index.html.haml @@ -32,7 +32,7 @@ - method.distributors.each do |distributor| = distributor.name %br/ - %td= method.type + %td= method.class.clean_name %td.align-center= method.environment.to_s.titleize %td.align-center= method.display_on.blank? ? t('.both') : t('.' + method.display_on.to_s) %td.align-center= method.active ? t('.active_yes') : t('.active_no') diff --git a/spec/features/admin/payment_method_spec.rb b/spec/features/admin/payment_method_spec.rb index 19ec0d151d..3bde47e33d 100644 --- a/spec/features/admin/payment_method_spec.rb +++ b/spec/features/admin/payment_method_spec.rb @@ -185,6 +185,16 @@ feature ' expect(page).not_to have_content payment_method3.name end + it "shows only the providers of the existing payment methods" do + payment_method1 + payment_method2 + payment_method3 + + visit spree.admin_payment_methods_path + + expect(page).to have_content "Cash/EFT/etc. (payments for which automatic validation is not required)", count: 2 + end + it "does not show duplicates of payment methods" do payment_method1 payment_method2 From 27c76cfae28ff300630b0775d9d00e113a9907fb Mon Sep 17 00:00:00 2001 From: Eduardo Date: Mon, 8 Jun 2020 00:17:28 -0300 Subject: [PATCH 2/2] add view spec to replace feature spec --- spec/features/admin/payment_method_spec.rb | 10 ------- .../payment_methods/index.html.haml_spec.rb | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 spec/views/spree/admin/payment_methods/index.html.haml_spec.rb diff --git a/spec/features/admin/payment_method_spec.rb b/spec/features/admin/payment_method_spec.rb index 3bde47e33d..19ec0d151d 100644 --- a/spec/features/admin/payment_method_spec.rb +++ b/spec/features/admin/payment_method_spec.rb @@ -185,16 +185,6 @@ feature ' expect(page).not_to have_content payment_method3.name end - it "shows only the providers of the existing payment methods" do - payment_method1 - payment_method2 - payment_method3 - - visit spree.admin_payment_methods_path - - expect(page).to have_content "Cash/EFT/etc. (payments for which automatic validation is not required)", count: 2 - end - it "does not show duplicates of payment methods" do payment_method1 payment_method2 diff --git a/spec/views/spree/admin/payment_methods/index.html.haml_spec.rb b/spec/views/spree/admin/payment_methods/index.html.haml_spec.rb new file mode 100644 index 0000000000..84007bf961 --- /dev/null +++ b/spec/views/spree/admin/payment_methods/index.html.haml_spec.rb @@ -0,0 +1,28 @@ +require "spec_helper" + +describe "spree/admin/payment_methods/index.html.haml" do + before do + controller.singleton_class.class_eval do + helper_method :new_object_url, :edit_object_url, :object_url + + def new_object_url() "" end + + def edit_object_url(object, options = {}) "" end + + def object_url(object = nil, options = {}) "" end + end + + assign(:payment_methods, [ + create(:payment_method), + create(:payment_method) + ]) + end + + describe "payment methods index page" do + it "shows only the providers of the existing payment methods" do + render + + expect(rendered).to have_content "Cash/EFT/etc. (payments for which automatic validation is not required)", count: 2 + end + end +end