Skip to content

Commit

Permalink
Adds a test for sorting posts by their published_at date
Browse files Browse the repository at this point in the history
  • Loading branch information
kirichkov committed May 10, 2018
1 parent 3985f22 commit e5c62eb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions test/controllers/comfy/blog/posts_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,28 @@ def test_get_index_with_category_invalid
assert_equal 0, assigns(:blog_posts).count
end

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)
)

get comfy_blog_posts_path

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]
end

def test_get_show
@post.update_column(:content_cache, "blog post content")
get comfy_blog_post_path(@site.path, @post.year, @post.month, @post.slug)
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/comfy/blog/posts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ default:
is_published: true
year: 2012
month: 1
published_at: <%= 2.days.ago %>
published_at: 2012-01-01 01:23:00
layout: default

0 comments on commit e5c62eb

Please sign in to comment.