solidus_core 2.11.16 → 3.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree.js.erb +0 -51
- data/app/helpers/spree/store_helper.rb +0 -11
- data/app/mailers/spree/carton_mailer.rb +1 -5
- data/app/models/concerns/spree/active_storage_adapter/attachment.rb +11 -13
- data/app/models/concerns/spree/active_storage_adapter.rb +0 -2
- data/app/models/concerns/spree/adjustment_source.rb +0 -15
- data/app/models/concerns/spree/calculated_adjustments.rb +0 -18
- data/app/models/concerns/spree/soft_deletable.rb +2 -4
- data/app/models/concerns/spree/user_address_book.rb +0 -37
- data/app/models/concerns/spree/user_methods.rb +2 -11
- data/app/models/spree/ability.rb +0 -37
- data/app/models/spree/address/name.rb +2 -20
- data/app/models/spree/address.rb +8 -187
- data/app/models/spree/adjustment.rb +0 -28
- data/app/models/spree/base.rb +12 -48
- data/app/models/spree/calculator/flexi_rate.rb +0 -5
- data/app/models/spree/calculator.rb +0 -11
- data/app/models/spree/country.rb +1 -6
- data/app/models/spree/credit_card.rb +0 -27
- data/app/models/spree/customer_return.rb +1 -4
- data/app/models/spree/image/active_storage_attachment.rb +2 -10
- data/app/models/spree/image/paperclip_attachment.rb +1 -1
- data/app/models/spree/image.rb +0 -7
- data/app/models/spree/inventory_unit.rb +0 -21
- data/app/models/spree/line_item.rb +2 -45
- data/app/models/spree/order.rb +4 -137
- data/app/models/spree/order_cancellations.rb +4 -24
- data/app/models/spree/order_shipping.rb +9 -6
- data/app/models/spree/order_updater.rb +2 -11
- data/app/models/spree/payment/cancellation.rb +3 -22
- data/app/models/spree/payment.rb +0 -3
- data/app/models/spree/payment_create.rb +1 -13
- data/app/models/spree/payment_method/bogus_credit_card.rb +9 -13
- data/app/models/spree/payment_method/credit_card.rb +1 -3
- data/app/models/spree/payment_method/simple_bogus_credit_card.rb +4 -4
- data/app/models/spree/payment_method.rb +2 -106
- data/app/models/spree/product/scopes.rb +0 -27
- data/app/models/spree/product.rb +0 -39
- data/app/models/spree/promotion/actions/create_adjustment.rb +0 -3
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +0 -3
- data/app/models/spree/promotion/actions/create_quantity_adjustments.rb +0 -3
- data/app/models/spree/promotion/rules/taxon.rb +2 -15
- data/app/models/spree/promotion.rb +2 -6
- data/app/models/spree/promotion_action.rb +2 -12
- data/app/models/spree/promotion_code/batch_builder.rb +0 -14
- data/app/models/spree/promotion_code.rb +2 -2
- data/app/models/spree/promotion_rule.rb +0 -4
- data/app/models/spree/refund.rb +0 -60
- data/app/models/spree/reimbursement.rb +3 -41
- data/app/models/spree/reimbursement_performer.rb +2 -8
- data/app/models/spree/reimbursement_type/credit.rb +1 -4
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -2
- data/app/models/spree/reimbursement_type/store_credit.rb +1 -4
- data/app/models/spree/return_authorization.rb +1 -4
- data/app/models/spree/return_item.rb +1 -19
- data/app/models/spree/shipment.rb +1 -54
- data/app/models/spree/shipping_method.rb +0 -25
- data/app/models/spree/shipping_rate.rb +0 -2
- data/app/models/spree/state.rb +0 -4
- data/app/models/spree/stock/simple_coordinator.rb +1 -20
- data/app/models/spree/stock/splitter/base.rb +2 -7
- data/app/models/spree/stock_item.rb +1 -7
- data/app/models/spree/store.rb +0 -12
- data/app/models/spree/store_credit.rb +0 -8
- data/app/models/spree/store_credit_category.rb +0 -32
- data/app/models/spree/tax_calculator/shipping_rate.rb +1 -12
- data/app/models/spree/tax_rate.rb +0 -27
- data/app/models/spree/taxon/active_storage_attachment.rb +0 -5
- data/app/models/spree/taxon/paperclip_attachment.rb +0 -5
- data/app/models/spree/taxon.rb +0 -11
- data/app/models/spree/user_address.rb +0 -5
- data/app/models/spree/variant.rb +2 -46
- data/config/locales/en.yml +0 -8
- data/db/migrate/20180416083007_add_apply_to_all_to_variant_property_rule.rb +1 -1
- data/lib/generators/solidus/install/install_generator.rb +13 -2
- data/lib/generators/solidus/install/templates/config/initializers/spree.rb.tt +3 -39
- data/lib/generators/spree/dummy/dummy_generator.rb +2 -1
- data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
- data/lib/generators/spree/dummy/templates/rails/storage.yml +3 -0
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/spree/app_configuration.rb +6 -73
- data/lib/spree/core/class_constantizer.rb +2 -0
- data/lib/spree/core/controller_helpers/auth.rb +1 -14
- data/lib/spree/core/controller_helpers/order.rb +2 -22
- data/lib/spree/core/controller_helpers/payment_parameters.rb +0 -54
- data/lib/spree/core/controller_helpers/pricing.rb +0 -8
- data/lib/spree/core/controller_helpers/strong_parameters.rb +0 -4
- data/lib/spree/core/engine.rb +0 -43
- data/lib/spree/core/environment_extension.rb +0 -9
- data/lib/spree/core/product_filters.rb +0 -40
- data/lib/spree/core/role_configuration.rb +0 -14
- data/lib/spree/core/search/base.rb +0 -26
- data/lib/spree/core/state_machines.rb +2 -11
- data/lib/spree/core/validators/email.rb +1 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +9 -8
- data/lib/spree/event/configuration.rb +0 -5
- data/lib/spree/event/subscriber.rb +0 -18
- data/lib/spree/event/subscriber_registry.rb +3 -1
- data/lib/spree/event.rb +0 -31
- data/lib/spree/i18n.rb +0 -22
- data/lib/spree/money.rb +3 -18
- data/lib/spree/permitted_attributes.rb +3 -60
- data/lib/spree/testing_support/blacklist_urls.rb +1 -1
- data/lib/spree/testing_support/capybara_ext.rb +0 -30
- data/lib/spree/testing_support/controller_requests.rb +0 -82
- data/lib/spree/testing_support/dummy_app/migrations.rb +0 -3
- data/lib/spree/testing_support/dummy_app.rb +6 -16
- data/lib/spree/testing_support/factories/order_factory.rb +0 -1
- data/lib/spree/testing_support/factories/refund_factory.rb +0 -1
- data/lib/spree/testing_support/order_walkthrough.rb +0 -3
- data/lib/spree/testing_support/preferences.rb +0 -25
- data/lib/spree/testing_support.rb +1 -1
- data/lib/tasks/migrations/migrate_default_billing_addresses_to_address_book.rake +20 -15
- data/solidus_core.gemspec +1 -24
- metadata +9 -74
- data/app/mailers/spree/test_mailer.rb +0 -13
- data/app/models/concerns/spree/user_payment_source.rb +0 -26
- data/app/models/spree/calculator/free_shipping.rb +0 -22
- data/app/models/spree/calculator/percent_per_item.rb +0 -51
- data/app/models/spree/calculator/price_sack.rb +0 -28
- data/app/models/spree/gateway/bogus.rb +0 -13
- data/app/models/spree/gateway/bogus_simple.rb +0 -13
- data/app/models/spree/gateway.rb +0 -14
- data/app/models/spree/order/checkout.rb +0 -244
- data/app/models/spree/order_capturing.rb +0 -50
- data/app/models/spree/promotion_handler/free_shipping.rb +0 -9
- data/lib/generators/spree/install/install_generator.rb +0 -15
- data/lib/solidus/migrations/rename_gateways.rb +0 -41
- data/lib/spree/core/current_store.rb +0 -24
- data/lib/spree/paranoia_deprecations.rb +0 -41
- data/lib/spree/preferences/persistable.rb +0 -23
- data/lib/spree/promo/environment.rb +0 -12
- data/lib/spree/testing_support/bar_ability.rb +0 -19
- data/lib/spree/testing_support/fixtures/file.txt +0 -1
- data/lib/tasks/core.rake +0 -104
- data/lib/tasks/email.rake +0 -12
- data/lib/tasks/migrations/copy_order_bill_address_to_credit_card.rake +0 -119
- data/lib/tasks/migrations/migrate_shipping_rate_taxes.rake +0 -22
- data/lib/tasks/migrations/migrate_user_addresses.rake +0 -34
- data/lib/tasks/migrations/rename_gateways.rake +0 -23
- data/lib/tasks/order_capturing.rake +0 -27
- data/lib/tasks/solidus/check_orders_with_invalid_email.rake +0 -18
@@ -1,119 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace 'spree:migrations:copy_order_bill_address_to_credit_card' do
|
4
|
-
# This copies the billing address from the order associated with a
|
5
|
-
# credit card's most recent payment to the credit card.
|
6
|
-
|
7
|
-
# Used in the migration CopyOrderBillAddressToCreditCard and made available as a
|
8
|
-
# rake task to allow running it a second time after deploying the new code, in
|
9
|
-
# case some order->credit card data was missed between the time that the
|
10
|
-
# migration was run and the application servers were restarted with the new
|
11
|
-
# code.
|
12
|
-
|
13
|
-
# This task should be safe to run multiple times.
|
14
|
-
|
15
|
-
task up: :environment do
|
16
|
-
Spree::Deprecation.warn("rake spree:migrations:copy_order_bill_address_to_credit_card:up has been deprecated and will be removed with Solidus 3.0.")
|
17
|
-
|
18
|
-
if Spree::CreditCard.connection.adapter_name =~ /postgres/i
|
19
|
-
postgres_copy
|
20
|
-
else
|
21
|
-
ruby_copy
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
task down: :environment do
|
26
|
-
Spree::Deprecation.warn("rake spree:migrations:copy_order_bill_address_to_credit_card:down has been deprecated and will be removed with Solidus 3.0.")
|
27
|
-
|
28
|
-
Spree::CreditCard.update_all(address_id: nil)
|
29
|
-
end
|
30
|
-
|
31
|
-
def ruby_copy
|
32
|
-
scope = Spree::CreditCard.where(address_id: nil).includes(payments: :order)
|
33
|
-
|
34
|
-
scope.find_each(batch_size: 500) do |cc|
|
35
|
-
# remove payments that lack a bill address
|
36
|
-
payments = cc.payments.select { |p| p.order.bill_address_id }
|
37
|
-
|
38
|
-
payment = payments.sort_by do |p|
|
39
|
-
[
|
40
|
-
%w(failed invalid).include?(p.state) ? 0 : 1, # prioritize valid payments
|
41
|
-
p.created_at, # prioritize more recent payments
|
42
|
-
]
|
43
|
-
end.last
|
44
|
-
|
45
|
-
next if payment.nil?
|
46
|
-
|
47
|
-
cc.update_column(:address_id, payment.order.bill_address_id)
|
48
|
-
puts "Successfully associated billing address (#{payment.order.bill_address_id}) with credit card (#{cc.id})"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# This was 20x faster for us but the syntax is postgres-specific. I'm sure
|
53
|
-
# there are equivalent versions for other DBs if someone wants to write them.
|
54
|
-
# I took a quick stab at crafting a cross-db compatible version but it was
|
55
|
-
# slow.
|
56
|
-
def postgres_copy
|
57
|
-
batch_size = 10_000
|
58
|
-
|
59
|
-
current_start_id = 1
|
60
|
-
|
61
|
-
while current_start_id <= last_credit_card_id
|
62
|
-
current_end_id = current_start_id + batch_size
|
63
|
-
puts "updating #{current_start_id} to #{current_end_id}"
|
64
|
-
|
65
|
-
# first try to find a valid payment for each credit card
|
66
|
-
Spree::CreditCard.connection.execute(
|
67
|
-
postgres_sql(
|
68
|
-
start_id: current_start_id,
|
69
|
-
end_id: current_end_id,
|
70
|
-
payment_state: "not in ('failed', 'invalid')"
|
71
|
-
)
|
72
|
-
)
|
73
|
-
|
74
|
-
# fall back to using invalid payments for each credit card
|
75
|
-
Spree::CreditCard.connection.execute(
|
76
|
-
postgres_sql(
|
77
|
-
start_id: current_start_id,
|
78
|
-
end_id: current_end_id,
|
79
|
-
payment_state: "in ('failed', 'invalid')"
|
80
|
-
)
|
81
|
-
)
|
82
|
-
|
83
|
-
current_start_id += batch_size
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def postgres_sql(start_id:, end_id:, payment_state:)
|
88
|
-
<<-SQL
|
89
|
-
update spree_credit_cards c
|
90
|
-
set address_id = o.bill_address_id
|
91
|
-
from spree_payments p
|
92
|
-
inner join spree_orders o
|
93
|
-
on o.id = p.order_id
|
94
|
-
and o.bill_address_id is not null
|
95
|
-
left join (
|
96
|
-
select p2.*
|
97
|
-
from spree_payments p2
|
98
|
-
inner join spree_orders o2
|
99
|
-
on o2.id = p2.order_id
|
100
|
-
and o2.bill_address_id is not null
|
101
|
-
) more_recent_payment
|
102
|
-
on more_recent_payment.source_id = p.source_id
|
103
|
-
and more_recent_payment.source_type = 'Spree::CreditCard'
|
104
|
-
and more_recent_payment.created_at > p.created_at
|
105
|
-
and more_recent_payment.state #{payment_state}
|
106
|
-
where c.address_id is null
|
107
|
-
and p.source_id = c.id
|
108
|
-
and p.source_type = 'Spree::CreditCard'
|
109
|
-
and p.state #{payment_state}
|
110
|
-
and more_recent_payment.id is null
|
111
|
-
and o.bill_address_id is not null
|
112
|
-
and c.id between #{start_id} and #{end_id}
|
113
|
-
SQL
|
114
|
-
end
|
115
|
-
|
116
|
-
def last_credit_card_id
|
117
|
-
Spree::CreditCard.last.try!(:id) || 0
|
118
|
-
end
|
119
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace :solidus do
|
4
|
-
namespace :migrations do
|
5
|
-
namespace :migrate_shipping_rate_taxes do
|
6
|
-
task up: :environment do
|
7
|
-
Spree::Deprecation.warn("rake spree:migrations:migrate_shipping_rate_taxes:up has been deprecated and will be removed with Solidus 3.0.")
|
8
|
-
|
9
|
-
print "Adding persisted tax notes to historic shipping rates ... "
|
10
|
-
Spree::ShippingRate.where.not(tax_rate_id: nil).find_each do |shipping_rate|
|
11
|
-
tax_rate = Spree::TaxRate.unscoped.find(shipping_rate.tax_rate_id)
|
12
|
-
shipping_rate.taxes.find_or_create_by!(
|
13
|
-
tax_rate: tax_rate,
|
14
|
-
amount: tax_rate.compute_amount(shipping_rate)
|
15
|
-
)
|
16
|
-
end
|
17
|
-
Spree::ShippingRate.where.not(tax_rate_id: nil).update_all(tax_rate_id: nil)
|
18
|
-
puts "Success."
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace 'spree:migrations:migrate_user_addresses' do
|
4
|
-
# This creates an entry in the user_addresses table for a user's currently
|
5
|
-
# associated shipping and billing addresses.
|
6
|
-
|
7
|
-
# This task should not need to be run more than once. But the de-dup behavior in
|
8
|
-
# UserAddressBook should make it safe.
|
9
|
-
# When the code (in the same PR) is deployed, each new order's addresses will be added
|
10
|
-
# to the user's address book. This will catch up all the historical data.
|
11
|
-
|
12
|
-
task up: :environment do
|
13
|
-
Spree::Deprecation.warn("rake spree:migrations:migrate_user_addresses:up has been deprecated and will be removed with Solidus 3.0.")
|
14
|
-
|
15
|
-
Spree.user_class.find_each(batch_size: 500) do |user|
|
16
|
-
ship_address = Spree::Address.find_by(id: user.ship_address_id)
|
17
|
-
bill_address = Spree::Address.find_by(id: user.bill_address_id)
|
18
|
-
|
19
|
-
current_addresses = [bill_address, ship_address].compact.uniq
|
20
|
-
|
21
|
-
current_addresses.each do |address|
|
22
|
-
# since ship_address is last, it will override bill_address as default when both are present
|
23
|
-
user.save_in_address_book(address.attributes, true)
|
24
|
-
end
|
25
|
-
|
26
|
-
puts "Migrated addresses for user ##{user.id}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
task down: :environment do
|
31
|
-
Spree::Deprecation.warn("rake spree:migrations:migrate_user_addresses:down has been deprecated and will be removed with Solidus 3.0.")
|
32
|
-
Spree::UserAddress.delete_all
|
33
|
-
end
|
34
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'solidus/migrations/rename_gateways'
|
4
|
-
|
5
|
-
namespace 'solidus:migrations:rename_gateways' do
|
6
|
-
task up: :environment do
|
7
|
-
Spree::Deprecation.warn("rake solidus:migrations:rename_gateways:up has been deprecated and will be removed with Solidus 3.0.")
|
8
|
-
count = Solidus::Migrations::RenameGateways.new.up
|
9
|
-
|
10
|
-
unless ENV['VERBOSE'] == 'false' || !verbose
|
11
|
-
puts "Renamed #{count} gateways into payment methods."
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
task down: :environment do
|
16
|
-
Spree::Deprecation.warn("rake solidus:migrations:rename_gateways:down has been deprecated and will be removed with Solidus 3.0.")
|
17
|
-
count = Solidus::Migrations::RenameGateways.new.down
|
18
|
-
|
19
|
-
unless ENV['VERBOSE'] == 'false' || !verbose
|
20
|
-
puts "Renamed #{count} payment methods into gateways."
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace :order_capturing do
|
4
|
-
desc "Looks for orders with inventory that is fully shipped/short-shipped, and captures money for it"
|
5
|
-
task capture_payments: :environment do
|
6
|
-
Spree::Deprecation.warn("rake order_capturing:capture_payments has been deprecated and will be removed with Solidus 3.0.")
|
7
|
-
|
8
|
-
failures = []
|
9
|
-
orders = Spree::Order.complete.where(payment_state: 'balance_due').where('completed_at > ?', Spree::Config[:order_capturing_time_window].days.ago)
|
10
|
-
|
11
|
-
orders.find_each do |order|
|
12
|
-
if order.inventory_units.all? { |iu| iu.canceled? || iu.shipped? }
|
13
|
-
if Spree::OrderCapturing.failure_handler
|
14
|
-
begin
|
15
|
-
Spree::OrderCapturing.new(order).capture_payments
|
16
|
-
rescue StandardError => e
|
17
|
-
failures << { message: "Order #{order.number} unable to capture. #{e.class}: #{e.message}" }
|
18
|
-
end
|
19
|
-
else
|
20
|
-
Spree::OrderCapturing.new(order).capture_payments
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
Spree::OrderCapturing.failure_handler.call(failures) if failures.any?
|
26
|
-
end
|
27
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace :solidus do
|
4
|
-
desc 'Prints orders with invalid email (after fix for GHSA-qxmr-qxh6-2cc9)'
|
5
|
-
task check_orders_with_invalid_email: :environment do
|
6
|
-
matches = Spree::Order.find_each.reduce([]) do |matches, order|
|
7
|
-
order.email.nil? || Spree::EmailValidator::EMAIL_REGEXP.match?(order.email) ? matches : matches + [order]
|
8
|
-
end
|
9
|
-
if matches.any?
|
10
|
-
puts 'Email / ID / Number'
|
11
|
-
puts(matches.map do |order|
|
12
|
-
"#{order.email} / #{order.id} / #{order.number}"
|
13
|
-
end.join("\n"))
|
14
|
-
else
|
15
|
-
puts 'NO MATCHES'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|