with_scope doesn't support :order in the presence of :include. For example:
{{{
# We're testing the interaction between :order, :include, and
with_scope.
TEST_ORDER = 'tickets.created_at DESC'
TEST_INCLUDE = ['owner']
def test_find(opts1, opts2)
Ticket.with_scope(:find => opts1) do
Ticket.find(:all, opts2).map {|t| t.id }
end
end
# In these examples, :order is respected.
test_find({ :order => TEST_ORDER }, {})
test_find({}, { :include => TEST_INCLUDE, :order => TEST_ORDER })
test_find({ :include => TEST_INCLUDE }, { :order => TEST_ORDER })
# In these examples, :order is ignored.
test_find({ :include => TEST_INCLUDE, :order => TEST_ORDER }, {})
test_find({ :order => TEST_ORDER }, { :include => TEST_INCLUDE })
}}}
There's some code duplication between
construct_finder_sql_with_included_associations and the usual
construct_finder_sql, and changeset r4274 for ticket #3887 only
modified one copy of the duplicate code.
with_scope_order_include.diff
Description: Binary data
_______________________________________________ Rails-core mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-core
