mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Make Relation#reload force load the records immediately
This commit is contained in:
@@ -124,12 +124,13 @@ module ActiveRecord
|
||||
end
|
||||
|
||||
def reload
|
||||
@loaded = false
|
||||
reset
|
||||
to_a # force reload
|
||||
self
|
||||
end
|
||||
|
||||
def reset
|
||||
@first = @last = @to_sql = @order_clause = @scope_for_create = @arel = nil
|
||||
@first = @last = @to_sql = @order_clause = @scope_for_create = @arel = @loaded = nil
|
||||
@records = []
|
||||
self
|
||||
end
|
||||
|
||||
@@ -68,10 +68,12 @@ class RelationTest < ActiveRecord::TestCase
|
||||
|
||||
assert topics.loaded?
|
||||
|
||||
topics.reload
|
||||
assert ! topics.loaded?
|
||||
original_size = topics.to_a.size
|
||||
Topic.create! :title => 'fake'
|
||||
|
||||
assert_queries(1) { topics.to_a }
|
||||
assert_queries(1) { topics.reload }
|
||||
assert_equal original_size + 1, topics.size
|
||||
assert topics.loaded?
|
||||
end
|
||||
|
||||
def test_finding_with_conditions
|
||||
|
||||
Reference in New Issue
Block a user