1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Reapply extensions when using except and only

This commit is contained in:
Iain Hecker 2011-03-19 21:53:49 +01:00 committed by Aaron Patterson
parent 55bf087da1
commit 96b9fc4400
2 changed files with 14 additions and 0 deletions

View file

@ -79,6 +79,9 @@ module ActiveRecord
result.send(:"#{method}_value=", send(:"#{method}_value"))
end
# Apply scope extension modules
result.send(:apply_modules, extensions)
result
end
@ -100,6 +103,9 @@ module ActiveRecord
result.send(:"#{method}_value=", send(:"#{method}_value"))
end
# Apply scope extension modules
result.send(:apply_modules, extensions)
result
end

View file

@ -797,6 +797,10 @@ class RelationTest < ActiveRecord::TestCase
assert_equal Post.all, all_posts.all
end
def test_extensions_with_except
assert_equal 2, Topic.named_extension.order(:author_name).except(:order).two
end
def test_only
relation = Post.where(:author_id => 1).order('id ASC').limit(1)
assert_equal [posts(:welcome)], relation.all
@ -808,6 +812,10 @@ class RelationTest < ActiveRecord::TestCase
assert_equal Post.limit(1).all.first, all_posts.first
end
def test_extensions_with_only
assert_equal 2, Topic.named_extension.order(:author_name).only(:order).two
end
def test_anonymous_extension
relation = Post.where(:author_id => 1).order('id ASC').extending do
def author