Skip to content

Commit ee4852c

Browse files
Kendra RigabenjaminwilAlistairNorman
committed
Don't use mock_model in model test
We can just use the FactoryBot factories instead. Co-Authored-By: Benjamin <benjamin@super.gd> Co-Authored-By: Alistair <alistair@super.gd>
1 parent 1e26e54 commit ee4852c

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

TODO.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ In-Memory Order Updater TODO
2929
- "This is really something which theoretically should be covered in tests"
3030

3131
## Mar 28, 2025
32-
- [ ] Verify if it is a breaking change to call
32+
- [x] Verify if it is a breaking change to call
3333
`LineItem#set_required_attributes` in `after_initialize` instead of
3434
`before_validation`. We think this may be a breaking change that requires
35-
further investigation.
35+
further investigation. (We investigated and don't believe it is a breaking change.)

promotions/spec/models/solidus_promotions/conditions/line_item_product_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
describe "#eligible?(line_item)" do
1616
subject { condition.eligible?(line_item, {}) }
1717

18-
let(:condition_line_item) { Spree::LineItem.new(product: condition_product) }
19-
let(:other_line_item) { Spree::LineItem.new(product: other_product) }
18+
let(:condition_line_item) { build(:line_item, product: condition_product) }
19+
let(:other_line_item) { build(:line_item) }
2020

2121
let(:condition_options) { super().merge(products: [condition_product]) }
22-
let(:condition_product) { mock_model(Spree::Product, tax_category: nil) }
23-
let(:other_product) { mock_model(Spree::Product, tax_category: nil) }
22+
let(:condition_product) { build(:product) }
2423

2524
it "is eligible if there are no products" do
2625
expect(condition).to be_eligible(condition_line_item)

promotions/spec/models/solidus_promotions/conditions/product_spec.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,11 @@
188188
describe "#eligible?(line_item)" do
189189
subject { condition.eligible?(line_item) }
190190

191-
let(:condition_line_item) { Spree::LineItem.new(product: condition_product) }
192-
let(:other_line_item) { Spree::LineItem.new(product: other_product) }
191+
let(:condition_line_item) { build(:line_item, product: condition_product) }
192+
let(:other_line_item) { build(:line_item) }
193193

194194
let(:condition_options) { super().merge(products: [condition_product]) }
195-
let(:condition_product) { mock_model(Spree::Product, tax_category: nil) }
196-
let(:other_product) { mock_model(Spree::Product, tax_category: nil) }
195+
let(:condition_product) { build(:product) }
197196

198197
it "is eligible if there are no products" do
199198
expect(condition).to be_eligible(condition_line_item)

0 commit comments

Comments
 (0)