-
Notifications
You must be signed in to change notification settings - Fork 900
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
Fix supports_helper stub_supports to handle unsupported_reason #22976
Conversation
@miq-bot cross-repo-test /all |
From Pull Request: ManageIQ/manageiq#22976
b22c2af
to
517f3a6
Compare
517f3a6
to
bc0151b
Compare
update:
WIP:
|
allow_any_instance_of(model).to receive(:supports?).and_call_original | ||
allow(model.supports_features).to receive(:[]).and_call_original |
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.
That's a lot nicer
We are now getting away from supports?(:supported_feature). Instead we are calling unsupported_reason(:supported_feature) It cuts down on our calls into the supports_feature_mixin. Before ====== When using stub_supports, unsupported_reason(:supported_feature) was not stubbed (and unpredictable) supports? was stubbed After ===== We are stubbing at the feature definition layer all code in unsupported_reason is run/tested all code in supports? is run/tested This puts more code under test and allows flexibility for refactoring Notes ===== Wasn't thrilled about kwarg supports, but a few tests still use that. I've changed them all but it wasn't too much work to keep this working so we can backport with minimal fuss This code better tests our features that defer to another feature
bc0151b
to
235eed6
Compare
Checked commit kbrock@235eed6 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
un-WIP: cross repo is failing for ui-classic (and ui-services). It looks like it some configuration issue. Need a second opinion on the ui-classic failure, but I'm happy with this code at this time.
|
@miq-bot cross-repo-test manageiq-ui-classic trying just to run ui-classic |
From Pull Request: ManageIQ/manageiq#22976
@Fryguy Can we merge?
|
This PR has been effectively backported to |
requires:
required by:
Overview
We are now getting away from supports?(:supported_feature). Instead we are calling unsupported_reason(:supported_feature)
It cuts down on our calls into the supports_feature_mixin.
Before
When using
stub_supports
,unsupported_reason(:supported_feature)
was not stubbed (and unpredictable)supports?(:all_features)
was stubbedAfter
We are stubbing at the feature definition layer
all code in
unsupported_reason
is run/tested (not stubbed)all code in
supports?
is run/tested (not stubbed)This puts more code under test and allows flexibility for refactoring
Notes
Wasn't thrilled about
stub_supports kwarg supports:
I've removed the tests that still use that, but keeping that parameter as-is so
this is more backport friendly.
This code better tests our features that defer to another feature
this is a little more finicky since it stubs supports for only the class specified. good: you can stub different classes with different values. bad: have to stub leaf classes