rails/activerecord/test
Jason Meller 03855e790d 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.
2014-01-21 19:35:27 -05:00
..
active_record/connection_adapters Ensure disconnecting or reconnecting resets the transaction state 2012-09-15 00:03:04 +01:00
assets Added test to illustrate bad binary blobs. 2012-01-31 13:45:00 -06:00
cases Ensure AR #second, #third, etc. finders work through associations 2014-01-21 19:35:27 -05:00
fixtures Ensure AR #second, #third, etc. finders work through associations 2014-01-21 19:35:27 -05:00
migrations activerecord: Initialize Migration with version from MigrationProxy. 2014-01-06 10:46:35 -05:00
models Add more tests for the dirty feature for enums 2014-01-21 12:45:58 -02:00
schema Add more tests for the dirty feature for enums 2014-01-21 12:45:58 -02:00
support Deprecate use of string in establish_connection as connection lookup 2013-12-24 10:18:54 +01:00
.gitignore
config.example.yml Simulated & actual (manual/skipped) PostgreSQL auto-reconnection tests. 2012-07-16 09:55:20 -07:00
config.rb