Fixes an issue where the LineItem :sorted_by_name_and_unit_value scope was not working with removal of the default scopes on line item and variant, which meant that the join in the scope was excluding soft-deleted items that should not have been excluded.
Where the presence of an object is being validated and that object comes from an *association*, we should use `validates :object, presence: true` instead of `validates :object_id, presence: true`.
This does not apply in the same way to validations on uniqueness of certain attributes, such as `validates :object_id, uniqueness...`
Enumerable#uniq is fine (eg calling #uniq on an Array object), but now using #uniq on an ActiveRecord::Relation is deprecated in favour of #distinct (which modifies the query itself, as opposed to iterating over the results of the query).
Fixes:
384) Spree::OrderMailer basic behaviour doesn't aggressively escape double quotes in confirmation body
Failure/Error: adjustments = adjustments.to_a + order.shipment_adjustments.to_a
ActionView::Template::Error:
Cannot have a has_many :through association 'Spree::Order#shipment_adjustments' which goes through 'Spree::Order#shipments' before the through association is defined.
# ./app/helpers/checkout_helper.rb:10:in `checkout_adjustments_for'
# ./app/views/spree/order_mailer/_order_summary.html.haml:43:in `_app_views_spree_order_mailer__order_summary_html_haml__2911251238692323485_70331958934800'
# ./app/views/spree/order_mailer/confirm_email_for_customer.html.haml:23:in `_app_views_spree_order_mailer_confirm_email_for_customer_html_haml__3734564010704881256_70331959518520'
# ./app/mailers/spree/order_mailer.rb:35:in `block in confirm_email_for_customer'
# ./app/mailers/spree/order_mailer.rb:33:in `confirm_email_for_customer'
# ./spec/mailers/order_mailer_spec.rb:20:in `block (3 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# ActiveRecord::HasManyThroughOrderError:
# Cannot have a has_many :through association 'Spree::Order#shipment_adjustments' which goes through 'Spree::Order#shipments' before the through association is defined.
# ./app/helpers/checkout_helper.rb:10:in `checkout_adjustments_for'
Fixes:
259) Spree::ShippingMethod#shipments can gather all the related shipments
Failure/Error: expect(shipping_method.shipments).to include(shipment)
ActiveRecord::HasManyThroughOrderError:
Cannot have a has_many :through association 'Spree::ShippingMethod#shipments' which goes through 'Spree::ShippingMethod#shipping_rates' before the through association is defined.
# ./spec/models/spree/shipping_method_spec.rb:190:in `block (3 levels) in <module:Spree>'
Fixes:
292) OrderManagement::Subscriptions::ProxyOrderSyncer#sync! when the subscription is not persisted and the schedule includes upcoming oc that closes after ends_at does not create a new proxy order for that oc
Failure/Error: order_cycle.schedules << schedule
ActiveRecord::HasManyThroughOrderError:
Cannot have a has_many :through association 'OrderCycle#schedules' which goes through 'OrderCycle#order_cycle_schedules' before the through association is defined.
# ./spec/factories.rb:29:in `block (4 levels) in <top (required)>'
# ./spec/factories.rb:28:in `each'
# ./spec/factories.rb:28:in `block (3 levels) in <top (required)>'
# ./engines/order_management/spec/services/order_management/subscriptions/proxy_order_syncer_spec.rb:59:in `block (4 levels) in <module:Subscriptions>'
# ./engines/order_management/spec/services/order_management/subscriptions/proxy_order_syncer_spec.rb:65:in `block (4 levels) in <module:Subscriptions>'
# ./engines/order_management/spec/services/order_management/subscriptions/proxy_order_syncer_spec.rb:133:in `block (6 levels) in <module:Subscriptions>'
# ./engines/order_management/spec/services/order_management/subscriptions/proxy_order_syncer_spec.rb:133:in `block (5 levels) in <module:Subscriptions>'
Failure/Error: enterprise.andand.touch
ActiveRecord::ActiveRecordError:
cannot touch on a new or destroyed record object. Consider using persisted?, new_record?, or destroyed? before touching
# ./app/models/spree/address.rb:155:in `touch_enterprise'
# ./spec/factories/product_factory.rb:12:in `block (3 levels) in <top (required)>'
# ./spec/factories/variant_factory.rb:26:in `block (4 levels) in <top (required)>'
# ./spec/models/spree/variant_spec.rb:9:in `block (2 levels) in <module:Spree>'
We get the same value here, but without the three additional database hits to adjustments (both of these values are already present on the order object itself).