mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
When logging the deletion of a user, don't store its id in the target_user_id column. It will never match a user record.
This commit is contained in:
parent
57d78aaba6
commit
52b0c1c45f
@ -9,7 +9,6 @@ class StaffActionLogger
|
||||
raise Discourse::InvalidParameters.new('user is nil') unless deleted_user and deleted_user.is_a?(User)
|
||||
UserHistory.create( params(opts).merge({
|
||||
action: UserHistory.actions[:delete_user],
|
||||
target_user_id: deleted_user.id,
|
||||
email: deleted_user.email,
|
||||
ip_address: deleted_user.ip_address.to_s,
|
||||
details: [:id, :username, :name, :created_at, :trust_level, :last_seen_at, :last_emailed_at].map { |x| "#{x}: #{deleted_user.send(x)}" }.join(', ')
|
||||
|
@ -28,9 +28,8 @@ describe StaffActionLogger do
|
||||
expect { logger.log_user_deletion(1) }.to raise_error(Discourse::InvalidParameters)
|
||||
end
|
||||
|
||||
it 'creates a new StaffActionLog record' do
|
||||
it 'creates a new UserHistory record' do
|
||||
expect { log_user_deletion }.to change { UserHistory.count }.by(1)
|
||||
UserHistory.last.target_user_id.should == deleted_user.id
|
||||
end
|
||||
end
|
||||
|
||||
@ -56,7 +55,7 @@ describe StaffActionLogger do
|
||||
expect { logger.log_trust_level_change(user, old_trust_level, max_level + 1) }.to raise_error(Discourse::InvalidParameters)
|
||||
end
|
||||
|
||||
it 'creates a new StaffActionLog record' do
|
||||
it 'creates a new UserHistory record' do
|
||||
expect { log_trust_level_change }.to change { UserHistory.count }.by(1)
|
||||
UserHistory.last.details.should include "new trust level: #{new_trust_level}"
|
||||
end
|
||||
@ -69,7 +68,7 @@ describe StaffActionLogger do
|
||||
expect { logger.log_site_setting_change('abc', '1', '2') }.to raise_error(Discourse::InvalidParameters)
|
||||
end
|
||||
|
||||
it "creates a new StaffActionLog record" do
|
||||
it "creates a new UserHistory record" do
|
||||
expect { logger.log_site_setting_change('title', 'Discourse', 'My Site') }.to change { UserHistory.count }.by(1)
|
||||
end
|
||||
end
|
||||
@ -106,7 +105,7 @@ describe StaffActionLogger do
|
||||
expect { logger.log_site_customization_destroy(nil) }.to raise_error(Discourse::InvalidParameters)
|
||||
end
|
||||
|
||||
it "creates a new StaffActionLog record" do
|
||||
it "creates a new UserHistory record" do
|
||||
site_customization = SiteCustomization.new(name: 'Banana', stylesheet: "body {color: yellow;}", header: "h1 {color: brown;}")
|
||||
log_record = logger.log_site_customization_destroy(site_customization)
|
||||
log_record.previous_value.should be_present
|
||||
|
Loading…
Reference in New Issue
Block a user