require 'spec_helper' require_dependency 'jobs/regular/process_post' describe Jobs::PollMailbox do let!(:poller) { Jobs::PollMailbox.new } describe ".execute" do it "does no polling if pop3s_polling_enabled is false" do SiteSetting.expects(:pop3s_polling_enabled?).returns(false) poller.expects(:poll_pop3s).never poller.execute({}) end describe "with pop3s_polling_enabled" do it "calls poll_pop3s" do SiteSetting.expects(:pop3s_polling_enabled?).returns(true) poller.expects(:poll_pop3s).once poller.execute({}) end end end describe ".poll_pop3s" do it "informs admins on pop authentication error" do error = Net::POPAuthenticationError.new data = { limit_once_per: 1.hour, message_params: { error: error }} Net::POP3.expects(:start).raises(error) GroupMessage.expects(:create).with("admins", :email_error_notification, data) poller.poll_pop3s end end describe "processing email" do let!(:receiver) { mock } let!(:email_string) { <