Skip to content

Commit

Permalink
Add describe block to Shipment#update_amounts test
Browse files Browse the repository at this point in the history
  • Loading branch information
Noah-Silvera committed Oct 25, 2024
1 parent 340032c commit 5ecd078
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions core/spec/models/spree/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,23 @@
end
end

context "updates cost when selected shipping rate is present" do
let(:shipment) { create(:shipment) }
before { shipment.selected_shipping_rate.update!(cost: 5) }
describe "#update_amounts" do
let(:shipment) { create(:shipment, cost: 3) }

it "updates shipment totals" do
expect {
shipment.update_amounts
}.to change { shipment.cost }.to(5)
context 'when the selected shipping rate cost is different than the current shipment cost' do
before { shipment.selected_shipping_rate.update!(cost: 5) }

it "updates the shipments cost" do
expect {
shipment.update_amounts
}.to change { shipment.reload.cost }.to(5)
end

it 'changes the updated_at column' do
expect {
shipment.update_amounts
}.to change { shipment.reload.updated_at }
end
end
end

Expand Down

0 comments on commit 5ecd078

Please sign in to comment.