FIX: Not logging old post contents properly
This commit is contained in:
parent
d31dfe0e84
commit
135195363b
|
@ -108,7 +108,7 @@ class StaffActionLogger
|
|||
UserHistory.create!(params(opts).merge(
|
||||
action: UserHistory.actions[:post_edit],
|
||||
post_id: post.id,
|
||||
details: "#{post.raw}\n\n---\n\n#{opts[:new_raw]}"
|
||||
details: "#{opts[:old_raw]}\n\n---\n\n#{post.raw}"
|
||||
))
|
||||
end
|
||||
|
||||
|
|
|
@ -150,6 +150,8 @@ class PostRevisor
|
|||
@skip_revision = false
|
||||
@skip_revision = @opts[:skip_revision] if @opts.has_key?(:skip_revision)
|
||||
|
||||
old_raw = @post.raw
|
||||
|
||||
Post.transaction do
|
||||
revise_post
|
||||
|
||||
|
@ -181,7 +183,7 @@ class PostRevisor
|
|||
if @editor.staff? && @editor.id != @post.user.id && @fields.has_key?('raw')
|
||||
StaffActionLogger.new(@editor).log_post_edit(
|
||||
@post,
|
||||
new_raw: @fields['raw']
|
||||
old_raw: old_raw
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -460,8 +460,9 @@ describe PostRevisor do
|
|||
log = UserHistory.where(
|
||||
acting_user_id: moderator.id,
|
||||
action: UserHistory.actions[:post_edit]
|
||||
)
|
||||
).first
|
||||
expect(log).to be_present
|
||||
expect(log.details).to eq("Hello world\n\n---\n\nlets totally update the body")
|
||||
end
|
||||
|
||||
it "doesn't log an edit when a staff member edits their own post" do
|
||||
|
|
Loading…
Reference in New Issue