solidus_core 2.11.10 → 2.11.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8eb3e5a4b41af8809472fc7d7875fd2be9101bc2673b2d289bc32e5f6bc0cabc
4
- data.tar.gz: 48aac9f88550bbaa4ce69271426877fed50459b23c5fe3109bed565e553fe0b3
3
+ metadata.gz: a612b396e4f6bd4624851ca8c6a234c6cc1628c8e6edf889d62fb57830b452a2
4
+ data.tar.gz: 95129bf8b5ad056d9356b63b4a89eaf36697208d16035e84b7627d8d3a710996
5
5
  SHA512:
6
- metadata.gz: 7b3adaf152c0e1a8bf34de8bf8577a8a369e51a6acb0215b558f055a1235b1b7499e50778cc040cf08221ee98d79df07d72b9112f61ad3158dd226b5c8af73e1
7
- data.tar.gz: dd950b0d62311e85c9e72cea449650b04d9388c2443e1dbb187bc885bf24f128338fb96e0b0b5eb177b9b444c2bb738b8d59d6bfdb298eb774b7391367e15b2d
6
+ metadata.gz: ba3b3f8246277100e2b3f9f71edca05cd76a1352e851cff75a36c68f7eb8107485ac7d258a0ea15703e3e7582542c24aef1d0201e9d3697b6fbbe80e6315581c
7
+ data.tar.gz: 219847c0d55e4b02063c69e32a7a0a0399600d083ab915c707722be181f87a591b87a2245e241ba77cee23253ca869228e638eecb8d3ebceb17e67371a125f05
@@ -584,7 +584,7 @@ module Spree
584
584
  raise CannotRebuildShipments.new(I18n.t('spree.cannot_rebuild_shipments_shipments_not_pending'))
585
585
  else
586
586
  shipments.destroy_all
587
- self.shipments = Spree::Config.stock.coordinator_class.new(self).shipments
587
+ shipments.push(*Spree::Config.stock.coordinator_class.new(self).shipments)
588
588
  end
589
589
  end
590
590
 
@@ -26,10 +26,16 @@ module Spree
26
26
  # @param payment [Spree::Payment] - the payment that should be canceled
27
27
  #
28
28
  def cancel(payment)
29
- if response = payment.payment_method.try_void(payment)
30
- payment.handle_void_response(response)
29
+ # For payment methods already implemeting `try_void`
30
+ if try_void_available?(payment.payment_method)
31
+ if response = payment.payment_method.try_void(payment)
32
+ payment.handle_void_response(response)
33
+ else
34
+ payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason, perform_after_create: false).perform!
35
+ end
31
36
  else
32
- payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason, perform_after_create: false).perform!
37
+ # For payment methods not yet implemeting `try_void`
38
+ deprecated_behavior(payment)
33
39
  end
34
40
  end
35
41
 
@@ -38,6 +44,19 @@ module Spree
38
44
  def refund_reason
39
45
  Spree::RefundReason.where(name: reason).first_or_create
40
46
  end
47
+
48
+ def try_void_available?(payment_method)
49
+ payment_method.respond_to?(:try_void) &&
50
+ payment_method.method(:try_void).owner != Spree::PaymentMethod
51
+ end
52
+
53
+ def deprecated_behavior(payment)
54
+ Spree::Deprecation.warn "#{payment.payment_method.class.name}#cancel is deprecated and will be removed. " \
55
+ 'Please implement a `try_void` method instead that returns a response object if void succeeds ' \
56
+ 'or `false|nil` if not. Solidus will refund the payment then.'
57
+ response = payment.payment_method.cancel(payment.response_code)
58
+ payment.handle_void_response(response)
59
+ end
41
60
  end
42
61
  end
43
62
  end
@@ -49,7 +49,6 @@ module Spree
49
49
 
50
50
  has_many :variants,
51
51
  -> { where(is_master: false).order(:position) },
52
- inverse_of: :product,
53
52
  class_name: 'Spree::Variant'
54
53
 
55
54
  has_many :variants_including_master,
@@ -73,11 +73,16 @@ module Spree
73
73
  packages = split_packages(packages)
74
74
 
75
75
  # Turn the Stock::Packages into a Shipment with rates
76
- packages.map do |package|
76
+ shipments = packages.map do |package|
77
77
  shipment = package.shipment = package.to_shipment
78
78
  shipment.shipping_rates = Spree::Config.stock.estimator_class.new.shipping_rates(package)
79
79
  shipment
80
80
  end
