From fc4081a8df30256593754a430cec735cbb7e8a41 Mon Sep 17 00:00:00 2001 From: Taico Aerts <t.v.aerts@tudelft.nl> Date: Thu, 3 Aug 2023 20:07:49 +0200 Subject: [PATCH] Add test for post editing --- test/system/post_test.rb | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/test/system/post_test.rb b/test/system/post_test.rb index 73aa0cda8..7a2199fe6 100644 --- a/test/system/post_test.rb +++ b/test/system/post_test.rb @@ -107,7 +107,7 @@ class PostTest < ApplicationSystemTestCase # Show # ------------------------------------------------------- - test 'User can view post' do + test 'Anyone can view question' do post = posts(:question_one) visit post_url(post) @@ -122,7 +122,7 @@ class PostTest < ApplicationSystemTestCase end end - test 'User can sort answers' do + test 'Anyone can sort answers' do post = posts(:question_one) visit post_url(post) @@ -130,4 +130,28 @@ class PostTest < ApplicationSystemTestCase assert_current_path post_url(post, sort: 'active') end + + # ------------------------------------------------------- + # Edit + # ------------------------------------------------------- + + test 'User with edit permissions can directly edit question' do + log_in :editor + post = posts(:question_two) + visit post_url(post) + + within ".post[data-post-id=\"#{post.id}\"]" do + click_on 'Edit' + end + + updated_text = 'This is the updated body text, which should be quite different from the original text!' + fill_in 'Body', with: updated_text + fill_in 'Edit Comment', with: 'Major Rewrite for Tests' + + click_on "Save Post in #{post.category.name}" + assert_current_path post_url(post) + + # Check that the page shows the updated text + assert_text updated_text + end end -- GitLab