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

remove most of test authentication stubbing #17575

Merged
merged 1 commit into from
Aug 2, 2018

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Jun 13, 2018

If we have fewer stubs, then we are testing more code and we are encouraged to pay attention to roles/miq_product_features and authorization.

I can see the argument that this makes it more or less stable.
So I'm putting it out there and seeing what others thing.

I just ran master classic-ui and all tests passed locally
@himdel - thoughts?

@kbrock kbrock added the test label Jun 13, 2018
@kbrock kbrock requested a review from himdel June 13, 2018 16:12
@kbrock kbrock changed the title remove most of stubbing remove most of test authentication stubbing Jun 13, 2018
User.current_user = user
puts "WARNING: double stubbing user - only use login_as or stub_user once" if user != User.current_user
Copy link
Member

Choose a reason for hiding this comment

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

STDERR.puts? or perhaps warn?

allow(controller).to receive(:current_user).and_return(user)
allow(User).to receive(:current_user).and_return(user)
# Stubs the user in context for a controller
# @param features (:all|:none|Array<>,String,Symbol) features for a user
Copy link
Member

Choose a reason for hiding this comment

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

when specific features are chosen, how are they passed...as Strings? I see Array of symbol, but I would have expected String identifiers.

That being said, there already is an "everything" product feature, so we should deprecate :all, and none can be handled by passing an empty Array, so we should probably deprecate :none as well. Then there are no "special" feature names, only real ones.

Copy link
Member Author

@kbrock kbrock Jun 13, 2018

Choose a reason for hiding this comment

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

thnx - array of strings or symbols work

Copy link
Member Author

Choose a reason for hiding this comment

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

a) I would like to s/all/everything in a future PR. it is in many repos.
b) :none seems to work very well. It creates all the joining models. The user ends up with feature(s), just features that aren't ones that affect us

@Fryguy
Copy link
Member

Fryguy commented Jun 13, 2018

This looks really nice. Much cleaner.

@himdel
Copy link
Contributor

himdel commented Jun 14, 2018

Agreed, looks great, thanks :)
Also, TIL :).

@kbrock kbrock force-pushed the authentication_helper_stubless branch from 72e4160 to 5b77924 Compare July 10, 2018 00:01
@miq-bot
Copy link
Member

miq-bot commented Jul 10, 2018

Some comments on commit kbrock@5b77924

spec/support/auth_helper.rb

  • ⚠️ - 10 - Detected puts. Remove all debugging statements.

@miq-bot
Copy link
Member

miq-bot commented Jul 10, 2018

Checked commit kbrock@5b77924 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. ⭐

@kbrock
Copy link
Member Author

kbrock commented Jul 10, 2018

@Fryguy / @himdel made that 1 change. Anything else?

Copy link
Contributor

@himdel himdel left a comment

Choose a reason for hiding this comment

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

LGTM, and doesn't break ui-classic travis 👍 :)

@bdunne bdunne merged commit e83fd17 into ManageIQ:master Aug 2, 2018
@bdunne bdunne added this to the Sprint 92 Ending Aug 13, 2018 milestone Aug 2, 2018
@bdunne bdunne self-assigned this Aug 2, 2018
@kbrock kbrock deleted the authentication_helper_stubless branch August 2, 2018 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants