aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-08-17 03:29:57 +0200
committerXavier Noria <fxn@hashref.com>2010-08-17 03:32:11 +0200
commitfb6b80562041e8d2378cad1b51f8c234fe76fd5e (patch)
treee407af937ad119b1a5a6c977b13319f24994cde2 /activerecord/test/cases
parentd14e2987b583a3dcb6836d310f77ce367c7396f8 (diff)
downloadrails-fb6b80562041e8d2378cad1b51f8c234fe76fd5e.tar.gz
rails-fb6b80562041e8d2378cad1b51f8c234fe76fd5e.tar.bz2
rails-fb6b80562041e8d2378cad1b51f8c234fe76fd5e.zip
code gardening: we have assert_(nil|blank|present), more concise, with better default failure messages - let's use them
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/aggregations_test.rb2
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb2
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb4
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb2
-rw-r--r--activerecord/test/cases/associations/join_model_test.rb4
-rw-r--r--activerecord/test/cases/method_scoping_test.rb2
-rw-r--r--activerecord/test/cases/named_scope_test.rb4
-rw-r--r--activerecord/test/cases/primary_keys_test.rb2
-rw-r--r--activerecord/test/cases/relation_scoping_test.rb2
-rw-r--r--activerecord/test/cases/relations_test.rb4
10 files changed, 14 insertions, 14 deletions
diff --git a/activerecord/test/cases/aggregations_test.rb b/activerecord/test/cases/aggregations_test.rb
index 9e285e57dc..3e0e6dce2c 100644
--- a/activerecord/test/cases/aggregations_test.rb
+++ b/activerecord/test/cases/aggregations_test.rb
@@ -99,7 +99,7 @@ class AggregationsTest < ActiveRecord::TestCase
customers(:zaphod).save
customers(:zaphod).reload
assert_kind_of Address, customers(:zaphod).address
- assert customers(:zaphod).address.street.nil?
+ assert_nil customers(:zaphod).address.street
end
def test_nil_assignment_results_in_nil
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
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb
index 5256ab8d11..312628a3e3 100644
--- a/activerecord/test/cases/method_scoping_test.rb
+++ b/activerecord/test/cases/method_scoping_test.rb
@@ -449,7 +449,7 @@ class NestedScopingTest < ActiveRecord::TestCase
Comment.send(:with_scope, :create => { :body => "Hey guys, nested scopes are broken. Please fix!" }) do
Comment.send(:with_exclusive_scope, :create => { :post_id => 1 }) do
assert_equal({:post_id => 1}, Comment.scoped.send(:scope_for_create))
- assert Comment.new.body.blank?
+ assert_blank Comment.new.body
comment = Comment.create :body => "Hey guys"
end
end
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index c42dda2ccb..3d6975d0b5 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -480,8 +480,8 @@ class DynamicScopeTest < ActiveRecord::TestCase
end
def test_dynamic_scope_should_create_methods_after_hitting_method_missing
- assert Developer.methods.grep(/scoped_by_created_at/).blank?
+ assert_blank Developer.methods.grep(/scoped_by_created_at/)
Developer.scoped_by_created_at(nil)
- assert Developer.methods.grep(/scoped_by_created_at/).present?
+ assert_present Developer.methods.grep(/scoped_by_created_at/)
end
end
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index 1e44237e0a..63d8c7d1c1 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -11,7 +11,7 @@ class PrimaryKeysTest < ActiveRecord::TestCase
def test_to_key_with_default_primary_key
topic = Topic.new
- assert topic.to_key.nil?
+ assert_nil topic.to_key
topic = Topic.find(1)
assert_equal [1], topic.to_key
end
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 9494990b04..d56e5a7999 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -209,7 +209,7 @@ class NestedRelationScopingTest < ActiveRecord::TestCase
def test_nested_exclusive_scope_for_create
comment = Comment.create_with(:body => "Hey guys, nested scopes are broken. Please fix!").scoping do
Comment.unscoped.create_with(:post_id => 1).scoping do
- assert Comment.new.body.blank?
+ assert_blank Comment.new.body
Comment.create :body => "Hey guys"
end
end
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index bd6e216c62..aa75aa27d4 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -411,7 +411,7 @@ class RelationTest < ActiveRecord::TestCase
def test_find_in_empty_array
authors = Author.scoped.where(:id => [])
- assert authors.all.blank?
+ assert_blank authors.all
end
def test_exists
@@ -486,7 +486,7 @@ class RelationTest < ActiveRecord::TestCase
def test_relation_merging_with_locks
devs = Developer.lock.where("salary >= 80000").order("id DESC") & Developer.limit(2)
- assert devs.locked.present?
+ assert_present devs.locked
end
def test_relation_merging_with_preload