From e34e1cb6f8bc3221723ea60edc575a691b646178 Mon Sep 17 00:00:00 2001 From: Taico Aerts <t.v.aerts@tudelft.nl> Date: Fri, 4 Aug 2023 09:54:27 +0200 Subject: [PATCH] Add test for expiring lock --- test/controllers/posts/lock_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/controllers/posts/lock_test.rb b/test/controllers/posts/lock_test.rb index 95a30470b..cfb7b2ddc 100644 --- a/test/controllers/posts/lock_test.rb +++ b/test/controllers/posts/lock_test.rb @@ -79,4 +79,15 @@ class PostsControllerTest < ActionController::TestCase end assert_equal 'success', JSON.parse(response.body)['status'] end + + test 'Locks on posts expire' do + sign_in users(:moderator) + post :lock, params: { id: posts(:question_one).id, length: 1, format: :json } + assert_response 200 + + # Change the locked_until to have already passed + assigns(:post).update(locked_until: 1.second.ago) + + assert_not assigns(:post).locked? + end end -- GitLab