Sha256: 6499ca2f8416acfe36a40de6bd140467469bfa46b262630ec325864b766f9741

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 KB

Contents

# encoding: utf-8
require 'rails_helper'

RSpec.describe MailManager::Bounce do
  context "when checking pop account" do
    it "should not blow up when mail contains a bad extended char" do
      Delayed::Worker.delay_jobs = true
      send_bounce('bad_utf8_chars.eml')
      MailManager::BounceJob.new.perform
      Delayed::Worker.delay_jobs = false
    end
    it "should run every 10 minutes when there is mail on the current run" do
      Delayed::Worker.delay_jobs = true
      send_bounce('bad_utf8_chars.eml')
      MailManager::BounceJob.new.perform
      expect(Delayed::Job.count).to eq(1)
      expect(Delayed::Job.first.run_at.utc.to_i).to be_within(5).of(
        10.minutes.from_now.utc.to_i
      )
      Delayed::Worker.delay_jobs = false
    end
    it "should run every 120 minutes when there is no mail on the current check" do
      Delayed::Worker.delay_jobs = true
      MailManager::BounceJob.new.perform
      Delayed::Job.delete_all
      MailManager::BounceJob.new.perform
      expect(Delayed::Job.count).to eq(1)
      expect(Delayed::Job.first.run_at.utc.to_i).to be_within(5).of(
        120.minutes.from_now.utc.to_i
      )
      Delayed::Worker.delay_jobs = false
    end
  end
  def send_bounce(filename)
    mail = Mail.new(File.read(File.join(Rails.root,'spec','support','files',filename)))
    mail.delivery_method :smtp
    mail.delivery_method.settings.merge!(ActionMailer::Base.smtp_settings)
    mail.deliver
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mail_manager-3.2.5 spec/test_app/spec/models/mail_manager/bounce_spec.rb
mail_manager-3.2.4 spec/test_app/spec/models/mail_manager/bounce_spec.rb
mail_manager-3.2.2 spec/test_app/spec/models/mail_manager/bounce_spec.rb
mail_manager-3.2.1 spec/test_app/spec/models/mail_manager/bounce_spec.rb
mail_manager-3.2.0 spec/test_app/spec/models/mail_manager/bounce_spec.rb