aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb21
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb21
2 files changed, 10 insertions, 32 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb
index a710900054..8c7956406a 100644
--- a/activerecord/test/cases/associations/has_many_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_associations_test.rb
@@ -1170,7 +1170,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert !firm.errors.empty?
- assert_equal "Cannot delete record because dependent companies exist", firm.errors[:base].first
+ assert_equal "Cannot delete record because dependent company exists", firm.errors[:base].first
assert RestrictedFirm.exists?(:name => 'restrict')
assert firm.companies.exists?(:name => 'child')
ensure
@@ -1676,20 +1676,9 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
end
def test_building_has_many_association_with_restrict_dependency
- assert_deprecated do
- class_eval <<-EOF
- class RestrictedFirm < ActiveRecord::Base
- has_many :companies, :dependent => :restrict
- end
- EOF
- end
-
- assert_not_deprecated do
- class_eval <<-EOF
- class Firm < ActiveRecord::Base
- has_many :companies
- end
- EOF
- end
+ klass = Class.new(ActiveRecord::Base)
+
+ assert_deprecated { klass.has_many :companies, :dependent => :restrict }
+ assert_not_deprecated { klass.has_many :companies }
end
end
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index a17f33c8df..7c6736fb95 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -183,7 +183,7 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
firm.destroy
assert !firm.errors.empty?
- assert_equal "Cannot delete record because dependent account exist", firm.errors[:base].first
+ assert_equal "Cannot delete record because dependent account exists", firm.errors[:base].first
assert RestrictedFirm.exists?(:name => 'restrict')
assert firm.account.present?
ensure
@@ -484,20 +484,9 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
end
def test_building_has_one_association_with_dependent_restrict
- assert_deprecated do
- class_eval <<-EOF
- class RestrictedFirm < ActiveRecord::Base
- has_one :account, :dependent => :restrict
- end
- EOF
- end
-
- assert_not_deprecated do
- class_eval <<-EOF
- class Firm < ActiveRecord::Base
- has_one :account
- end
- EOF
- end
+ klass = Class.new(ActiveRecord::Base)
+
+ assert_deprecated { klass.has_one :account, :dependent => :restrict }
+ assert_not_deprecated { klass.has_one :account }
end
end