From 85ec7674e8bc4b2c2cfc17181a25b2e20a6fc45d Mon Sep 17 00:00:00 2001 From: Taico Aerts <t.v.aerts@tudelft.nl> Date: Wed, 2 Aug 2023 22:38:23 +0200 Subject: [PATCH] Add show tests --- test/system/post_test.rb | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/test/system/post_test.rb b/test/system/post_test.rb index f67d4207c..3fd5f8c80 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 -- GitLab