Class: UserTest
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- UserTest
show all
- Includes:
- Goldberg::TestHelper
- Defined in:
- lib/six-updater-web/vendor/plugins/goldberg/test/unit/user_test.rb
Instance Method Summary
collapse
#form_login, #form_logout, included, #login_user
Instance Method Details
6
7
8
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/user_test.rb', line 6
def setup
@role = Goldberg::Role.find :first
end
|
#test_check_password ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/user_test.rb', line 82
def test_check_password
first_pass = 'test'
new_pass = 'test1'
first_pass.freeze
new_pass.freeze
assert_not_equal(first_pass, new_pass)
user = Goldberg::User.new(:name => 'user')
user.role = @role
user.clear_password = first_pass
assert(user.save)
assert(user.check_password(first_pass))
assert(!user.check_password(new_pass))
user.clear_password = new_pass
assert(user.save)
assert(user.check_password(new_pass))
assert(!user.check_password(first_pass))
end
|
#test_clear_password_set_nil_on_save ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/user_test.rb', line 67
def test_clear_password_set_nil_on_save
new_pass = 'test123'
new_pass.freeze
user = Goldberg::User.new(:name => 'name')
user.role = @role
assert(!user.save)
user.clear_password = new_pass
assert_equal(new_pass, user.clear_password)
assert(user.save)
assert_nil(user.clear_password)
end
|
#test_name_unique ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/user_test.rb', line 18
def test_name_unique
name_1 = 'NAME1'
name_2 = 'NAME2'
name_1.freeze
name_2.freeze
user_1 = Goldberg::User.new(:name => name_1)
user_1.role = @role
user_1.clear_password = 'fred'
user_2 = Goldberg::User.new(:name => name_2)
user_2.role = @role
user_2.clear_password = 'fred'
assert(user_1.save)
assert(user_2.save)
user_2.name = name_1
assert(!user_2.save)
assert(!user_2.valid?)
assert(user_2.errors.invalid?(:name))
end
|
#test_password_updated_on_save_when_clear_password_set ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/user_test.rb', line 41
def test_password_updated_on_save_when_clear_password_set
user = Goldberg::User.new(:name => 'name')
user.role = @role
user.clear_password = 'fred'
assert(user.save)
saved_password = user.password
saved_salt = user.password_salt
user.clear_password = 'test123'
assert(user.save)
assert_not_equal(saved_password, user.password)
assert_not_equal(saved_salt, user.password_salt)
saved_password = user.password
saved_salt = user.password_salt
user.name = 'haha'
assert(user.name)
assert_equal(saved_password, user.password)
assert_equal(saved_salt, user.password_salt)
end
|
#test_requires_name ⇒ Object
10
11
12
13
14
15
|
# File 'lib/six-updater-web/vendor/plugins/goldberg/test/unit/user_test.rb', line 10
def test_requires_name
user = Goldberg::User.new
assert(!user.valid?)
assert(user.errors.invalid?(:name))
assert(!user.save)
end
|