O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Users and Roles

Now that we have Devise installed, let’s see how we can use testing to expose security issues.

The most basic security issue is user login. Since our application involves projects that would presumably be limited to a specific, private set of users, it makes sense that you would need to be logged in to access the application. This is testable logic—a logged-in user can access a page, whereas an ordinary browser who happens along the page cannot.

So here’s an integration test for the project index page:

security/01/gatherer/spec/features/user_and_role_spec.rb
Line 1 
require ​"rails_helper"
describe ​"with users and roles"​ ​do
def​ log_in_as(user)
visit new_user_session_path
fill_in(​"user_email"​, :with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required