From f2193c93de8a032bf2eb45fcd8e125c5ed42b7d0 Mon Sep 17 00:00:00 2001 From: vrastello Date: Mon, 23 May 2022 20:27:01 -0700 Subject: [PATCH 1/3] add new test case --- core/spec/models/spree/promotion_rule_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/spec/models/spree/promotion_rule_spec.rb b/core/spec/models/spree/promotion_rule_spec.rb index c3f057ab18c..f0da5495bd8 100644 --- a/core/spec/models/spree/promotion_rule_spec.rb +++ b/core/spec/models/spree/promotion_rule_spec.rb @@ -16,6 +16,10 @@ def eligible? expect { BadTestRule.new.eligible? }.to raise_error(ArgumentError) end + it 'forces developer to implement applicable? method' do + expect { BadTestRule.new.applicable? }.to raise_error(ArgumentError) + end + it 'validates unique rules for a promotion' do TestRule.create!(promotion: promotion) From d3f5b6bf8e6c2c0e3e0daa32b19e4dee8233f5ec Mon Sep 17 00:00:00 2001 From: vrastello Date: Mon, 23 May 2022 20:29:37 -0700 Subject: [PATCH 2/3] adding tiered_flat_rate_spec --- core/spec/models/spree/calculator/tiered_flat_rate_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/spec/models/spree/calculator/tiered_flat_rate_spec.rb b/core/spec/models/spree/calculator/tiered_flat_rate_spec.rb index 170c1761927..19d3ef76d1a 100644 --- a/core/spec/models/spree/calculator/tiered_flat_rate_spec.rb +++ b/core/spec/models/spree/calculator/tiered_flat_rate_spec.rb @@ -13,8 +13,11 @@ end context 'when tiers is a hash' do + before { calculator.preferred_tiers = { 'nope' => 20 } } + + it { is_expected.to be true } + context 'and one of the keys is not a positive number' do - before { calculator.preferred_tiers = { 'nope' => 20 } } it { is_expected.to be false } end From 26f22854bab8c7b444b51944f45273e05fc93aed Mon Sep 17 00:00:00 2001 From: vrastello Date: Mon, 23 May 2022 20:30:52 -0700 Subject: [PATCH 3/3] tiered percent spec --- core/spec/models/spree/calculator/tiered_percent_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/spec/models/spree/calculator/tiered_percent_spec.rb b/core/spec/models/spree/calculator/tiered_percent_spec.rb index 2d1b5b1d6e3..c782644ff8f 100644 --- a/core/spec/models/spree/calculator/tiered_percent_spec.rb +++ b/core/spec/models/spree/calculator/tiered_percent_spec.rb @@ -25,8 +25,11 @@ end context 'when tiers is a hash' do + before { calculator.preferred_tiers = { 'nope' => 20 } } + + it { is_expected.to be true } + context 'and one of the keys is not a positive number' do - before { calculator.preferred_tiers = { 'nope' => 20 } } it { is_expected.to be false } end