Add test case for arel_attribute
with a custom table
Since #29301, `arel_attribute` respects a custom table name.
This commit is contained in:
parent
48ef5e0ad5
commit
801ccab22a
@ -1806,6 +1806,10 @@ def test_presence
|
||||
assert_equal post, custom_post_relation.joins(:author).where!(title: post.title).take
|
||||
end
|
||||
|
||||
test "arel_attribute respects a custom table" do
|
||||
assert_equal [posts(:welcome)], custom_post_relation.ranked_by_comments.limit_by(1).to_a
|
||||
end
|
||||
|
||||
test "#load" do
|
||||
relation = Post.all
|
||||
assert_queries(1) do
|
||||
|
@ -21,7 +21,7 @@ def greeting
|
||||
|
||||
scope :containing_the_letter_a, -> { where("body LIKE '%a%'") }
|
||||
scope :titled_with_an_apostrophe, -> { where("title LIKE '%''%'") }
|
||||
scope :ranked_by_comments, -> { order("comments_count DESC") }
|
||||
scope :ranked_by_comments, -> { order(arel_attribute(:comments_count).desc) }
|
||||
|
||||
scope :limit_by, lambda { |l| limit(l) }
|
||||
scope :locked, -> { lock }
|
||||
|
Loading…
Reference in New Issue
Block a user