From fb6b80562041e8d2378cad1b51f8c234fe76fd5e Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Tue, 17 Aug 2010 03:29:57 +0200 Subject: code gardening: we have assert_(nil|blank|present), more concise, with better default failure messages - let's use them --- activerecord/test/cases/associations/belongs_to_associations_test.rb | 2 +- activerecord/test/cases/associations/has_many_associations_test.rb | 4 ++-- activerecord/test/cases/associations/has_one_associations_test.rb | 2 +- activerecord/test/cases/associations/join_model_test.rb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'activerecord/test/cases/associations') diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index a1ce9b1689..28234ebe49 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -22,7 +22,7 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase def test_belongs_to Client.find(3).firm.name assert_equal companies(:first_firm).name, Client.find(3).firm.name - assert !Client.find(3).firm.nil?, "Microsoft should have a firm" + assert_not_nil Client.find(3).firm, "Microsoft should have a firm" end def test_belongs_to_with_primary_key diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index ac2021c369..7e10a8ceeb 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -633,7 +633,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase # Should not be destroyed since the association is not dependent. assert_nothing_raised do - assert Client.find(client_id).firm.nil? + assert_nil Client.find(client_id).firm end end @@ -658,7 +658,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal [client_id], Client.destroyed_client_ids[firm.id] # Should be destroyed since the association is dependent. - assert Client.find_by_id(client_id).nil? + assert_nil Client.find_by_id(client_id) end def test_clearing_an_exclusively_dependent_association_collection diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb index 469a21b9bf..e959ed46cc 100644 --- a/activerecord/test/cases/associations/has_one_associations_test.rb +++ b/activerecord/test/cases/associations/has_one_associations_test.rb @@ -253,7 +253,7 @@ class HasOneAssociationsTest < ActiveRecord::TestCase def test_dependence_with_missing_association_and_nullify Account.destroy_all firm = DependentFirm.find(:first) - assert firm.account.nil? + assert_nil firm.account firm.destroy end diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb index fcdb81e92e..b83966e91c 100644 --- a/activerecord/test/cases/associations/join_model_test.rb +++ b/activerecord/test/cases/associations/join_model_test.rb @@ -427,8 +427,8 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase def test_has_many_through_uses_conditions_specified_on_the_has_many_association author = Author.find(:first) - assert !author.comments.blank? - assert author.nonexistant_comments.blank? + assert_present author.comments + assert_blank author.nonexistant_comments end def test_has_many_through_uses_correct_attributes -- cgit v1.2.3