diff --git a/test/system/post_test.rb b/test/system/post_test.rb index f67d4207c21506920f6694884116ee0380b03bf3..3fd5f8c808f0ec4216ce838e8cde701c7477031b 100644 --- a/test/system/post_test.rb +++ b/test/system/post_test.rb @@ -31,5 +31,31 @@ class PostTest < ApplicationSystemTestCase # TODO: Post validations - # TODO: Sort urls -end \ No newline at end of file + # ------------------------------------------------------- + # Show + # ------------------------------------------------------- + + test 'User can view post' do + post = posts(:question_one) + visit post_url(post) + + # Check that the post is displayed somewhere on the page + assert_text post.title + assert_text post.body + + # Check that answers are displayed somewhere on the page + assert post.children.any?, 'The post for this system test should have answers' + post.children.where(deleted: false).each do |child| + assert_text child.body + end + end + + test 'User can sort answers' do + post = posts(:question_one) + visit post_url(post) + + click_on 'Active' + + assert_current_path post_url(post, sort: 'active') + end +end