diff --git a/app/models/post.rb b/app/models/post.rb index cfd4aeef1a46ce5ad9be7e9daae35e8361fc2fa7..6d32dfe6aaa4e2854a4bff60656d7702bad3adce 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -175,6 +175,8 @@ class Post < ApplicationRecord if locked update(locked: false, locked_by: nil, locked_at: nil, locked_until: nil) end + + false end # @param user [User, Nil] diff --git a/test/controllers/posts/lock_test.rb b/test/controllers/posts/lock_test.rb index 95a30470b1ce526b0803a3c767aa4269a9c6e5a7..cfb7b2ddc0b71518fb698ac74960de5af281df3f 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 diff --git a/test/fixtures/posts.yml b/test/fixtures/posts.yml index e67b996fbea5935fa33cf500ba23f124515d3572..c3597fb96896631d447eb8c2c3c8e26b0f75ce34 100644 --- a/test/fixtures/posts.yml +++ b/test/fixtures/posts.yml @@ -150,7 +150,6 @@ locked: locked: true locked_by: deleter locked_at: 2019-01-01T00:00:00.000000Z - locked_until: 2020-01-01T00:00:00.000000Z user: standard_user community: sample category: main @@ -175,7 +174,6 @@ locked_mod: locked: true locked_by: moderator locked_at: 2019-01-01T00:00:00.000000Z - locked_until: 2020-01-01T00:00:00.000000Z user: standard_user community: sample category: main