From 5ecd078de8f045e2cc4bbcab20adde8c349186f7 Mon Sep 17 00:00:00 2001 From: Noah Silvera Date: Fri, 25 Oct 2024 16:47:25 -0400 Subject: [PATCH] Add describe block to Shipment#update_amounts test --- core/spec/models/spree/shipment_spec.rb | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/core/spec/models/spree/shipment_spec.rb b/core/spec/models/spree/shipment_spec.rb index e1a5293a357..5c6c9703a37 100644 --- a/core/spec/models/spree/shipment_spec.rb +++ b/core/spec/models/spree/shipment_spec.rb @@ -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