Skip to content

Instantly share code, notes, and snippets.

@pjammer

pjammer/snippet.rb

Forked from anonymous/snippet.rb
Created Jan 30, 2010
Embed
What would you like to do?
require 'test_helper'
class AuthenticationTest < ActionController::IntegrationTest
def log_and_say(user, arg)
login_on_admin(user.username, user.password)
assert_content arg
end
test "Login on admin with valid username, password and role" do
user = Factory.build(:user_admin)
log_and_say(user, "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|
log_and_say(user, "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|
log_and_say( user, 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.