diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb index b24877e..a8c4626 100644 --- a/activerecord/test/cases/named_scope_test.rb +++ b/activerecord/test/cases/named_scope_test.rb @@ -219,4 +219,11 @@ class NamedScopeTest < ActiveRecord::TestCase topics = Topic.base.sort_by { |t| [t.author_name, t.content] } assert_equal Topic.base.order_by_content.order_by_author_name, topics end + + def test_ordered_association_with_named_scopes_should_do_ordering + comments = authors(:david).comments + assert_equal authors(:david).comments_desc, comments.sort_by {|c| -c.id } + assert_equal authors(:david).comments_desc.order_by_body, comments.sort_by {|c| [c.body, -c.id] } + end + end diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index f7f07c1..34d8492 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -1,5 +1,6 @@ class Comment < ActiveRecord::Base named_scope :containing_the_letter_e, :conditions => "comments.body LIKE '%e%'" + named_scope :order_by_body, :order => :body belongs_to :post, :counter_cache => true