Disallow revision edits with empty raw content
This commit is contained in:
parent
44d95ad5ab
commit
4f81bb8303
|
@ -121,6 +121,8 @@ class PostRevisor
|
|||
|
||||
@topic_changes = TopicChanges.new(@topic, editor)
|
||||
|
||||
return false if @fields.has_key?(:raw) && @fields[:raw].blank?
|
||||
|
||||
# some normalization
|
||||
@fields[:raw] = cleanup_whitespaces(@fields[:raw]) if @fields.has_key?(:raw)
|
||||
@fields[:user_id] = @fields[:user_id].to_i if @fields.has_key?(:user_id)
|
||||
|
|
|
@ -114,6 +114,15 @@ describe PostRevisor do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'with nil raw contents' do
|
||||
it "doesn't change version" do
|
||||
expect {
|
||||
expect(subject.revise!(post.user, raw: nil)).to eq(false)
|
||||
post.reload
|
||||
}.not_to change(post, :version)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ninja editing' do
|
||||
it 'correctly applies edits' do
|
||||
SiteSetting.editing_grace_period = 1.minute
|
||||
|
|
Loading…
Reference in New Issue