correct spec and error reporting
previous commit misused warn_exception which caused a spec to fail
This commit is contained in:
parent
589e3fcaa0
commit
23423ba112
|
@ -1283,11 +1283,11 @@ class Report
|
|||
FROM user_auth_token_logs t
|
||||
JOIN users u ON u.id = t.user_id
|
||||
WHERE t.action = 'suspicious'
|
||||
AND t.created_at >= '#{report.start_date}'
|
||||
AND t.created_at <= '#{report.end_date}'
|
||||
AND t.created_at >= :start_date
|
||||
AND t.created_at <= :end_date
|
||||
SQL
|
||||
|
||||
DB.query(sql).each do |row|
|
||||
DB.query(sql, start_date: report.start_date, end_date: report.end_date).each do |row|
|
||||
data = {}
|
||||
|
||||
ipinfo = DiscourseIpInfo.get(row.client_ip)
|
||||
|
|
|
@ -42,7 +42,7 @@ class DiscourseIpInfo
|
|||
ret[:location] = [ret[:city], ret[:region], ret[:country]].reject(&:blank?).join(", ")
|
||||
end
|
||||
rescue => e
|
||||
Discourse.warn_exception(e, "IP #{ip} could not be looked up in MaxMind GeoLite2-City database.")
|
||||
Discourse.warn_exception(e, message: "IP #{ip} could not be looked up in MaxMind GeoLite2-City database.")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -55,7 +55,7 @@ class DiscourseIpInfo
|
|||
ret[:organization] = result["autonomous_system_organization"]
|
||||
end
|
||||
rescue => e
|
||||
Discourse.warn_exception(e, "IP #{ip} could not be looked up in MaxMind GeoLite2-ASN database.")
|
||||
Discourse.warn_exception(e, message: "IP #{ip} could not be looked up in MaxMind GeoLite2-ASN database.")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -980,6 +980,9 @@ describe Report do
|
|||
|
||||
context "with data" do
|
||||
it "works" do
|
||||
SiteSetting.verbose_auth_token_logging = true
|
||||
freeze_time DateTime.parse('2017-03-01 12:00')
|
||||
|
||||
UserAuthToken.log(action: "suspicious", user_id: robin.id)
|
||||
UserAuthToken.log(action: "suspicious", user_id: joffrey.id)
|
||||
UserAuthToken.log(action: "suspicious", user_id: joffrey.id)
|
||||
|
|
Loading…
Reference in New Issue