diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb index e94bd3608cf..6ee0831c5ae 100644 --- a/spec/components/topic_view_spec.rb +++ b/spec/components/topic_view_spec.rb @@ -191,10 +191,11 @@ describe TopicView do context '#recent_posts' do before do - 24.times do # our let()s have already created 3 - Fabricate(:post, topic: topic, user: first_poster) + 24.times do |t| # our let()s have already created 3 + Fabricate(:post, topic: topic, user: first_poster, created_at: t.seconds.from_now) end end + it 'returns at most 25 recent posts ordered newest first' do recent_posts = topic_view.recent_posts diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 6f5b2c69dfb..2cbff032885 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -39,7 +39,9 @@ describe Post do describe '#by_newest' do it 'returns posts ordered by created_at desc' do - 2.times { Fabricate(:post) } + 2.times do |t| + Fabricate(:post, created_at: t.seconds.from_now) + end Post.by_newest.first.created_at.should > Post.by_newest.last.created_at end end