Skip to content

Commit d3ef74b

Browse files
authored
Merge pull request solidusio#6381 from mamhoff/fix-percent-with-cap-ui
Promotions: Fix default calculator fields partial bug and make PercentWithCap calculator available in the UI
2 parents ea4bb50 + 7e1de2d commit d3ef74b

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
@@ -81,6 +81,7 @@ class Configuration < Spree::Preferences::Configuration
8181
"SolidusPromotions::Calculators::FlatRate",
8282
"SolidusPromotions::Calculators::FlexiRate",
8383
"SolidusPromotions::Calculators::Percent",
84+
"SolidusPromotions::Calculators::PercentWithCap",
8485
"SolidusPromotions::Calculators::TieredFlatRate",
8586
"SolidusPromotions::Calculators::TieredPercent",
8687
"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
@@ -185,4 +185,15 @@
185185
expect(page).to have_content("Condition has been successfully updated!")
186186
end
187187
end
188+
189+
describe "Rendering the promotion edit page with the PercentWithCap calculator" do
190+
let(:promotion) { create(:solidus_promotion, name: "My capped promotion", benefits: [benefit]) }
191+
let(:benefit) { SolidusPromotions::Benefits::AdjustLineItem.new(calculator:) }
192+
let(:calculator) { SolidusPromotions::Calculators::PercentWithCap.new(preferred_percent: 10, preferred_max_amount: 100) }
193+
194+
it "renders without errors" do
195+
visit solidus_promotions.edit_admin_promotion_path(promotion)
196+
expect(page).to have_content("My capped promotion")
197+
end
198+
end
188199
end

0 commit comments

Comments
 (0)