replace "User#before_create" and "User.login" shoulda contexts at unit user test
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10540 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b04f44f944
commit
df44af819c
@ -86,31 +86,25 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
assert user.save
|
assert user.save
|
||||||
end
|
end
|
||||||
|
|
||||||
context "User#before_create" do
|
def test_user_before_create_should_set_the_mail_notification_to_the_default_setting
|
||||||
should "set the mail_notification to the default Setting" do
|
@user1 = User.generate!
|
||||||
@user1 = User.generate!
|
assert_equal 'only_my_events', @user1.mail_notification
|
||||||
assert_equal 'only_my_events', @user1.mail_notification
|
with_settings :default_notification_option => 'all' do
|
||||||
|
@user2 = User.generate!
|
||||||
with_settings :default_notification_option => 'all' do
|
assert_equal 'all', @user2.mail_notification
|
||||||
@user2 = User.generate!
|
|
||||||
assert_equal 'all', @user2.mail_notification
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "User.login" do
|
def test_user_login_be_case_insensitive
|
||||||
should "be case-insensitive." do
|
u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
|
||||||
u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
|
u.login = 'newuser'
|
||||||
u.login = 'newuser'
|
u.password, u.password_confirmation = "password", "password"
|
||||||
u.password, u.password_confirmation = "password", "password"
|
assert u.save
|
||||||
assert u.save
|
u = User.new(:firstname => "Similar", :lastname => "User", :mail => "similaruser@somenet.foo")
|
||||||
|
u.login = 'NewUser'
|
||||||
u = User.new(:firstname => "Similar", :lastname => "User", :mail => "similaruser@somenet.foo")
|
u.password, u.password_confirmation = "password", "password"
|
||||||
u.login = 'NewUser'
|
assert !u.save
|
||||||
u.password, u.password_confirmation = "password", "password"
|
assert_include I18n.translate('activerecord.errors.messages.taken'), u.errors[:login]
|
||||||
assert !u.save
|
|
||||||
assert_include I18n.translate('activerecord.errors.messages.taken'), u.errors[:login]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_mail_uniqueness_should_not_be_case_sensitive
|
def test_mail_uniqueness_should_not_be_case_sensitive
|
||||||
|
Loading…
x
Reference in New Issue
Block a user