Skip to content

Commit

Permalink
loaded should be aliased to loaded? in collection proxy
Browse files Browse the repository at this point in the history
Fixes #39088.
  • Loading branch information
kamipo committed May 20, 2020
1 parent 9366f52 commit 39de115
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def load_target
def loaded?
@association.loaded?
end
alias :loaded :loaded?

##
# :method: select
Expand Down
2 changes: 2 additions & 0 deletions activerecord/test/cases/associations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,10 @@ def test_reset_unloads_target
david.posts.reload

assert_predicate david.posts, :loaded?
assert_predicate david.posts, :loaded
david.posts.reset
assert_not_predicate david.posts, :loaded?
assert_not_predicate david.posts, :loaded
end
end

Expand Down
4 changes: 4 additions & 0 deletions activerecord/test/cases/relations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ def test_scoped_all
def test_loaded_all
topics = Topic.all

assert_not_predicate topics, :loaded?
assert_not_predicate topics, :loaded

assert_queries(1) do
2.times { assert_equal 5, topics.to_a.size }
end

assert_predicate topics, :loaded?
assert_predicate topics, :loaded
end

def test_scoped_first
Expand Down

0 comments on commit 39de115

Please sign in to comment.