Skip to content

Commit 068fe5c

Browse files
authored
Merge pull request #1162 from eip-ewi/fix-post-locked
2 parents e87442b + e34e1cb commit 068fe5c

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

app/models/post.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ def locked?
175175
if locked
176176
update(locked: false, locked_by: nil, locked_at: nil, locked_until: nil)
177177
end
178+
179+
false
178180
end
179181

180182
# @param user [User, Nil]

test/controllers/posts/lock_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,15 @@ class PostsControllerTest < ActionController::TestCase
7979
end
8080
assert_equal 'success', JSON.parse(response.body)['status']
8181
end
82+
83+
test 'Locks on posts expire' do
84+
sign_in users(:moderator)
85+
post :lock, params: { id: posts(:question_one).id, length: 1, format: :json }
86+
assert_response 200
87+
88+
# Change the locked_until to have already passed
89+
assigns(:post).update(locked_until: 1.second.ago)
90+
91+
assert_not assigns(:post).locked?
92+
end
8293
end

test/fixtures/posts.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ locked:
150150
locked: true
151151
locked_by: deleter
152152
locked_at: 2019-01-01T00:00:00.000000Z
153-
locked_until: 2020-01-01T00:00:00.000000Z
154153
user: standard_user
155154
community: sample
156155
category: main
@@ -175,7 +174,6 @@ locked_mod:
175174
locked: true
176175
locked_by: moderator
177176
locked_at: 2019-01-01T00:00:00.000000Z
178-
locked_until: 2020-01-01T00:00:00.000000Z
179177
user: standard_user
180178
community: sample
181179
category: main

0 commit comments

Comments
 (0)