Skip to content

Commit

Permalink
Use shipping_method.adjustment_label in Shipment#ensure_correct_adjus…
Browse files Browse the repository at this point in the history
…tment

Fixes solidusio#3138
  • Loading branch information
radar committed Jun 6, 2013
1 parent ee1fcf8 commit e13b3e4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/app/models/spree/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,12 @@ def send_shipped_email
def ensure_correct_adjustment
if adjustment
adjustment.originator = shipping_method
adjustment.label = shipping_method.name
adjustment.label = shipping_method.adjustment_label
adjustment.amount = selected_shipping_rate.cost if adjustment.open?
adjustment.save!
adjustment.reload
elsif selected_shipping_rate_id
shipping_method.create_adjustment shipping_method.name, order, self, true, "open"
shipping_method.create_adjustment shipping_method.adjustment_label, order, self, true, "open"
reload #ensure adjustment is present on later saves
end
end
Expand Down
8 changes: 8 additions & 0 deletions core/spec/models/spree/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,14 @@
shipment.send(:ensure_correct_adjustment)
end

# Regression test for #3138
it "should use the shipping method's adjustment label" do
shipment.stub(:selected_shipping_rate_id => 1)
shipping_method.stub(:adjustment_label => "Foobar")
shipping_method.should_receive(:create_adjustment).with("Foobar", order, shipment, true, "open")
shipment.send(:ensure_correct_adjustment)
end

it "should update originator when adjustment is present" do
shipment.stub(selected_shipping_rate: mock_model(Spree::ShippingRate, cost: 10.00))
shipment.stub(adjustment: mock_model(Spree::Adjustment, open?: true))
Expand Down

0 comments on commit e13b3e4

Please sign in to comment.