aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/deprecated_associations_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/deprecated_associations_test.rb')
-rwxr-xr-xactiverecord/test/deprecated_associations_test.rb26
1 files changed, 16 insertions, 10 deletions
diff --git a/activerecord/test/deprecated_associations_test.rb b/activerecord/test/deprecated_associations_test.rb
index 419e1d6e2f..ed1d3c4055 100755
--- a/activerecord/test/deprecated_associations_test.rb
+++ b/activerecord/test/deprecated_associations_test.rb
@@ -286,9 +286,11 @@ class DeprecatedAssociationsTest < Test::Unit::TestCase
natural = Client.create("name" => "Natural Company")
apple.clients << natural
assert_equal apple.id, natural.firm_id
- assert_equal Client.find(natural.id), Firm.find(apple.id).clients.find { |c| c.id == natural.id }
+ assert_equal Client.find(natural.id), Firm.find(apple.id).clients.find(natural.id)
apple.clients.delete natural
- assert_nil Firm.find(apple.id).clients.find { |c| c.id == natural.id }
+ assert_raises(ActiveRecord::RecordNotFound) {
+ Firm.find(apple.id).clients.find(natural.id)
+ }
end
def test_natural_adding_of_has_and_belongs_to_many
@@ -299,17 +301,21 @@ class DeprecatedAssociationsTest < Test::Unit::TestCase
rails.developers << john
rails.developers << mike
- assert_equal Developer.find(john.id), Project.find(rails.id).developers.find { |d| d.id == john.id }
- assert_equal Developer.find(mike.id), Project.find(rails.id).developers.find { |d| d.id == mike.id }
- assert_equal Project.find(rails.id), Developer.find(mike.id).projects.find { |p| p.id == rails.id }
- assert_equal Project.find(rails.id), Developer.find(john.id).projects.find { |p| p.id == rails.id }
+ assert_equal Developer.find(john.id), Project.find(rails.id).developers.find(john.id)
+ assert_equal Developer.find(mike.id), Project.find(rails.id).developers.find(mike.id)
+ assert_equal Project.find(rails.id), Developer.find(mike.id).projects.find(rails.id)
+ assert_equal Project.find(rails.id), Developer.find(john.id).projects.find(rails.id)
ap.developers << john
- assert_equal Developer.find(john.id), Project.find(ap.id).developers.find { |d| d.id == john.id }
- assert_equal Project.find(ap.id), Developer.find(john.id).projects.find { |p| p.id == ap.id }
+ assert_equal Developer.find(john.id), Project.find(ap.id).developers.find(john.id)
+ assert_equal Project.find(ap.id), Developer.find(john.id).projects.find(ap.id)
ap.developers.delete john
- assert_nil Project.find(ap.id).developers.find { |d| d.id == john.id }
- assert_nil Developer.find(john.id).projects.find { |p| p.id == ap.id }
+ assert_raises(ActiveRecord::RecordNotFound) {
+ Project.find(ap.id).developers.find(john.id)
+ }
+ assert_raises(ActiveRecord::RecordNotFound) {
+ Developer.find(john.id).projects.find(ap.id)
+ }
end
def test_storing_in_pstore