2012-10-25 22:12:16 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class UserTest < ActiveSupport::TestCase
|
|
|
|
test 'user' do
|
|
|
|
tests = [
|
|
|
|
{
|
|
|
|
:create => {
|
|
|
|
:firstname => 'Firstname',
|
|
|
|
:lastname => 'Lastname',
|
|
|
|
:email => 'some@example.com',
|
|
|
|
:login => 'some@example.com',
|
|
|
|
:created_by_id => 1,
|
|
|
|
},
|
|
|
|
:create_verify => {
|
|
|
|
:firstname => 'Firstname',
|
|
|
|
:lastname => 'Lastname',
|
|
|
|
:email => 'some@example.com',
|
|
|
|
:login => 'some@example.com',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:create => {
|
|
|
|
:firstname => 'Firstname Lastname',
|
|
|
|
:lastname => '',
|
|
|
|
:email => 'some@example.com',
|
|
|
|
:login => 'some@example.com',
|
|
|
|
:created_by_id => 1,
|
|
|
|
},
|
|
|
|
:create_verify => {
|
|
|
|
:firstname => 'Firstname',
|
|
|
|
:lastname => 'Lastname',
|
|
|
|
:email => 'some@example.com',
|
|
|
|
:login => 'some@example.com',
|
|
|
|
},
|
|
|
|
},
|
2012-11-02 07:14:59 +00:00
|
|
|
{
|
|
|
|
:create => {
|
|
|
|
:firstname => 'Firstname Lastname',
|
|
|
|
:lastname => nil,
|
|
|
|
:email => 'some@example.com',
|
|
|
|
:login => 'some@example.com',
|
|
|
|
:created_by_id => 1,
|
|
|
|
},
|
|
|
|
:create_verify => {
|
|
|
|
:firstname => 'Firstname',
|
|
|
|
:lastname => 'Lastname',
|
|
|
|
:email => 'some@example.com',
|
|
|
|
:login => 'some@example.com',
|
|
|
|
},
|
|
|
|
},
|
2012-10-25 22:12:16 +00:00
|
|
|
{
|
|
|
|
:create => {
|
|
|
|
:firstname => 'Lastname, Firstname',
|
|
|
|
:lastname => '',
|
|
|
|
:email => 'some@example.com',
|
|
|
|
:login => 'some@example.com',
|
|
|
|
:created_by_id => 1,
|
|
|
|
},
|
|
|
|
:create_verify => {
|
|
|
|
:firstname => 'Firstname',
|
|
|
|
:lastname => 'Lastname',
|
|
|
|
:email => 'some@example.com',
|
|
|
|
:login => 'some@example.com',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:create => {
|
|
|
|
:firstname => '',
|
|
|
|
:lastname => '',
|
|
|
|
:email => 'firstname.lastname@example.com',
|
|
|
|
:login => 'login',
|
|
|
|
:created_by_id => 1,
|
|
|
|
},
|
|
|
|
:create_verify => {
|
|
|
|
:firstname => 'Firstname',
|
|
|
|
:lastname => 'Lastname',
|
|
|
|
:email => 'firstname.lastname@example.com',
|
|
|
|
:login => 'login',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
:create => {
|
|
|
|
:firstname => '',
|
|
|
|
:lastname => '',
|
|
|
|
:email => 'FIRSTNAME.lastname@example.com',
|
|
|
|
:login => 'login',
|
|
|
|
:created_by_id => 1,
|
|
|
|
},
|
|
|
|
:create_verify => {
|
|
|
|
:firstname => 'Firstname',
|
|
|
|
:lastname => 'Lastname',
|
|
|
|
:email => 'firstname.lastname@example.com',
|
|
|
|
:login => 'login',
|
|
|
|
},
|
|
|
|
},
|
2012-11-02 07:14:59 +00:00
|
|
|
{
|
|
|
|
:create => {
|
|
|
|
:firstname => nil,
|
|
|
|
:lastname => nil,
|
|
|
|
:email => 'FIRSTNAME.lastname@example.com',
|
|
|
|
:login => 'login',
|
|
|
|
:created_by_id => 1,
|
|
|
|
},
|
|
|
|
:create_verify => {
|
|
|
|
:firstname => 'Firstname',
|
|
|
|
:lastname => 'Lastname',
|
|
|
|
:email => 'firstname.lastname@example.com',
|
|
|
|
:login => 'login',
|
|
|
|
},
|
|
|
|
},
|
2012-10-25 22:12:16 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
tests.each { |test|
|
|
|
|
|
|
|
|
user = User.create( test[:create] )
|
|
|
|
|
|
|
|
test[:create_verify].each { |key, value|
|
|
|
|
assert_equal( user[key], value )
|
|
|
|
}
|
|
|
|
|
|
|
|
user.destroy
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|