#125 Test Devise authentication with Controller and System tests
17/04/2023
Free
When setting up a new Rails app with Devise, you should set up your test suite to work with authentication and write controller (integration) and system tests for the authentication flow.
Here’s a reusable approach to setting up your test suite for the long run!
Episode source code: https://github.com/corsego/125-test-devise-authentication/commits/main
Based on this blogpost: https://blog.corsego.com/minitest-faker-factory-bot-devise
0:00 tests in generated controllers
1:34 update routes and make tests work
3:49 install devise
6:15 fix duplicate index users on email in fixtures
7:03 test unauthenticated access
9:15 devise login in tests
10:48 system (browser) tests
19:43 run system tests without browser popup
20:20 test, test:system, test:all
0
Sign in to join the conversation
Recommended based on what you are watching now
![#40 Devise Trackable, Users Index page](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTg4OCwicHVyIjoiYmxvYl9pZCJ9fQ==--b75191503a8d30fc413cb4bb6ef083b8f8535573/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)
06:07
#40 Devise Trackable, Users Index page
21/06/2021
Free
![#41 Devise Confirmable - no more users with fake emails!](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTc2MywicHVyIjoiYmxvYl9pZCJ9fQ==--c1571d092dac0178f17f208a36ea68acea884f9d/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)
12:51
#41 Devise Confirmable - no more users with fake emails!
23/06/2021
Free
![#42 Devise Lockable. Ban or Unban users as you please.](https://superails.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTgwMCwicHVyIjoiYmxvYl9pZCJ9fQ==--167c1abb2e961584dc4257d11d5b99ec43d2b9a1/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGciLCJyZXNpemVfdG9fbGltaXQiOls0MDAsNjAwXX0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--2d7cd3a4d9675c7f4c17dad7856d799792bd3595/maxresdefault.jpg)
13:03
#42 Devise Lockable. Ban or Unban users as you please.
25/06/2021
Free