FIX: makes dashboard more resilient to errors (#6217)

This commit is an attempt to limit cases where the dashboard will generate a full exception page and also make it easier to track the error.
This commit is contained in:
Joffrey JAFFEUX
2018-07-31 21:23:28 -04:00
committed by GitHub
parent 7d8286e7ad
commit 2b2a506a7b
12 changed files with 135 additions and 76 deletions

View File

@ -475,6 +475,8 @@ describe Report do
let(:post) { Fabricate(:post) }
before do
freeze_time
PostAction.act(flagger, post, PostActionType.types[:spam], message: 'bad')
end
@ -507,6 +509,8 @@ describe Report do
let(:post) { Fabricate(:post) }
before do
freeze_time
post.revise(editor, raw: 'updated body', edit_reason: 'not cool')
end
@ -674,4 +678,38 @@ describe Report do
end
end
end
describe "exception report" do
before(:each) do
class Report
def self.report_exception_test(report)
report.data = x
end
end
end
it "returns a report with an exception error" do
report = Report.find("exception_test")
expect(report.error).to eq(:exception)
end
end
describe "timeout report" do
before(:each) do
freeze_time
class Report
def self.report_timeout_test(report)
report.error = wrap_slow_query(1) do
ActiveRecord::Base.connection.execute("SELECT pg_sleep(5)")
end
end
end
end
it "returns a report with a timeout error" do
report = Report.find("timeout_test")
expect(report.error).to eq(:timeout)
end
end
end