FIX: Post reviser picking up edits for hidden posts (#8792)

This commit is contained in:
Mark VanLandingham 2020-01-27 10:05:48 -06:00 committed by GitHub
parent ea11ad4d99
commit 20e3c0f386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View File

@ -335,6 +335,7 @@ class PostRevisor
update_post
update_topic if topic_changed?
create_or_update_revision
remove_flags_and_unhide_post
end
USER_ACTIONS_TO_REMOVE ||= [UserAction::REPLY, UserAction::RESPONSE]
@ -365,8 +366,6 @@ class PostRevisor
@post.word_count = @fields[:raw].scan(/[[:word:]]+/).size if @fields.has_key?(:raw)
@post.self_edits += 1 if self_edit?
remove_flags_and_unhide_post
@post.extract_quoted_post_numbers
@post_successfully_saved = @post.save(validate: @validate_post)

View File

@ -227,6 +227,18 @@ describe PostRevisor do
end
end
describe 'hidden post' do
it "correctly stores the modification value" do
post.update(hidden: true, hidden_reason_id: Post.hidden_reasons[:flag_threshold_reached])
revisor = PostRevisor.new(post)
revisor.revise!(post.user, { raw: 'hello world' }, revised_at: post.updated_at + 11.minutes)
expect(post.revisions.first.modifications.symbolize_keys).to eq(
cooked: ["<p>Hello world</p>", "<p>hello world</p>"],
raw: ["Hello world", "hello world"]
)
end
end
describe 'revision much later' do
let!(:revised_at) { post.updated_at + 2.minutes }