-
-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplement Spree's simple_product in OFN factory #2493
Reimplement Spree's simple_product in OFN factory #2493
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any failures fixed by this change?
A lot of tests still fail because of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, the simple_product was just an extension of base_product with on_hand = 5.
I am pretty sure tests will depend on that number (5) to pass. How are we planning to address that? Have you considered not changing from simple to base but instead create a new simple product that still extends base product and would address the "on_hand" thing in a spree2 friendly manner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this fixes some tests, it doesn't fix the underlying problem that we are relying on Spree's factories here. This change is typical shotgun surgery. The solution would be to create our own simple_product
. Long term, I would like to only use our own factories. I always find it annoying to look for a factory, not finding it in our code base and then needing to search the Spree modules to find it.
https://refactoring.guru/smells/shotgun-surgery
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @mkllnk, watching for shotgun surgery will make things more changeable in the future. And we know more upgrades will come.
Ok so I should instead create our own product factory, is that right ? |
and call it |
Should I take into account https://github.com/openfoodfoundation/openfoodnetwork/pull/2417/files and keep a |
@HugsDaniel I think you should keep what's in there. on_hand? I believe we will still have on_hand available after the upgrade. even if only an adapter. |
7ab57b7
to
eab04e0
Compare
Yes @HugsDaniel. You can assume that there will be methods called |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a tiny style comment below. ;-)
spec/factories.rb
Outdated
@@ -526,4 +530,5 @@ | |||
user.spree_roles << Spree::Role.find_or_create_by_name!('admin') | |||
end | |||
end | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this slipped in accidentally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it did, sorry about that
What? Why?
Closes #2433
As explained in the PR, Spree's product factory got rid of
simple_product
in favor ofbase_product
, making all of our tests usingsimple_product
fail.I reimplemented the Spree<2.0
simple_product
factory inside OFNspec/factories.rb
, inheriting from OFN's override of Spree'sbase_product
factory.As before, a
simple_product
is an extension of abase_product
withon_hand 5
.What should we test?
All tests using Spree's
product_factory
don't fail onsimple_product
.Release notes
Spree Upgrade - Reimplementation in OFN of Spree's
simple_product
, inheriting frombase_product
, as a test helper.Changelog Category: Changed
How is this related to the Spree upgrade?
Spree 2.0 removed
simple_product
in theirproduct_factory
, so it has been reimplemented in OFN factories to enable its use in test suite.