Sha256: f082ccdd80d0939a59b516ed60544e9a7172c9ac1da13c56c709aabe1e805e37

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

module EmailSpec
  module BackgroundProcesses
    module DelayedJob
      def all_emails
        work_off_queue
        super
      end

      def last_email_sent
        work_off_queue
        super
      end

      def reset_mailer
        work_off_queue
        super
      end

      def mailbox_for(address)
        work_off_queue
        super
      end

      private

      # Later versions of DelayedJob switch from using Delayed::Job to Delayed::Worker
      # Support both versions for those who haven't upgraded yet
      def work_off_queue
        if defined?(Delayed::Job)
          Delayed::Job.work_off
        else
          Delayed::Worker.send :public, :work_off
          worker = Delayed::Worker.new(:max_priority => nil, :min_priority => nil, :quiet => true)
          worker.work_off
        end
      end
    end

    module Compatibility
      if defined?(Delayed) && (defined?(Delayed::Job) || defined?(Delayed::Worker))
        include EmailSpec::BackgroundProcesses::DelayedJob
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
path-email_spec-0.6.2 lib/email_spec/background_processes.rb
email_spec-0.6.2 lib/email_spec/background_processes.rb
email_spec-0.6.1 lib/email_spec/background_processes.rb
email_spec-0.6.0 lib/email_spec/background_processes.rb