Merge branch 'master' of https://github.com/FarmBot/Farmbot-Web-App into staging

pull/1399/head
gabrielburnworth 2019-08-27 13:53:53 -07:00
commit 4edfa20b60
3 changed files with 9 additions and 5 deletions

View File

@ -94,7 +94,8 @@ class DashboardController < ApplicationController
rescue
report = { problem: "Crashed while parsing report" }
end
Rollbar.info("CSP Violation", report)
# We get too many CSP reports.
# Rollbar.info("CSP Violation", report)
render json: report
end

View File

@ -7,10 +7,12 @@ class LogService < AbstractServiceRunner
T.new(1.hour) => 0.5 * 10_000,
T.new(1.day) => 0.5 * 100_000
LOG_TPL = "FBOS LOG (device_%s): %s"
def process(delivery_info, payload)
params = { routing_key: delivery_info.routing_key, payload: payload }
m = AmqpLogParser.run!(params)
puts "#{m.device_id}: #{m.payload["message"]}" if Rails.env.production?
puts LOG_TPL % [m.device_id, m.payload["message"]] if Rails.env.production?
THROTTLE_POLICY.track(m.device_id)
maybe_deliver(m)
end

View File

@ -20,14 +20,15 @@ describe DashboardController do
end
it "receives CSP violation reports (malformed JSON)" do
expect(Rollbar).to receive(:info)
.with("CSP Violation", { problem: "Crashed while parsing report" })
# expect(Rollbar).to receive(:info)
# .with("CSP Violation", { problem: "Crashed while parsing report" })
post :csp_reports, body: "NOT JSON ! ! !"
expect(json).to eq(problem: "Crashed while parsing report")
end
it "receives CSP violation reports (malformed JSON)" do
expect(Rollbar).to receive(:info).with("CSP Violation", {})
post :csp_reports, body: {}.to_json, params: { format: :json }
expect(json).to eq({})
end
it "creates a new user" do