]> source.dussan.org Git - redmine.git/commitdiff
not use assert_not_nil in Errors#[]
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 30 Jul 2013 08:23:54 +0000 (08:23 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Tue, 30 Jul 2013 08:23:54 +0000 (08:23 +0000)
r7593 etc. replaced Rails2 Errors#on.
Rails3 Errors#[] always return array.
So, Rails3 Errors#[] is always not nil.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12070 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/functional/projects_controller_test.rb
test/unit/attachment_test.rb
test/unit/issue_nested_set_test.rb
test/unit/issue_relation_test.rb
test/unit/issue_test.rb
test/unit/user_test.rb

index 37010cc710d3e172f326f3e6a583696106eaf068..c8bd19c5e48ca974460af668ad026f4843c90da4 100644 (file)
@@ -209,7 +209,7 @@ class ProjectsControllerTest < ActionController::TestCase
     assert_response :success
     project = assigns(:project)
     assert_kind_of Project, project
-    assert_not_nil project.errors[:parent_id]
+    assert_not_equal [], project.errors[:parent_id]
   end
 
   test "#create by non-admin user with add_subprojects permission should create a project with a parent_id" do
@@ -244,7 +244,7 @@ class ProjectsControllerTest < ActionController::TestCase
     assert_response :success
     project = assigns(:project)
     assert_kind_of Project, project
-    assert_not_nil project.errors[:parent_id]
+    assert_not_equal [], project.errors[:parent_id]
   end
 
   test "#create by non-admin user with add_subprojects permission should fail with unauthorized parent_id" do
@@ -265,7 +265,7 @@ class ProjectsControllerTest < ActionController::TestCase
     assert_response :success
     project = assigns(:project)
     assert_kind_of Project, project
-    assert_not_nil project.errors[:parent_id]
+    assert_not_equal [], project.errors[:parent_id]
   end
 
   def test_create_subproject_with_inherit_members_should_inherit_members
index e32754b7d5e082f4e914b82ccc1f1e594083dc5a..b3608aef74310fdd3608b28087a185ace1e56485 100644 (file)
@@ -93,7 +93,7 @@ class AttachmentTest < ActiveSupport::TestCase
   def test_description_length_should_be_validated
     a = Attachment.new(:description => 'a' * 300)
     assert !a.save
-    assert_not_nil a.errors[:description]
+    assert_not_equal [], a.errors[:description]
   end
 
   def test_destroy
index c3120e82a495f5d806b882a0be1e0aa636830a98..0d83671e00df45507509c2a792e28576231d69af 100644 (file)
@@ -57,7 +57,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase
     child = Issue.new(:project_id => 2, :tracker_id => 1, :author_id => 1,
                       :subject => 'child', :parent_issue_id => issue.id)
     assert !child.save
-    assert_not_nil child.errors[:parent_issue_id]
+    assert_not_equal [], child.errors[:parent_issue_id]
   end
 
   def test_move_a_root_to_child
@@ -163,7 +163,7 @@ class IssueNestedSetTest < ActiveSupport::TestCase
     child.reload
     child.parent_issue_id = grandchild.id
     assert !child.save
-    assert_not_nil child.errors[:parent_issue_id]
+    assert_not_equal [], child.errors[:parent_issue_id]
   end
 
   def test_destroy_should_destroy_children
index 3bcf06bd50df7c0e4bfe4172b11593de84e7f205..6fc408353d1b1bbb2bfaf903155d8818df29b0f1 100644 (file)
@@ -115,7 +115,7 @@ class IssueRelationTest < ActiveSupport::TestCase
           :relation_type => IssueRelation::TYPE_PRECEDES
         )
     assert !r.save
-    assert_not_nil r.errors[:base]
+    assert_not_equal [], r.errors[:base]
   end
 
   def test_validates_circular_dependency_of_subtask
@@ -166,7 +166,7 @@ class IssueRelationTest < ActiveSupport::TestCase
           :relation_type => IssueRelation::TYPE_BLOCKED
         )
     assert !r.save
-    assert_not_nil r.errors[:base]
+    assert_not_equal [], r.errors[:base]
   end
 
   def test_create_should_make_journal_entry
index ef1a3fb030e458dab316519c78cec94d1bcf4a37..8f9f965cbeb3096b6a9e0f8b791e62fcc922de3f 100644 (file)
@@ -490,7 +490,7 @@ class IssueTest < ActiveSupport::TestCase
     issue.tracker_id = 2
     issue.subject = 'New subject'
     assert !issue.save
-    assert_not_nil issue.errors[:tracker_id]
+    assert_not_equal [], issue.errors[:tracker_id]
   end
 
   def test_category_based_assignment
@@ -1045,7 +1045,7 @@ class IssueTest < ActiveSupport::TestCase
                       :status_id => 1, :fixed_version_id => 1,
                       :subject => 'New issue')
     assert !issue.save
-    assert_not_nil issue.errors[:fixed_version_id]
+    assert_not_equal [], issue.errors[:fixed_version_id]
   end
 
   def test_should_not_be_able_to_assign_a_new_issue_to_a_locked_version
@@ -1053,7 +1053,7 @@ class IssueTest < ActiveSupport::TestCase
                       :status_id => 1, :fixed_version_id => 2,
                       :subject => 'New issue')
     assert !issue.save
-    assert_not_nil issue.errors[:fixed_version_id]
+    assert_not_equal [], issue.errors[:fixed_version_id]
   end
 
   def test_should_be_able_to_assign_a_new_issue_to_an_open_version
@@ -1074,7 +1074,7 @@ class IssueTest < ActiveSupport::TestCase
     issue = Issue.find(11)
     issue.status_id = 1
     assert !issue.save
-    assert_not_nil issue.errors[:base]
+    assert_not_equal [], issue.errors[:base]
   end
 
   def test_should_be_able_to_reopen_and_reassign_an_issue_assigned_to_a_closed_version
index 52a7d64b72a6694757f40cb84cdb843fa665da2a..f1da321aa4aa928e95d1a9dbda9be1c69c52965e 100644 (file)
@@ -401,7 +401,7 @@ class UserTest < ActiveSupport::TestCase
     u = User.new
     u.mail_notification = 'foo'
     u.save
-    assert_not_nil u.errors[:mail_notification]
+    assert_not_equal [], u.errors[:mail_notification]
   end
 
   def test_password