Disallow revision edits with empty raw content

This commit is contained in:
Penar Musaraj 2018-11-12 15:28:38 -05:00
parent 44d95ad5ab
commit 4f81bb8303
2 changed files with 11 additions and 0 deletions

View File

@ -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)

View File

@ -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