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

Don't capture NameError if its not a missing component #5432

Merged
merged 1 commit into from
Oct 12, 2023

Conversation

elia
Copy link
Member

@elia elia commented Oct 12, 2023

Summary

Instead of rescuing NameError we proactively check if the requested component is available. This is made possible by Zeitwerk using autoload under the hood and having all loadable constants respond true when asked if they are const_defined?.

This change is in response of having a bad constant name inside a component being reported as a typo in the component name.

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.

Instead of rescuing NameError we proactively check if the requested
component is available. This is made possible by Zeitwerk using
`autoload` under the hood and having all loadable constants respond
`true` when asked if they are `const_defined?`.
@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Merging #5432 (336a0c1) into main (afc630e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #5432   +/-   ##
=======================================
  Coverage   88.85%   88.86%           
=======================================
  Files         609      609           
  Lines       14784    14786    +2     
=======================================
+ Hits        13137    13139    +2     
  Misses       1647     1647           
Files Coverage Δ
admin/lib/solidus_admin/configuration.rb 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@elia elia marked this pull request as ready for review October 12, 2023 11:21
@elia elia requested a review from a team as a code owner October 12, 2023 11:21
@elia elia requested a review from rainerdema October 12, 2023 11:21
@elia elia changed the title Don't capture NameError if its not a missing component Don't capture NameError if its not a missing component Oct 12, 2023
Copy link
Contributor

@rainerdema rainerdema left a comment

Choose a reason for hiding this comment

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

👍

@elia elia merged commit 870e9bf into main Oct 12, 2023
4 checks passed
@elia elia deleted the elia/admin/component-name-error branch October 12, 2023 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants