make tests work again

This commit is contained in:
wvengen 2013-06-25 13:04:55 +02:00
parent e450cf404e
commit 91c8be6b6c
6 changed files with 36 additions and 41 deletions

View file

@ -1,13 +1,13 @@
require File.dirname(__FILE__) + '/../test_helper'
class UserTest < Test::Unit::TestCase
class UserTest < ActiveSupport::TestCase
fixtures :users
def setup
@admin = users(:admin)
end
def test_read_user
test 'read_user' do
assert_kind_of User, @admin
assert_equal "Anton", @admin.first_name
assert_equal "Admininistrator", @admin.last_name
@ -15,20 +15,25 @@ class UserTest < Test::Unit::TestCase
assert @admin.role_admin?
end
def test_create_and_read_password
@admin.set_password({:required => true}, "secret", "secret")
test 'create_and_read_password' do
@admin.password = "some_secret"
@admin.password_confirmation = @admin.password
assert @admin.valid?
assert @admin.has_password("some_secret")
end
test 'invalid_password' do
@admin.password = "foo"
@admin.password_confirmation = @admin.password
assert @admin.invalid?
assert_equal [I18n.t('activemodel.errors.messages.too_short', count: 5)], @admin.errors[:password]
end
test 'password_not_match' do
@admin.password = "foobar"
@admin.password_confirmation = "foobor"
@admin.save
assert @admin.has_password("secret")
end
def test_invalid_password
@admin.set_password({:required => true}, "foo", "foo")
assert_equal 'Passwort muss zwischen 6 u. 25 Zeichen haben', @admin.errors.on_base
end
def test_password_not_match
@admin.set_password({:required => true}, "foobar", "foobor")
assert_equal 'Passworteingaben stimmen nicht überein', @admin.errors.on_base
assert_equal [I18n.t('activemodel.errors.messages.confirmation')], @admin.errors[:password]
end
end