Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Fixed payment seeds in Rails 8 (#12815)

Damian Legawiec67c8ee5b4a87
diff --git a/sample/db/samples/payments.rb b/sample/db/samples/payments.rb
index 955ffef218..af27eaf856 100644
--- a/sample/db/samples/payments.rb
+++ b/sample/db/samples/payments.rb
@@ -10,16 +10,13 @@ Spree::Gateway.class_eval do
end
end
-# This table was previously called spree_creditcards, and older migrations
-# reference it as such. Make it explicit here that this table has been renamed.
-Spree::CreditCard.table_name = 'spree_credit_cards'
-
-credit_card = Spree::CreditCard.where(cc_type: 'visa',
- month: 12,
- year: 2.years.from_now.year,
- last_digits: '1111',
- name: 'Sean Schofield',
- gateway_customer_profile_id: 'BGS-1234').first_or_create!
+credit_card = Spree::CreditCard.find_or_initialize_by(gateway_customer_profile_id: 'BGS-1234')
+credit_card.cc_type = 'visa'
+credit_card.month = 12
+credit_card.year = 2.years.from_now.year
+credit_card.last_digits = '1111'
+credit_card.name = 'Sean Schofield'
+credit_card.save!
Spree::Order.all.each_with_index do |order, _index|
order.update_with_updater!