FEATURE: Add POP3 timeout error only after 3 failures in a row.

This commit is contained in:
Guo Xiang Tan
2016-04-06 14:59:48 +08:00
parent 46487f095e
commit f95cefd09a
2 changed files with 52 additions and 8 deletions

View File

@@ -23,10 +23,39 @@ describe Jobs::PollMailbox do
describe ".poll_pop3" do
it "logs an error on pop authentication error" do
Net::POP3.any_instance.expects(:start).raises(Net::POPAuthenticationError.new)
Discourse.expects(:handle_job_exception)
poller.poll_pop3
context "pop errors" do
let(:user) { Fabricate(:user) }
before do
Discourse.expects(:handle_job_exception).at_least_once
end
after do
$redis.flushall
end
it "add an admin dashboard message on pop authentication error" do
Net::POP3.any_instance.expects(:start)
.raises(Net::POPAuthenticationError.new).at_least_once
poller.poll_pop3
i18n_key = 'dashboard.poll_pop3_auth_error'
expect(AdminDashboardData.problem_message_check(i18n_key))
.to eq(I18n.t(i18n_key))
end
it "logs an error on pop connection timeout error" do
Net::POP3.any_instance.expects(:start).raises(Net::OpenTimeout.new).at_least_once
4.times { poller.poll_pop3 }
i18n_key = 'dashboard.poll_pop3_timeout'
expect(AdminDashboardData.problem_message_check(i18n_key))
.to eq(I18n.t(i18n_key))
end
end
it "calls enable_ssl when the setting is enabled" do