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:
Toshi MARUYAMA 2012-10-01 06:41:18 +00:00
parent b04f44f944
commit df44af819c
1 changed files with 16 additions and 22 deletions

View File

@ -86,31 +86,25 @@ class UserTest < ActiveSupport::TestCase
assert user.save
end
context "User#before_create" do
should "set the mail_notification to the default Setting" do
@user1 = User.generate!
assert_equal 'only_my_events', @user1.mail_notification
with_settings :default_notification_option => 'all' do
@user2 = User.generate!
assert_equal 'all', @user2.mail_notification
end
def test_user_before_create_should_set_the_mail_notification_to_the_default_setting
@user1 = User.generate!
assert_equal 'only_my_events', @user1.mail_notification
with_settings :default_notification_option => 'all' do
@user2 = User.generate!
assert_equal 'all', @user2.mail_notification
end
end
context "User.login" do
should "be case-insensitive." do
u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
u.login = 'newuser'
u.password, u.password_confirmation = "password", "password"
assert u.save
u = User.new(:firstname => "Similar", :lastname => "User", :mail => "similaruser@somenet.foo")
u.login = 'NewUser'
u.password, u.password_confirmation = "password", "password"
assert !u.save
assert_include I18n.translate('activerecord.errors.messages.taken'), u.errors[:login]
end
def test_user_login_be_case_insensitive
u = User.new(:firstname => "new", :lastname => "user", :mail => "newuser@somenet.foo")
u.login = 'newuser'
u.password, u.password_confirmation = "password", "password"
assert u.save
u = User.new(:firstname => "Similar", :lastname => "User", :mail => "similaruser@somenet.foo")
u.login = 'NewUser'
u.password, u.password_confirmation = "password", "password"
assert !u.save
assert_include I18n.translate('activerecord.errors.messages.taken'), u.errors[:login]
end
def test_mail_uniqueness_should_not_be_case_sensitive