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

Fix supports_helper stub_supports to handle unsupported_reason #22976

Merged
merged 1 commit into from
Apr 24, 2024

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Apr 5, 2024

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 stubbed

After

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

@kbrock
Copy link
Member Author

kbrock commented Apr 5, 2024

@miq-bot cross-repo-test /all

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Apr 5, 2024
@kbrock kbrock mentioned this pull request Apr 5, 2024
17 tasks
@kbrock kbrock force-pushed the supports_unsupports_before branch from b22c2af to 517f3a6 Compare April 5, 2024 02:11
@kbrock kbrock changed the title Fix supports_helper stub_supports to handle unsupported_reason [WIP] Fix supports_helper stub_supports to handle unsupported_reason Apr 5, 2024
@kbrock kbrock added the wip label Apr 5, 2024
@kbrock kbrock force-pushed the supports_unsupports_before branch from 517f3a6 to bc0151b Compare April 5, 2024 02:47
@kbrock
Copy link
Member Author

kbrock commented Apr 5, 2024

update:

  • cops

WIP:

  • put in 2 fixes for cross repo test fixes (the fixes work with and without this PR)
  • unsure about ui-classic failure
  • assume serviceui will always fail
  • no longer feel this should go back to 2.5.1 (thinking 2.5.2)

allow_any_instance_of(model).to receive(:supports?).and_call_original
allow(model.supports_features).to receive(:[]).and_call_original
Copy link
Member

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
@kbrock kbrock force-pushed the supports_unsupports_before branch from bc0151b to 235eed6 Compare April 5, 2024 18:01
@miq-bot
Copy link
Member

miq-bot commented Apr 5, 2024

Checked commit kbrock@235eed6 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint
4 files checked, 0 offenses detected
Everything looks fine. 🍪

@kbrock
Copy link
Member Author

kbrock commented Apr 5, 2024

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.

specs ran ui-classic successfully locally for me

@kbrock kbrock removed the wip label Apr 5, 2024
@kbrock kbrock changed the title [WIP] Fix supports_helper stub_supports to handle unsupported_reason Fix supports_helper stub_supports to handle unsupported_reason Apr 5, 2024
@kbrock
Copy link
Member Author

kbrock commented Apr 5, 2024

@miq-bot cross-repo-test manageiq-ui-classic

trying just to run ui-classic

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Apr 5, 2024
@kbrock
Copy link
Member Author

kbrock commented Apr 18, 2024

@Fryguy Can we merge?

@agrare agrare self-assigned this Apr 24, 2024
@agrare agrare merged commit f0db4fb into ManageIQ:master Apr 24, 2024
8 checks passed
@Fryguy
Copy link
Member

Fryguy commented May 23, 2024

This PR has been effectively backported to radjabov via the merge of master into radjabov.

@kbrock kbrock deleted the supports_unsupports_before branch May 23, 2024 18:09
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.

4 participants