Use Devise helpers for authentication in specs

Description

The way we test authentication and user permissions in specs is not ideal:

  • We set up instance variables @current_user and @current_admin which exist only in tests. If we use them we're not actually testing anything.

  • We stub controller methods for getting logged in users/admins instead of letting them run.

  • The user factory creates unconfirmed/unactivated users by default, which means if we were actually logging in as such users with Devise in tests, it wouldn't work.

We are already including Devise helpers in our controller specs, we just need to use them.

Reference: https://github.com/heartcombo/devise/wiki/How-To:-Test-controllers-with-Rails-(and-RSpec)

How to test: none.

Assignee

redsummernight

Reporter

redsummernight

Roadmap

Login

Priority

Medium

Affects versions

Fix versions

None

Components

AutomatedTests

Difficulty

Medium

Milestone

Internal 0.9
Configure