Skip to content

Instantly share code, notes, and snippets.

/snippet.rb

Created Jan 30, 2010
Embed
What would you like to do?
require 'test_helper'
class AuthenticationTest < ActionController::IntegrationTest
test "Login on admin with valid username, password and role" do
user = Factory.build(:user_admin)
login_on_admin(user.username, user.password)
assert_content "Welcome #{user.username}, logged in as #{user.role}"
end
test "Login on admin with invalid role" do
users = [Factory.build(:user_guest), Factory.build(:user_user)]
users.each do |user|
login_on_admin(user.username, user.password)
assert_content "Invalid Login or Password"
end
end
test "Login on admin with invalid username and password" do
users = [Factory.build(:user_admin), Factory.build(:user_user), Factory.build(:user_guest)]
users.each do |user|
login_on_admin(user.username, "Fantastic and Wrong")
assert_content "Invalid Login or Password"
end
end
test "guest users should exist" do
user = Factory.build(:user_guest)
assert_equal("guest", user.role)
end
test "Should be logged as guest on request" do
login_as_guest
assert_equal("guest", @user.role)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.