FIX: Use default locale for edit reason when owner of post gets changed
This commit is contained in:
parent
efef422416
commit
f3d3129113
|
@ -498,16 +498,22 @@ class Post < ActiveRecord::Base
|
|||
def set_owner(new_user, actor, skip_revision = false)
|
||||
return if user_id == new_user.id
|
||||
|
||||
edit_reason = I18n.t('change_owner.post_revision_text',
|
||||
old_user: (self.user.username_lower rescue nil) || I18n.t('change_owner.deleted_user'),
|
||||
new_user: new_user.username_lower
|
||||
edit_reason = I18n.with_locale(SiteSetting.default_locale) do
|
||||
I18n.t('change_owner.post_revision_text',
|
||||
old_user: (self.user.username_lower rescue nil) || I18n.t('change_owner.deleted_user'),
|
||||
new_user: new_user.username_lower
|
||||
)
|
||||
end
|
||||
|
||||
revise(
|
||||
actor,
|
||||
{ raw: self.raw, user_id: new_user.id, edit_reason: edit_reason },
|
||||
bypass_bump: true, skip_revision: skip_revision
|
||||
)
|
||||
revise(actor, { raw: self.raw, user_id: new_user.id, edit_reason: edit_reason }, bypass_bump: true, skip_revision: skip_revision)
|
||||
|
||||
if post_number == topic.highest_post_number
|
||||
topic.update_columns(last_post_user_id: new_user.id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
before_create do
|
||||
|
|
|
@ -919,6 +919,23 @@ describe Post do
|
|||
expect(post.user).to eq(coding_horror)
|
||||
expect(post.revisions.size).to eq(0)
|
||||
end
|
||||
|
||||
it "uses default locale for edit reason" do
|
||||
I18n.locale = 'de'
|
||||
old_username = post.user.username_lower
|
||||
|
||||
post.set_owner(coding_horror, Discourse.system_user)
|
||||
post.reload
|
||||
|
||||
expected_reason = I18n.with_locale(SiteSetting.default_locale) do
|
||||
I18n.t('change_owner.post_revision_text',
|
||||
old_user: old_username,
|
||||
new_user: coding_horror.username_lower
|
||||
)
|
||||
end
|
||||
|
||||
expect(post.edit_reason).to eq(expected_reason)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".rebake_old" do
|
||||
|
|
Loading…
Reference in New Issue