workarea-commerce / workarea

Workarea is an enterprise-grade Ruby on Rails commerce platform
https://www.workarea.com
Other
327 stars 66 forks source link

Setting localized_active_fields to false causes multiple tests to fail #557

Closed mmannino closed 3 years ago

mmannino commented 3 years ago

Describe the bug When setting localized_active_fields to false, the follow test files have 1 or more failures. test/integration/workarea/storefront/segments_integration_test.rb test/models/workarea/releasable_active_test.rb

To Reproduce Set localized_active_fields = false in initializers/workarea.rb Run the following tests. test/integration/workarea/storefront/segments_integration_test.rb test/models/workarea/releasable_active_test.rb

Expected behavior All tests should pass. In the releasable_active_test.rb, the test itself is assuming there is a mongoid localized array; this is any easy fix of the tests themselves.

In the segments_integration_test the behavior is much more subtle. From what I can tell, the active? method override in Segmentable is being pre-empted by the Mongoid active? when the underlying active field is no longer localized but a simple boolean field; so when the discount is being tested to see if it's active? (in Pricing::Discount::Collection.all) the Mongoid active? is being called instead of the Segmentable#active? The end result is that a Discount that is relying on a specific segment in order to be active is simply going by the active flag and ignoring the active segments of the request.

Workarea Setup (please complete the following information):

Attachments

Additional context Add any other context about the problem here.

bencrouse commented 3 years ago

We'll look into this, thanks for reporting.

bencrouse commented 3 years ago

Closing, this was fixed in PR #563