Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
language: ruby

rvm:
- 2.2.5
- 2.3.1
- 2.4.1
- 2.2.10
- 2.5.9
- 2.7.4
- 3.0.0

env:
- RAILS_VERSION=4.2
- RAILS_VERSION=5.2
- RAILS_VERSION=6.0
- RAILS_VERSION=6.1

jobs:
exclude:
- rvm: 2.2.10
env: RAILS_VERSION=5.2
- rvm: 2.2.10
env: RAILS_VERSION=6.0
- rvm: 2.2.10
env: RAILS_VERSION=6.1

- rvm: 2.5.9
env: RAILS_VERSION=4.2

- rvm: 2.7.4
env: RAILS_VERSION=4.2

- rvm: 3.0.0
env: RAILS_VERSION=4.2
- rvm: 3.0.0
env: RAILS_VERSION=5.2
- rvm: 3.0.0
env: RAILS_VERSION=6.0

before_install:
- gem install bundler -v 1.15
Expand Down
14 changes: 14 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,17 @@ source 'https://rubygems.org'

# Specify your gem's dependencies in devise-async.gemspec
gemspec

version = ENV['RAILS_VERSION'] || "~> 6.1"

gem "activerecord", version
gem "actionpack", version
gem "actionmailer", version

if version =~ /^4/
gem 'sqlite3', '~> 1.3.6'
elsif version =~ /^5.2/
gem 'sqlite3', '~> 1.3.6'
else
gem 'sqlite3', '~> 1.4'
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Devise Async

[![Tag](https://img.shields.io/github/tag/mhfs/devise-async.svg?style=flat-square)](https://github.com/mhfs/devise-async/releases) [![Build Status](https://img.shields.io/travis/mhfs/devise-async.svg?style=flat-square)](https://travis-ci.org/mhfs/devise-async) [![Code Climate](https://img.shields.io/codeclimate/github/mhfs/devise-async.svg?style=flat-square)](https://codeclimate.com/github/mhfs/devise-async)
[![Build Status](https://app.travis-ci.com/joe1chen/devise-async.svg?branch=master)](https://app.travis-ci.com/github/joe1chen/devise-async)

Devise Async provides an easy way to configure Devise to send its emails asynchronously using ActiveJob.

Expand Down
7 changes: 2 additions & 5 deletions devise-async.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ Gem::Specification.new do |gem|


gem.add_runtime_dependency 'devise', '>= 4.0'
gem.add_runtime_dependency 'activejob', '>= 5.0'
gem.add_runtime_dependency 'activejob', '>= 4.2'

gem.add_development_dependency 'activerecord', '>= 5.0'
gem.add_development_dependency 'actionpack', '>= 5.0'
gem.add_development_dependency 'actionmailer', '>= 5.0'
gem.add_development_dependency 'rspec', '~> 3.6'
gem.add_development_dependency 'rspec-rails', '~> 3.6'
gem.add_development_dependency 'sqlite3', '~> 1.3'
gem.add_development_dependency 'sqlite3'
gem.add_development_dependency 'pry'
end
4 changes: 4 additions & 0 deletions lib/devise/async.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ module Async
mattr_accessor :enabled
@@enabled = true

# Defines the queue in which the background job will be enqueued.
mattr_accessor :queue
@@queue = nil

# Allow configuring Devise::Async with a block
#
# Example:
Expand Down
9 changes: 8 additions & 1 deletion lib/devise/async/model.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'action_mailer'

module Devise
module Models
module Async
Expand Down Expand Up @@ -50,7 +52,12 @@ def devise_pending_notifications
private

def deliver_mail_later(notification, model, args)
devise_mailer.send(notification, model, *args).deliver_later
if ActionMailer::Base.method_defined?(:deliver_later_queue_name)
# Rails 5 introduced the option of setting the mailer queue name.
devise_mailer.send(notification, model, *args).deliver_later(queue: Devise::Async.queue || ActionMailer::Base.deliver_later_queue_name)
else
devise_mailer.send(notification, model, *args).deliver_later
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/devise/async_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@
expect(described_class.enabled).to eq(false)
described_class.enabled = initial_enabled
end

it 'stores queue config' do
initial_queue = described_class.queue

described_class.queue = :critical
expect(described_class.queue).to eq(:critical)
described_class.queue = initial_queue
end
end