diff test/unit/user_test.rb @ 119:8661b858af72

* Update to Redmine trunk rev 4705
author Chris Cannam
date Thu, 13 Jan 2011 14:12:06 +0000
parents 94944d00e43c
children 07fa8a8b56a8
line wrap: on
line diff
--- a/test/unit/user_test.rb	Fri Nov 19 14:05:24 2010 +0000
+++ b/test/unit/user_test.rb	Thu Jan 13 14:12:06 2011 +0000
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
-require File.dirname(__FILE__) + '/../test_helper'
+require File.expand_path('../../test_helper', __FILE__)
 
 class UserTest < ActiveSupport::TestCase
   fixtures :users, :members, :projects, :roles, :member_roles, :auth_sources
@@ -115,12 +115,19 @@
     assert Member.find_all_by_user_id(2).empty?
   end
   
-  def test_validate
+  def test_validate_login_presence
     @admin.login = ""
     assert !@admin.save
     assert_equal 1, @admin.errors.count
   end
   
+  def test_validate_mail_notification_inclusion
+    u = User.new
+    u.mail_notification = 'foo'
+    u.save
+    assert_not_nil u.errors.on(:mail_notification)
+  end
+  
   context "User#try_to_login" do
     should "fall-back to case-insensitive if user login is not found as-typed." do
       user = User.try_to_login("AdMin", "admin")
@@ -437,55 +444,49 @@
       end
 
       should "be true for a user with :all" do
-        @author.update_attribute(:mail_notification, :all)
+        @author.update_attribute(:mail_notification, 'all')
         assert @author.notify_about?(@issue)
       end
       
       should "be false for a user with :none" do
-        @author.update_attribute(:mail_notification, :none)
+        @author.update_attribute(:mail_notification, 'none')
         assert ! @author.notify_about?(@issue)
       end
       
       should "be false for a user with :only_my_events and isn't an author, creator, or assignee" do
-        @user = User.generate_with_protected!(:mail_notification => :only_my_events)
+        @user = User.generate_with_protected!(:mail_notification => 'only_my_events')
         assert ! @user.notify_about?(@issue)
       end
       
       should "be true for a user with :only_my_events and is the author" do
-        @author.update_attribute(:mail_notification, :only_my_events)
+        @author.update_attribute(:mail_notification, 'only_my_events')
         assert @author.notify_about?(@issue)
       end
       
       should "be true for a user with :only_my_events and is the assignee" do
-        @assignee.update_attribute(:mail_notification, :only_my_events)
+        @assignee.update_attribute(:mail_notification, 'only_my_events')
         assert @assignee.notify_about?(@issue)
       end
       
       should "be true for a user with :only_assigned and is the assignee" do
-        @assignee.update_attribute(:mail_notification, :only_assigned)
+        @assignee.update_attribute(:mail_notification, 'only_assigned')
         assert @assignee.notify_about?(@issue)
       end
       
       should "be false for a user with :only_assigned and is not the assignee" do
-        @author.update_attribute(:mail_notification, :only_assigned)
+        @author.update_attribute(:mail_notification, 'only_assigned')
         assert ! @author.notify_about?(@issue)
       end
       
       should "be true for a user with :only_owner and is the author" do
-        @author.update_attribute(:mail_notification, :only_owner)
+        @author.update_attribute(:mail_notification, 'only_owner')
         assert @author.notify_about?(@issue)
       end
       
       should "be false for a user with :only_owner and is not the author" do
-        @assignee.update_attribute(:mail_notification, :only_owner)
+        @assignee.update_attribute(:mail_notification, 'only_owner')
         assert ! @assignee.notify_about?(@issue)
       end
-      
-      should "be false if the mail_notification is anything else" do
-        @assignee.update_attribute(:mail_notification, :somthing_else)
-        assert ! @assignee.notify_about?(@issue)
-      end
-      
     end
 
     context "other events" do