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

Replace uniq with distinct for cartons association #2710

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Shipment < Spree::Base
has_many :shipping_rates, -> { order(:cost) }, dependent: :destroy, inverse_of: :shipment
has_many :shipping_methods, through: :shipping_rates
has_many :state_changes, as: :stateful
has_many :cartons, -> { uniq }, through: :inventory_units
has_many :cartons, -> { distinct }, through: :inventory_units

before_validation :set_cost_zero_when_nil

Expand Down
9 changes: 9 additions & 0 deletions core/spec/models/spree/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -895,4 +895,13 @@
end
end
end

describe '#cartons' do
let(:carton) { create(:carton) }
let(:shipment) { carton.shipments.first }

subject { shipment.cartons }

it { is_expected.to include carton }
end
end