diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-12-26 15:28:23 +0530 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-12-26 15:31:50 +0530 |
commit | 9a9f97af2815469e6f28dee9b88577251ef1b832 (patch) | |
tree | d6a581b91deba8b91ace9ff55d13a0fc6f1b618b /activerecord/test | |
parent | 3c5a7dcaf55f427f3a48e206feb06410d011ca4f (diff) | |
download | rails-9a9f97af2815469e6f28dee9b88577251ef1b832.tar.gz rails-9a9f97af2815469e6f28dee9b88577251ef1b832.tar.bz2 rails-9a9f97af2815469e6f28dee9b88577251ef1b832.zip |
Add relation.reload to force reloading the records
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 475090fbd8..2b3c6eec1d 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -55,6 +55,21 @@ class RelationTest < ActiveRecord::TestCase assert topics.loaded? end + def test_reload + topics = Topic.scoped + + assert_queries(1) do + 2.times { topics.to_a } + end + + assert topics.loaded? + + topics.reload + assert ! topics.loaded? + + assert_queries(1) { topics.to_a } + end + def test_finding_with_conditions assert_equal ["David"], Author.where(:name => 'David').map(&:name) assert_equal ['Mary'], Author.where(["name = ?", 'Mary']).map(&:name) |