From c8b5ce64a472ba3e12e4033641e53ded1e7a4363 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 16 Mar 2022 16:29:03 +0000 Subject: [PATCH 1/2] Adds coverage for hiding payment methods with tags --- spec/system/consumer/split_checkout_spec.rb | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index 9d6f14421c..fa272676cb 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -671,6 +671,42 @@ describe "As a consumer, I want to checkout my order", js: true do end end end + + describe "hidding a payment method with a default rule" do + let!(:tagged_customer) { create(:customer, user: user, enterprise: distributor) } + let!(:hidden_payment) { + create(:payment_method, distributors: [distributor], name: "Hidden", tag_list: "hide_pm") + } + before do + create(:filter_payment_methods_tag_rule, + enterprise: distributor, + is_default: true, + preferred_payment_method_tags: "hide_pm", + preferred_matched_payment_methods_visibility: 'hidden') + visit checkout_step_path(:payment) + end + + context "with no exceptions set to a customer" do + it "hides the payment method" do + expect(page).not_to have_content hidden_payment.name + end + end + + context "with an exception set to a customer" do + before do + create(:filter_payment_methods_tag_rule, + enterprise: distributor, + preferred_customer_tags: "show_pm", + preferred_payment_method_tags: "hide_pm", + preferred_matched_payment_methods_visibility: 'visible') + tagged_customer.update_attribute(:tag_list, "show_pm") + visit checkout_step_path(:payment) + end + it "displays the payment method" do + expect(page).to have_content hidden_payment.name + end + end + end end context "summary step" do From 029df03ee60aa4f39bdccf2d1a4301f0d5987ef9 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Apr 2022 23:49:12 +0100 Subject: [PATCH 2/2] Improves naming and styling --- spec/system/consumer/split_checkout_spec.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/system/consumer/split_checkout_spec.rb b/spec/system/consumer/split_checkout_spec.rb index fa272676cb..8dcee8e27a 100644 --- a/spec/system/consumer/split_checkout_spec.rb +++ b/spec/system/consumer/split_checkout_spec.rb @@ -672,9 +672,9 @@ describe "As a consumer, I want to checkout my order", js: true do end end - describe "hidding a payment method with a default rule" do + describe "hiding a payment method with a default rule" do let!(:tagged_customer) { create(:customer, user: user, enterprise: distributor) } - let!(:hidden_payment) { + let!(:hidden_method) { create(:payment_method, distributors: [distributor], name: "Hidden", tag_list: "hide_pm") } before do @@ -688,7 +688,7 @@ describe "As a consumer, I want to checkout my order", js: true do context "with no exceptions set to a customer" do it "hides the payment method" do - expect(page).not_to have_content hidden_payment.name + expect(page).not_to have_content hidden_method.name end end @@ -702,8 +702,9 @@ describe "As a consumer, I want to checkout my order", js: true do tagged_customer.update_attribute(:tag_list, "show_pm") visit checkout_step_path(:payment) end + it "displays the payment method" do - expect(page).to have_content hidden_payment.name + expect(page).to have_content hidden_method.name end end end