@StatelessCode
  @StatelessCode
Stateless Code | Create Pre and Post Sign-In Pages to Test Devise @StatelessCode | Uploaded October 2022 | Updated October 2024, 1 hour ago.
In order to test that Devise is working properly in our Rails 7 application, we need pages to navigate to. Specifically, we need a page that requires user authentication and one that doesn't. We also need to define our root route in order for Devise to work properly.

These are the scenarios we need to be able to test:

- A non-logged in user can access our public page, but not our authentication-required page
- A logged in user can access the public page and the authentication-required page
- The public page should be aware of whether a user is logged in and provide appropriate actions. (Sign up and log in if not logged in; visit the members' page and log out if logged in.)

As we create these pages with their controllers and views, we follow a test-driven approach. We write a failing test and then implement the code to make it pass. After the test is passing we can refactor our code to try to make it more elegant or break large methods down into smaller ones.

This video covers:
00:00:12 Introduction
00:01:34 Generate WelcomeController that does not require authentication
00:02:53 Configure routes and set welcome#index as root route and look at other devise routes
00:07:14 Look at view file and fix path in controller test
00:08:24 Write failing WelcomeController tests for logged in and non-logged-in users
00:11:16 Implement view changes to make WelcomeController tests pass and troubleshoot test problems
00:22:19 Generate AuthenticatedController to test logged in behavior and no access for logged out user
00:26:01 Failing test for Authenticated Controller
00:27:09 Demonstrate authentication behavior in browser and get tests to pass
00:30:25 Try to include the Devise::Test::IntegrationHelpers in ActionDispatch::IntegrationTest. Not working. Revert.
00:35:26 Commit and push code, close subtask

#ruby #rails7 #rails #rubyonrails #rubygems #codecast #screencast #github #opensource #minitest #TDD #agile #NerdDice #DnD #roleplaying #softwaredevelopment #learntocode #tailwind #postgresql #rubocop #devise #turbo #controllers #routes

See other related StatelessCode videos:
- Getting Started with Rails 7: Setup Git and Create the First Controller youtu.be/Rs_O58vLytA

This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE. Stateless Code denies the concept of "intellectual property". Copying is not stealing.
Create Pre and Post Sign-In Pages to Test DeviseInstall VirtualBox 7 on Ubuntu, Windows, and Intel MacCodecast: Getting Started with Rails 7 27: Add a Stimulus Controller for Client-Side InteractionCodecast: Create a RubyGem 79: Refactor ConvenienceMethods - Part 1Codecast: Create a RubyGem 87: Downtime Hodgepodge and a ContributorCodecast: Getting Started with Rails 7 20: Basic Auth Part 2 and Finish the GuideMediocre Karaoke - Dont Stop Me Now by QueenMandatory is PoisonUpdate Bundle to Clear Dependabot Alerts and Troubleshoot Build Dependency FailuresCodecast: Create a RubyGem 73: Add Multiple Dice to Highest and LowestAdapt a Usability Interview Script for the Project and Fix Broken Wiki LinksInstall an Android Emulator on Ubuntu 22.04

Create Pre and Post Sign-In Pages to Test Devise @StatelessCode

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER