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,8 +1,4 @@
# == Schema Information
<<<<<<< HEAD:test/fixtures/articles.yml
=======
# Schema version: 20090325175756
>>>>>>> wiki:test/fixtures/articles.yml
#
# Table name: articles
#

View file

@ -3,6 +3,7 @@ admins:
type: Workgroup
name: Administrators
description: System administrators.
created_on: <%= 5.weeks.ago.to_s(:db) %>
role_admin: true
role_suppliers: true
role_article_meta: true
@ -11,12 +12,8 @@ admins:
bananas:
type: Ordergroup
name: Banangroup
created_on: <%= 4.weeks.ago.to_s(:db) %>
account_balance: 100.00
account_updated: <%= 1.weeks.ago.to_s(:db) %>
contact_person: Tim
contact_phone: 030 123132456
contact_address: Waldermarstrasse 43, 10988 Berlin

View file

@ -1,8 +1,4 @@
# == Schema Information
<<<<<<< HEAD:test/fixtures/suppliers.yml
=======
# Schema version: 20090325175756
>>>>>>> wiki:test/fixtures/suppliers.yml
#
# Table name: suppliers
#
@ -38,12 +34,3 @@ terra:
Terra possibly delivers also on other days than tuesday. Don't
hesitate to ask for it.
min_order_quantity: 80,-€ (gross)

View file

@ -9,5 +9,15 @@ class ActiveSupport::TestCase
# -- they do not yet inherit this setting
fixtures :all
# Add more helper methods to be used by all tests here...
def login(nick='admin', pass='secret')
open_session do |session|
session.post '/f/login', nick: nick, password: pass
end
end
def logout
open_session do |session|
session.post '/f/logout'
end
end
end

View file

@ -1,18 +1,18 @@
require File.dirname(__FILE__) + '/../test_helper'
class SupplierTest < Test::Unit::TestCase
class SupplierTest < ActiveSupport::TestCase
fixtures :suppliers
def setup
@supplier = Supplier.find_by_name("Terra")
end
def test_read
test 'read' do
assert_equal "Terra", @supplier.name
assert_equal "www.terra-natur.de", @supplier.url
end
def test_update
test 'update' do
assert_equal "tuesday", @supplier.delivery_days
@supplier.delivery_days = 'wednesday'
assert @supplier.save, @supplier.errors.full_messages.join("; ")

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