mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 17:12:45 +08:00
FIX: allow post editing but do not allow ninja edit for active flagged post
This commit is contained in:
parent
44e41df76b
commit
094f7a73d5
|
@ -90,7 +90,7 @@ module PostGuardian
|
||||||
return true
|
return true
|
||||||
end
|
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
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,7 @@ class PostRevisor
|
||||||
end
|
end
|
||||||
|
|
||||||
def ninja_edit?
|
def ninja_edit?
|
||||||
|
return false if @post.has_active_flag?
|
||||||
@revised_at - @last_version_at <= SiteSetting.editing_grace_period.to_i
|
@revised_at - @last_version_at <= SiteSetting.editing_grace_period.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1008,29 +1008,6 @@ describe Guardian do
|
||||||
expect(Guardian.new(admin).can_edit?(tos_first_post)).to be_truthy
|
expect(Guardian.new(admin).can_edit?(tos_first_post)).to be_truthy
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
describe 'a Topic' do
|
describe 'a Topic' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user