FIX: while changing site text, old and new values can be nil

This commit is contained in:
Arpit Jalan 2016-01-18 20:56:14 +05:30
parent e6c1f1db52
commit cf1bd35fc6
2 changed files with 1 additions and 5 deletions

View file

@ -134,10 +134,8 @@ class StaffActionLogger
}))
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(:new_text) unless new_text.present?
raise Discourse::InvalidParameters.new(:old_text) unless old_text.present?
UserHistory.create( params(opts).merge({
action: UserHistory.actions[:change_site_text],
subject: subject,

View file

@ -176,8 +176,6 @@ describe StaffActionLogger do
describe "log_site_text_change" 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('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
it "creates a new UserHistory record" do