diff options
author | Jason Meller <jason.meller@mandiant.com> | 2014-01-21 17:34:39 -0500 |
---|---|---|
committer | Jason Meller <jason.meller@mandiant.com> | 2014-01-21 19:35:27 -0500 |
commit | 03855e790de2224519f55382e3c32118be31eeff (patch) | |
tree | 66e881ca9c3d960058edaea67d1bbbc5d60b3d92 /activerecord/test/cases/inheritance_test.rb | |
parent | 9383de42a2cf23cc53052cec2f736864c1c562a1 (diff) | |
download | rails-03855e790de2224519f55382e3c32118be31eeff.tar.gz rails-03855e790de2224519f55382e3c32118be31eeff.tar.bz2 rails-03855e790de2224519f55382e3c32118be31eeff.zip |
Ensure AR #second, #third, etc. finders work through associations
This commit fixes two regressions introduced in cafe31a078 where
newly created finder methods #second, #third, #forth, and #fifth
caused a NoMethodError error on reload associations and where we
were pulling the wrong element out of cached associations.
Examples:
some_book.authors.reload.second
# Before
# => NoMethodError: undefined method 'first' for nil:NilClass
# After
# => #<Author id: 2, name: "Sally Second", ...>
some_book.first.authors.first
some_book.first.authors.second
# Before
# => #<Author id: 1, name: "Freddy First", ...>
# => #<Author id: 1, name: "Freddy First", ...>
# After
# => #<Author id: 1, name: "Freddy First", ...>
# => #<Author id: 2, name: "Sally Second", ...>
Fixes #13783.
Diffstat (limited to 'activerecord/test/cases/inheritance_test.rb')
-rw-r--r-- | activerecord/test/cases/inheritance_test.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb index d2b5a06b55..e2ff2aa451 100644 --- a/activerecord/test/cases/inheritance_test.rb +++ b/activerecord/test/cases/inheritance_test.rb @@ -222,9 +222,9 @@ class InheritanceTest < ActiveRecord::TestCase end def test_inheritance_condition - assert_equal 10, Company.count + assert_equal 11, Company.count assert_equal 2, Firm.count - assert_equal 4, Client.count + assert_equal 5, Client.count end def test_alt_inheritance_condition |