Testing Registration and Signing into a Rails Application
Now that we have everything setup, let's test it out and see how we can sign up for an account on our application.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

Now that we have everything setup, let's test it out and see how we can sign up for an account on our application.

Start the rails server, go to the browser and type the URL localhost:3000/users/sign_up. We don't have a link to this page yet, and we'll add that later.

On this page, you can see the sign-up form.

medium

When you enter the details and click on the Sign up button, you are taken to the home page where you can see a message that says you are signed up successfully.

medium

To see how this looks in your console, type a query like User.last, and this should bring up the record.

large

You can also run other queries like User.count or User.last.email_id to get the information you want. One thing you won't be able to see here is the password. When I signed up I used a simple password, but the password stored in the database is long. This is because devise encrypts the password automatically for us to make it secure. Also, it automatically updates some fields like sign_in_count. To check if this value is getting updated correctly, go to the URL localhost:3000/users/sign_in and enter the same email ID and password to log in. This will also take you to the home page and will have a message that says your signed in successfully. So, signing up and signing in works fine.
Now, if you go back to your console and check the sign_in_count value with the command User.last.sign_in_count, you can see the value is 2.

large

This means our login module is good.