Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add tests for payment methods, and fix payment_method_factory.rb
Matthew Kennedy7f701a1232e1
diff --git a/backend/spec/features/admin/configuration/payment_methods_spec.rb b/backend/spec/features/admin/configuration/payment_methods_spec.rbindex 6f14c826ad..52c0b73984 100644--- a/backend/spec/features/admin/configuration/payment_methods_spec.rb+++ b/backend/spec/features/admin/configuration/payment_methods_spec.rb@@ -8,10 +8,31 @@ describe 'Payment Methods', type: :feature dolet!(:store_2) { create(:store) }let!(:store_3) { create(:store) }+ let!(:payment_method_one) { create(:payment_method) }+ let!(:payment_method_two) { create(:payment_method, name: 'Should Be MIA' ,stores: [store_3]) }+before dovisit spree.admin_payment_methods_pathend+ context 'managine payment methods by store' do+ it 'only displays payment methods for current store' do+ within('table#listing_payment_methods') do+ expect(page).to have_content(payment_method_one.name)+ expect(page).not_to have_content(payment_method_two.name)+ end+ end++ it 'is able to show payment methods for all stores using filter' do+ check 'q_all_stores'+ click_on 'Search'++ expect(page).to have_checked_field(id: 'q_all_stores')+ expect(page).to have_content(payment_method_one.name)+ expect(page).to have_content(payment_method_two.name)+ end+ end+context 'admin visiting payment methods listing page' doit 'displays existing payment methods' docreate(:check_payment_method)diff --git a/core/lib/spree/testing_support/factories/payment_method_factory.rb b/core/lib/spree/testing_support/factories/payment_method_factory.rbindex 316c97222e..23a4b37e01 100644--- a/core/lib/spree/testing_support/factories/payment_method_factory.rb+++ b/core/lib/spree/testing_support/factories/payment_method_factory.rb@@ -1,5 +1,6 @@FactoryBot.define dofactory :payment_method, class: Spree::PaymentMethod do+ type { 'Spree::PaymentMethod' }name { 'Test' }before(:create) do |payment_method|@@ -7,22 +8,25 @@ FactoryBot.define dodefault_store = Spree::Store.default.persisted? ? Spree::Store.default : nilstore = default_store || create(:store)- payment_method.stores << [store]+ payment_method.stores << storeendendendfactory :check_payment_method, parent: :payment_method, class: Spree::PaymentMethod::Check do+ type { 'Spree::PaymentMethod::Check' }name { 'Check' }endfactory :credit_card_payment_method, parent: :payment_method, class: Spree::Gateway::Bogus do+ type { 'Spree::Gateway::Bogus' }name { 'Credit Card' }end# authorize.net was moved to spree_gateway.# Leaving this factory in place with bogus in case anyone is using it.factory :simple_credit_card_payment_method, parent: :payment_method, class: Spree::Gateway::BogusSimple do+ type { 'Spree::Gateway::BogusSimple' }name { 'Credit Card' }end