81
+
82
+ # Make sure we don't add the proposed shipments to the order
83
+ order.shipments = order.shipments - shipments
84
+
85
+ shipments
81
86
  end
82
87
 
83
88
  def split_packages(initial_packages)
@@ -30,7 +30,7 @@ module Spree
30
30
  attr_writer :rebuild_vat_prices
31
31
  include Spree::DefaultPrice
32
32
 
33
- belongs_to :product, -> { with_discarded }, touch: true, class_name: 'Spree::Product', inverse_of: :variants, optional: false
33
+ belongs_to :product, -> { with_discarded }, touch: true, class_name: 'Spree::Product', inverse_of: :variants_including_master, optional: false
34
34
  belongs_to :tax_category, class_name: 'Spree::TaxCategory', optional: true
35
35
 
36
36
  delegate :name, :description, :slug, :available_on, :discontinue_on, :discontinued?,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spree
4
- VERSION = "2.11.10"
4
+ VERSION = "2.11.11"
5
5
 
6
6
  def self.solidus_version
7
7
  VERSION
@@ -52,7 +52,13 @@ module Spree
52
52
  :month, :year, :expiry, :first_name, :last_name, :name
53
53
  ]
54
54
 
55
- @@customer_return_attributes = [:stock_location_id, return_items_attributes: [:id, :inventory_unit_id, :return_authorization_id, :returned, :amount, :reception_status_event, :acceptance_status, :exchange_variant_id, :resellable]]
55
+ @@customer_return_attributes = [
56
+ :stock_location_id, return_items_attributes: [
57
+ :id, :inventory_unit_id, :return_authorization_id, :returned, :amount,
58
+ :reception_status_event, :acceptance_status, :exchange_variant_id,
59
+ :resellable, :return_reason_id
60
+ ]
61
+ ]
56
62
 
57
63
  @@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
58
64
 
@@ -45,6 +45,7 @@ module DummyApp
45
45
  end
46
46
 
47
47
  class Application < ::Rails::Application
48
+ config.has_many_inverse = true
48
49
  config.eager_load = false
49
50
  config.cache_classes = true
50
51
  config.cache_store = :memory_store
@@ -3,22 +3,29 @@
3
3
  namespace :solidus do
4
4
  namespace :migrations do
5
5
  namespace :migrate_default_billing_addresses_to_address_book do
6
- task up: :environment do
7
- print "Migrating default billing addresses to address book ... "
6
+ task :up, [:batch_size] => [:environment] do |_t, args|
7
+ batch_size = args[:batch_size] || 100_000
8
+ print "Migrating default billing addresses to address book in batches of #{batch_size} ... "
8
9
  if Spree::UserAddress.where(default_billing: true).any?
9
- Spree.user_class.joins(:bill_address).update_all(bill_address_id: nil) # rubocop:disable Rails/SkipsModelValidations
10
+ Spree.user_class.joins(:bill_address).in_batches(of: batch_size).each do |batch|
11
+ batch.update_all(bill_address_id: nil) # rubocop:disable Rails/SkipsModelValidations
12
+ end
10
13
  end
11
14
  Spree::UserAddress.joins(
12
15
  <<~SQL
13
16
  JOIN spree_users ON spree_user_addresses.user_id = spree_users.id
14
17
  AND spree_user_addresses.address_id = spree_users.bill_address_id
15
18
  SQL
16
- ).update_all(default_billing: true)
19
+ ).in_batches(of: batch_size).each do |batch|
20
+ batch.update_all(default_billing: true) # rubocop:disable Rails/SkipsModelValidations
21
+ end
22
+
17
23
  puts "Success"
18
24
  end
19
25
 
20
- task down: :environment do
21
- Spree::UserAddress.update_all(default_billing: false) # rubocop:disable Rails/SkipsModelValidations
26
+ task :down, [:batch_size] => [:environment] do |_t, args|
27
+ batch_size = args[:batch_size] || 100_000
28
+ Spree::UserAddress.in_batches(of: batch_size).update_all(default_billing: false) # rubocop:disable Rails/SkipsModelValidations
22
29
  puts "Rolled back default billing address migration to address book"
23
30
  end
24
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.10
4
+ version: 2.11.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-10 00:00:00.000000000 Z
11
+ date: 2021-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -985,7 +985,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
985
985
  - !ruby/object:Gem::Version
986
986
  version: 1.8.23
987
987
  requirements: []
988
- rubygems_version: 3.1.4
988
+ rubygems_version: 3.2.20
989
989
  signing_key:
990
990
  specification_version: 4
991
991
  summary: Essential models, mailers, and classes for the Solidus e-commerce project.