mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:13:38 +08:00
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
|
FROM user_auth_token_logs t
|
||||||
JOIN users u ON u.id = t.user_id
|
JOIN users u ON u.id = t.user_id
|
||||||
WHERE t.action = 'suspicious'
|
WHERE t.action = 'suspicious'
|
||||||
AND t.created_at >= '#{report.start_date}'
|
AND t.created_at >= :start_date
|
||||||
AND t.created_at <= '#{report.end_date}'
|
AND t.created_at <= :end_date
|
||||||
SQL
|
SQL
|
||||||
|
|
||||||
DB.query(sql).each do |row|
|
DB.query(sql, start_date: report.start_date, end_date: report.end_date).each do |row|
|
||||||
data = {}
|
data = {}
|
||||||
|
|
||||||
ipinfo = DiscourseIpInfo.get(row.client_ip)
|
ipinfo = DiscourseIpInfo.get(row.client_ip)
|
||||||
|
|
|
@ -42,7 +42,7 @@ class DiscourseIpInfo
|
||||||
ret[:location] = [ret[:city], ret[:region], ret[:country]].reject(&:blank?).join(", ")
|
ret[:location] = [ret[:city], ret[:region], ret[:country]].reject(&:blank?).join(", ")
|
||||||
end
|
end
|
||||||
rescue => e
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class DiscourseIpInfo
|
||||||
ret[:organization] = result["autonomous_system_organization"]
|
ret[:organization] = result["autonomous_system_organization"]
|
||||||
end
|
end
|
||||||
rescue => e
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -980,6 +980,9 @@ describe Report do
|
||||||
|
|
||||||
context "with data" do
|
context "with data" do
|
||||||
it "works" 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: robin.id)
|
||||||
UserAuthToken.log(action: "suspicious", user_id: joffrey.id)
|
UserAuthToken.log(action: "suspicious", user_id: joffrey.id)
|
||||||
UserAuthToken.log(action: "suspicious", user_id: joffrey.id)
|
UserAuthToken.log(action: "suspicious", user_id: joffrey.id)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user