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

New #stub_user controller macro #10243

Merged
merged 4 commits into from
Aug 4, 2016
Merged

Commits on Aug 4, 2016

  1. New #stub_user controller helper

    Replaces #set_user_privileges
    
    This consolidates the stubbing of users in controllers specs to a
    single, flexible, more controlled spot. It enables easier integration of
    forthcoming tenancy changes (multiple entitlements/roles)
    chrisarcand committed Aug 4, 2016
    Configuration menu
    Copy the full SHA
    5e91d1d View commit details
    Browse the repository at this point in the history
  2. Remove set_user_privileges ✂️

    With the addition of #stub_user, this [very janky, barely works] method
    can be removed.
    chrisarcand committed Aug 4, 2016
    Configuration menu
    Copy the full SHA
    1ac4516 View commit details
    Browse the repository at this point in the history
  3. Use a true stub for stub_user

    This changes stub_user to use a non-persisted user object and changes
    the :user_with_group factory to use a non-persisted group object. This
    increases test performance as stub_user is called over 1,000 times in
    controller specs, writing a user and group record to the database every
    time. Automation specs also make heavy use of :user_with_group, so each
    group write there is avoided.
    
    As expected, stubbing is more performant but loses a little bit of true
    parity with actual code testing. For example, because the user and group
    are empty objects and have no primary keys, code that utilizes IDs
    directly MUST use a real record. For that, one should use create an
    actual user/group and use 'login_as'. Given that I needed to change only
    a *single* spec because of this, it seems well worth it in 99% of cases
    (the spec I have changed here uses current_user.miq_groups.ids in a
    query for groups added to a report)
    
    In short, stub_user vs. login_as should be used as most people are told
    to use FactoryGirl's create vs. build - Use build as much as you can,
    but create if you really need to.
    chrisarcand committed Aug 4, 2016
    Configuration menu
    Copy the full SHA
    8ef1efe View commit details
    Browse the repository at this point in the history
  4. Set rubocop TargetRubyVersion to 2.2

    Avoids the 💣 💥 🔥 🚒
    chrisarcand authored and jrafanie committed Aug 4, 2016
    Configuration menu
    Copy the full SHA
    fbdabcf View commit details
    Browse the repository at this point in the history