diff --git a/app/controllers/comfy/blog/posts_controller.rb b/app/controllers/comfy/blog/posts_controller.rb index 5220e89..ea3caf0 100644 --- a/app/controllers/comfy/blog/posts_controller.rb +++ b/app/controllers/comfy/blog/posts_controller.rb @@ -14,7 +14,6 @@ def index end scope = scope.for_category(params[:category]) if params[:category] - scope = scope.order(:published_at).reverse_order @blog_posts = comfy_paginate(scope, per_page: ComfyBlog.config.posts_per_page) diff --git a/test/controllers/comfy/blog/posts_controller_test.rb b/test/controllers/comfy/blog/posts_controller_test.rb index 9311673..5e33621 100644 --- a/test/controllers/comfy/blog/posts_controller_test.rb +++ b/test/controllers/comfy/blog/posts_controller_test.rb @@ -76,14 +76,9 @@ def test_get_index_with_category_invalid def test_get_index_is_sorted new_post = @site.blog_posts.create!( - site: comfy_cms_sites(:default), - title: "Default title 2", - slug: "default-title-2", - is_published: true, - year: 2012, - month: 1, - published_at: DateTime.new(2012, 1, 1, 1, 24, 0), - layout: comfy_cms_layouts(:default) + title: "Test Post", + published_at: @post.published_at + 1.day, + layout: comfy_cms_layouts(:default) ) get comfy_blog_posts_path @@ -91,9 +86,7 @@ def test_get_index_is_sorted assert_response :success assert assigns(:blog_posts) assert_equal 2, assigns(:blog_posts).count - - assert_equal new_post, assigns(:blog_posts)[0] - assert_equal comfy_blog_posts(:default), assigns(:blog_posts)[1] + assert_equal [new_post, @post], assigns(:blog_posts).to_a end def test_get_show