mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 00:03:26 +08:00
FIX: while changing site text, old and new values can be nil
This commit is contained in:
parent
e6c1f1db52
commit
cf1bd35fc6
@ -134,10 +134,8 @@ class StaffActionLogger
|
|||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_site_text_change(subject, new_text, old_text, opts={})
|
def log_site_text_change(subject, new_text=nil, old_text=nil, opts={})
|
||||||
raise Discourse::InvalidParameters.new(:subject) unless subject.present?
|
raise Discourse::InvalidParameters.new(:subject) unless subject.present?
|
||||||
raise Discourse::InvalidParameters.new(:new_text) unless new_text.present?
|
|
||||||
raise Discourse::InvalidParameters.new(:old_text) unless old_text.present?
|
|
||||||
UserHistory.create( params(opts).merge({
|
UserHistory.create( params(opts).merge({
|
||||||
action: UserHistory.actions[:change_site_text],
|
action: UserHistory.actions[:change_site_text],
|
||||||
subject: subject,
|
subject: subject,
|
||||||
|
@ -176,8 +176,6 @@ describe StaffActionLogger do
|
|||||||
describe "log_site_text_change" do
|
describe "log_site_text_change" do
|
||||||
it "raises an error when params are invalid" do
|
it "raises an error when params are invalid" do
|
||||||
expect { logger.log_site_text_change(nil, 'new text', 'old text') }.to raise_error(Discourse::InvalidParameters)
|
expect { logger.log_site_text_change(nil, 'new text', 'old text') }.to raise_error(Discourse::InvalidParameters)
|
||||||
expect { logger.log_site_text_change('created', nil, 'old text') }.to raise_error(Discourse::InvalidParameters)
|
|
||||||
expect { logger.log_site_text_change('created', 'new text', nil) }.to raise_error(Discourse::InvalidParameters)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a new UserHistory record" do
|
it "creates a new UserHistory record" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user