Skip to content
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

Raise on deprecation when SOLIDUS_RAISE_DEPRECATIONS set #5813

Merged

Conversation

forkata
Copy link
Contributor

@forkata forkata commented Aug 7, 2024

Summary

Fixes #5766

This issue can be reproduced on the first commit by running the specs with the environment variable to override deprecation behaviour, as such

SOLIDUS_RAISE_DEPRECATIONS=true bundle exec rspec spec/lib/spree/deprecator_spec.rb

which produces the following output

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) Spree.deprecator by default does not raise an error unless overridden by environment
     # fix for deprecation behaviour override
     Failure/Error: expect { Dummy.new.deprecated_method }.to raise_error(ActiveSupport::DeprecationException)
       expected ActiveSupport::DeprecationException but nothing was raised

We were able to fix this issue by moving the code that sets the deprecation behaviour after the DummyApp is initialized, which seems to reset that.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@forkata forkata requested a review from a team as a code owner August 7, 2024 21:57
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Aug 7, 2024
@forkata forkata changed the title Raise error with spree deprecator Raise on deprecation when SOLIDUS_RAISE_DEPRECATIONS set Aug 7, 2024
@forkata forkata force-pushed the raise-error-with-spree-deprecator branch from e798682 to 6877d7a Compare August 7, 2024 22:05
Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@benjaminwil
Copy link
Contributor

It looks like this change has exposed some other tests that should have been raising exceptions but were not. (Because SOLIDUS_RAISE_DEPRECATIONS is set to true for CI runs.)

So we'll need to go back and fix those up before merging, it seems.

@kennyadsl
Copy link
Member

Thanks for this! We should restore the previous behavior to spot failing specs for deprecations, like it's already happening it seems. Thanks again. ❤️

mamhoff added a commit to mamhoff/solidus that referenced this pull request Aug 8, 2024
This spec still used one of the old extension points for the promotion
system, and solidusio#5813 exposed that.
@benjaminwil
Copy link
Contributor

Looks like we just need to rebase once #5814 is merged and all will be okay.

mamhoff added a commit to mamhoff/solidus that referenced this pull request Aug 8, 2024
This spec still used one of the old extension points for the promotion
system, and solidusio#5813 exposed that.
@kennyadsl
Copy link
Member

We can rebase now, thanks!

@benjaminwil benjaminwil force-pushed the raise-error-with-spree-deprecator branch from 6877d7a to 44f1b9d Compare August 9, 2024 22:49
benjaminwil and others added 2 commits August 12, 2024 09:49
These tests were written to aid in debugging an issue:

  solidusio#5766

Here we expose an issue using a pending test, with the ENV that allows
overriding of the default deprecation behavior, which gets lost during
the initialization of the `DummyApp`.

Co-authored-by: Chris Todorov <[email protected]>
This change fixes issue solidusio#5766 which seems to be caused
by the deprecator behaviour being lost when the dummy app is initialized.
By moving the code that sets the behaviour to happen after the
initialization of the dummy app we can avoid this issue.

Co-authored-by: Benjamin Willems <[email protected]>
@forkata forkata force-pushed the raise-error-with-spree-deprecator branch from 44f1b9d to 586c519 Compare August 12, 2024 16:50
Copy link

codecov bot commented Aug 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.74%. Comparing base (8da6c2a) to head (586c519).
Report is 21 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5813   +/-   ##
=======================================
  Coverage   88.74%   88.74%           
=======================================
  Files         735      735           
  Lines       17172    17172           
=======================================
  Hits        15239    15239           
  Misses       1933     1933           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @forkata and @benjaminwil! ❤️

@kennyadsl kennyadsl merged commit 5d82826 into solidusio:main Aug 19, 2024
14 checks passed
mamhoff added a commit to mamhoff/solidus that referenced this pull request Sep 2, 2024
This calculator uses the `eligible` API from `Spree::Adjustment`, which
in a system with the new promotions system will not be necessary.

This hasn't been caught before because deprecation warnings did not
raise until solidusio#5813 was merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecation warnings don't raise when they should
6 participants