Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ActiveRecord relation for Spree::Shipment#line_items #2886

Merged
merged 1 commit into from
Oct 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Shipment < Spree::Base
has_many :shipping_methods, through: :shipping_rates
has_many :state_changes, as: :stateful
has_many :cartons, -> { distinct }, through: :inventory_units
has_many :line_items, -> { distinct }, through: :inventory_units

before_validation :set_cost_zero_when_nil

Expand Down Expand Up @@ -188,10 +189,6 @@ def item_cost
line_items.map(&:total).sum
end

def line_items
inventory_units.includes(:line_item).map(&:line_item).uniq
end

def ready_or_pending?
ready? || pending?
end
Expand Down