Skip to content

Commit

Permalink
Merge pull request #2018 from jhawthorn/deprecate_add_shipping_rate
Browse files Browse the repository at this point in the history
Deprecate Shipment#add_shipping_method
  • Loading branch information
jhawthorn authored Jun 14, 2017
2 parents b5ffbe8 + 49dea52 commit f0cabac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def can_transition_from_canceled_to_ready?
def add_shipping_method(shipping_method, selected = false)
shipping_rates.create(shipping_method: shipping_method, selected: selected, cost: cost)
end
deprecate :add_shipping_method, deprecator: Spree::Deprecation

def after_cancel
manifest.each { |item| manifest_restock(item) }
Expand Down
6 changes: 5 additions & 1 deletion core/lib/spree/testing_support/factories/shipment_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

after(:create) do |shipment, evaluator|
shipping_method = evaluator.shipping_method || create(:shipping_method, cost: evaluator.cost)
shipment.add_shipping_method(shipping_method, true)
shipment.shipping_rates.create!(
shipping_method: shipping_method,
cost: evaluator.cost,
selected: true
)

shipment.order.line_items.each do |line_item|
line_item.quantity.times do
Expand Down
2 changes: 1 addition & 1 deletion core/spec/models/spree/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@

describe '#selected_shipping_rate_id=' do
let!(:air_shipping_method) { create(:shipping_method, name: "Air") }
let(:new_rate) { shipment.add_shipping_method(air_shipping_method) }
let(:new_rate) { shipment.shipping_rates.create!(shipping_method: air_shipping_method) }

context 'when the id exists' do
it 'sets the new shipping rate as selected' do
Expand Down

0 comments on commit f0cabac

Please sign in to comment.