FIX: allow post editing but do not allow ninja edit for active flagged post

This commit is contained in:
Arpit Jalan 2016-03-30 23:48:42 +05:30
parent 44e41df76b
commit 094f7a73d5
3 changed files with 2 additions and 24 deletions

View File

@ -90,7 +90,7 @@ module PostGuardian
return true
end
if post.topic.archived? || post.user_deleted || post.deleted_at || post.has_active_flag?
if post.topic.archived? || post.user_deleted || post.deleted_at
return false
end

View File

@ -175,6 +175,7 @@ class PostRevisor
end
def ninja_edit?
return false if @post.has_active_flag?
@revised_at - @last_version_at <= SiteSetting.editing_grace_period.to_i
end

View File

@ -1008,29 +1008,6 @@ describe Guardian do
expect(Guardian.new(admin).can_edit?(tos_first_post)).to be_truthy
end
end
context "flagged post" do
let(:user) { Fabricate(:user) }
let(:post) { Fabricate(:post) }
before { PostAction.act(user, post, PostActionType.types[:off_topic]) }
it 'returns false when post owner tries to edit active flagged post' do
expect(Guardian.new(post.user).can_edit?(post)).to be_falsey
end
it 'returns true when trust level 4 user tries to edit active flagged post' do
expect(Guardian.new(trust_level_4).can_edit?(post)).to be_truthy
end
it 'returns true when staff tries to edit active flagged post' do
expect(Guardian.new(moderator).can_edit?(post)).to be_truthy
end
it 'returns true when post owner tries to edit post with inactive flag' do
PostAction.defer_flags!(post, admin)
expect(Guardian.new(post.user).can_edit?(post)).to be_truthy
end
end
end
describe 'a Topic' do