Skip to content

Commit 1baa767

Browse files
authored
Merge pull request #6394 from mamhoff/backport/v4.6/pr-6381
[v4.6] Promotions: Fix default calculator fields partial bug and make PercentWithCap calculator available in the UI
2 parents 9dc65d9 + 3ef805b commit 1baa767

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

promotions/config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ en:
195195
solidus_promotions/benefits/adjust_line_item_quantity_groups: Discount matching line items based on quantity groups
196196
solidus_promotions/calculators/distributed_amount: Distributed Amount
197197
solidus_promotions/calculators/percent: Percent
198+
solidus_promotions/calculators/percent_with_cap: Distributed Percent with cap
198199
solidus_promotions/calculators/flat_rate: Flat Rate
199200
solidus_promotions/calculators/flexi_rate: Flexible Rate
200201
solidus_promotions/calculators/tiered_flat_rate: Tiered Flat Rate

promotions/lib/solidus_promotions/configuration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class Configuration < Spree::Preferences::Configuration
7070
"SolidusPromotions::Calculators::FlatRate",
7171
"SolidusPromotions::Calculators::FlexiRate",
7272
"SolidusPromotions::Calculators::Percent",
73+
"SolidusPromotions::Calculators::PercentWithCap",
7374
"SolidusPromotions::Calculators::TieredFlatRate",
7475
"SolidusPromotions::Calculators::TieredPercent",
7576
"SolidusPromotions::Calculators::TieredPercentOnEligibleItemQuantity"

promotions/lib/views/backend/solidus_promotions/admin/calculator_fields/_default_fields.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
<%= render "solidus_promotions/admin/shared/preference_fields/#{calculator.preference_type(name)}",
33
name: "#{prefix}[calculator_attributes][preferred_#{name}]",
44
value: calculator.get_preference(name),
5-
label: calculator.class.human_attribute_name("preferred_#{name}", default: I18n.t(name, scope: :spree, default: name.humanize)) %>
5+
label: calculator.class.human_attribute_name("preferred_#{name}", default: I18n.t(name, scope: :spree, default: name.to_s.humanize)) %>
66
<% end %>

promotions/spec/system/solidus_promotions/backend/promotions_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,15 @@
161161
expect(page).to have_content("Benefit has been successfully removed!")
162162
end
163163
end
164+
165+
describe "Rendering the promotion edit page with the PercentWithCap calculator" do
166+
let(:promotion) { create(:solidus_promotion, name: "My capped promotion", benefits: [benefit]) }
167+
let(:benefit) { SolidusPromotions::Benefits::AdjustLineItem.new(calculator:) }
168+
let(:calculator) { SolidusPromotions::Calculators::PercentWithCap.new(preferred_percent: 10, preferred_max_amount: 100) }
169+
170+
it "renders without errors" do
171+
visit solidus_promotions.edit_admin_promotion_path(promotion)
172+
expect(page).to have_content("My capped promotion")
173+
end
174+
end
164175
end

0 commit comments

Comments
 (0)