Skip to content

Commit 1b399a2

Browse files
committed
Promotion order adjuster: update adjustment labels
If a promotion calculator implements a dynamic `#{adjustable}_adjustment_label` method, we need to update the adjustment label when it changes. This makes sure that is the case.
1 parent 662b0a7 commit 1b399a2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

promotions/app/models/solidus_promotions/order_adjuster/persist_discounted_order.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ def update_adjustment(item, discount_item)
7070
adjustment ||= item.adjustments.new(
7171
source: discount_item.source,
7272
order_id: item.is_a?(Spree::Order) ? item.id : item.order_id,
73-
label: discount_item.label
7473
)
7574
adjustment.amount = discount_item.amount
75+
adjustment.label = discount_item.label
7676
adjustment
7777
end
7878
end

promotions/spec/models/solidus_promotions/order_adjuster_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@
8080
expect(adjustable.current_discounts).to be_empty
8181
end
8282

83+
it "updates adjustment labels" do
84+
subject
85+
expect_any_instance_of(SolidusPromotions::Benefit).to receive(:adjustment_label).and_return("Changed Adjustment Label")
86+
expect { order_adjuster.call }
87+
.to change { order.line_items.first.adjustments.first.label }
88+
.from("Promotion (Because we like you)")
89+
.to("Changed Adjustment Label")
90+
end
91+
8392
context "if order is complete but not shipped" do
8493
let(:line_item) { order.line_items.first }
8594
let(:order) { create(:order_ready_to_ship) }

0 commit comments

Comments
 (0)