diff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rb index d6af09842..4e3af29e5 100644 --- a/lib/guardian/post_guardian.rb +++ b/lib/guardian/post_guardian.rb @@ -89,9 +89,13 @@ module PostGuardian end if is_my_own?(post) - return false if post.hidden? && - post.hidden_at.present? && - post.hidden_at >= SiteSetting.cooldown_minutes_after_hiding_posts.minutes.ago + 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 diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index 5ff55a9f4..8ebd05af1 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -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