Skip to content

Instantly share code, notes, and snippets.

Created January 30, 2010 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/290555 to your computer and use it in GitHub Desktop.
Save anonymous/290555 to your computer and use it in GitHub Desktop.
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