FIX: If a post has been hidden due to flagging, don't use the absolute

edit window for edit prevention.
This commit is contained in:
Robin Ward 2014-09-16 11:20:31 -04:00
parent b62aaf5a53
commit 309b67add4
2 changed files with 14 additions and 3 deletions

View File

@ -89,10 +89,14 @@ module PostGuardian
end
if is_my_own?(post)
return false if post.hidden? &&
post.hidden_at.present? &&
if post.hidden?
return false if post.hidden_at.present? &&
post.hidden_at >= SiteSetting.cooldown_minutes_after_hiding_posts.minutes.ago
# If it's your own post and it's hidden, you can still edit it
return true
end
return !post.edit_time_limit_expired?
end

View File

@ -710,6 +710,13 @@ describe Guardian do
Guardian.new(post.user).can_edit?(post).should be_true
end
it "returns true if the post is hidden, it's been enough time and the edit window has expired" do
post.hidden = true
post.hidden_at = (SiteSetting.cooldown_minutes_after_hiding_posts + 1).minutes.ago
post.created_at = (SiteSetting.post_edit_time_limit + 1).minutes.ago
Guardian.new(post.user).can_edit?(post).should be_true
end
it "returns true if the post is hidden due to flagging and it's got a nil `hidden_at`" do
post.hidden = true
post.hidden_at = nil