-
-
Save rbazinet/1857661 to your computer and use it in GitHub Desktop.
EmailQueue for Sidekiq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmailQueue | |
include Sidekiq::Worker | |
def perform(options) | |
mailer = options['mailer'].constantize | |
method = options['method'] | |
args = options['args'] | |
mailer.send(method, *args).deliver | |
end | |
def self.enqueue(mailer_klass, method, *args) | |
options = {'mailer' => mailer_klass.to_s, 'method' => method, 'args' => args} | |
self.perform_async(options) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec::Matchers.define :have_queued_email do |expected| | |
match do |actual| | |
EmailQueue.jobs.any?{|job| job['args'] == [expected.merge('mailer' => actual.to_s)]} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment