Commit e9259e24b5e1e0cf04789301df2abfe92548a8b5
Exists in
master
and in
28 other branches
Merge commit 'e6804db53297868da972db1b7153ec94a7c07c97' into v0.11.x
+ removing an uneeded require of mocha
Showing
2 changed files
with
17 additions
and
1 deletions
Show diff stats
app/models/article.rb
@@ -86,7 +86,7 @@ class Article < ActiveRecord::Base | @@ -86,7 +86,7 @@ class Article < ActiveRecord::Base | ||
86 | 'profiles.public_profile' => true | 86 | 'profiles.public_profile' => true |
87 | }, | 87 | }, |
88 | :include => 'profile', | 88 | :include => 'profile', |
89 | - :order => 'articles.created_at desc, articles.id desc' | 89 | + :order => 'articles.updated_at desc, articles.id desc' |
90 | } | 90 | } |
91 | if ( scoped_methods && scoped_methods.last && | 91 | if ( scoped_methods && scoped_methods.last && |
92 | scoped_methods.last[:find] && | 92 | scoped_methods.last[:find] && |
test/unit/article_test.rb
@@ -169,6 +169,22 @@ class ArticleTest < Test::Unit::TestCase | @@ -169,6 +169,22 @@ class ArticleTest < Test::Unit::TestCase | ||
169 | assert_equal [ ], Article.recent(nil) | 169 | assert_equal [ ], Article.recent(nil) |
170 | end | 170 | end |
171 | 171 | ||
172 | + should 'order recent articles by updated_at' do | ||
173 | + p = create_user('usr1').person | ||
174 | + Article.destroy_all | ||
175 | + | ||
176 | + first = p.articles.build(:name => 'first', :public_article => true); first.save! | ||
177 | + second = p.articles.build(:name => 'second', :public_article => true, :updated_at => first.updated_at + 1.second); second.save! | ||
178 | + | ||
179 | + assert_equal [ second, first ], Article.recent(2) | ||
180 | + | ||
181 | + Article.record_timestamps = false | ||
182 | + first.update_attributes!(:updated_at => second.updated_at + 1.second) | ||
183 | + Article.record_timestamps = true | ||
184 | + | ||
185 | + assert_equal [ first, second ], Article.recent(2) | ||
186 | + end | ||
187 | + | ||
172 | should 'require that subclasses define description' do | 188 | should 'require that subclasses define description' do |
173 | assert_raise NotImplementedError do | 189 | assert_raise NotImplementedError do |
174 | Article.description | 190 | Article.description |