devise-async 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.travis.yml +6 -0
- data/Gemfile +1 -1
- data/README.md +13 -7
- data/devise-async.gemspec +11 -11
- data/lib/devise-async.rb +1 -1
- data/lib/devise/async.rb +32 -0
- data/lib/devise/async/backend.rb +11 -0
- data/lib/devise/async/backend/base.rb +16 -0
- data/lib/devise/async/backend/delayed_job.rb +11 -0
- data/lib/devise/async/backend/resque.rb +18 -0
- data/lib/devise/async/backend/sidekiq.rb +15 -0
- data/lib/devise/async/proxy.rb +18 -0
- data/lib/devise/async/version.rb +5 -0
- data/lib/devise/async/worker.rb +15 -0
- data/test/devise/async/backend/delayed_job_test.rb +24 -0
- data/test/devise/async/backend/resque_test.rb +21 -0
- data/test/devise/async/backend/sidekiq_test.rb +21 -0
- data/test/devise/async/backend_test.rb +25 -0
- data/test/devise/async/proxy_test.rb +13 -0
- data/test/devise/async/worker_test.rb +28 -0
- data/test/support/{app → rails_app}/app/models/user.rb +0 -0
- data/test/support/rails_app/config/database.yml +5 -0
- data/test/support/{app → rails_app}/config/initializers/devise.rb +1 -4
- data/test/support/{app → rails_app}/config/routes.rb +0 -0
- data/test/support/{app → rails_app}/db/schema.rb +0 -0
- data/test/test_helper.rb +13 -10
- metadata +43 -41
- data/lib/devise_async.rb +0 -18
- data/lib/devise_async/backend.rb +0 -9
- data/lib/devise_async/backend/delayed_job.rb +0 -14
- data/lib/devise_async/backend/resque.rb +0 -17
- data/lib/devise_async/backend/sidekiq.rb +0 -18
- data/lib/devise_async/proxy.rb +0 -16
- data/lib/devise_async/version.rb +0 -3
- data/lib/devise_async/worker.rb +0 -13
- data/test/backend/delayed_job_test.rb +0 -22
- data/test/backend/resque_test.rb +0 -19
- data/test/backend/sidekiq_test.rb +0 -19
- data/test/backend_test.rb +0 -23
- data/test/proxy_test.rb +0 -11
- data/test/support/app/config/database.yml +0 -6
- data/test/worker_test.rb +0 -26
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Devise Async
|
1
|
+
# Devise Async [![Build Status](https://secure.travis-ci.org/mhfs/devise-async.png)](http://travis-ci.org/mhfs/devise-async)
|
2
2
|
|
3
3
|
Devise Async provides an easy way to configure Devise to send its emails asynchronously using your preferred queuing backend.
|
4
4
|
|
@@ -12,7 +12,9 @@ Supported backends:
|
|
12
12
|
|
13
13
|
Add this line to your application's Gemfile:
|
14
14
|
|
15
|
-
|
15
|
+
```ruby
|
16
|
+
gem 'devise-async'
|
17
|
+
```
|
16
18
|
|
17
19
|
And then execute:
|
18
20
|
|
@@ -24,15 +26,19 @@ Or install it yourself as:
|
|
24
26
|
|
25
27
|
## Usage
|
26
28
|
|
27
|
-
Set `
|
29
|
+
Set `Devise::Async::Proxy` as Devise's mailer in `config/initializers/devise.rb`:
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
+
```ruby
|
32
|
+
# Configure the class responsible to send e-mails.
|
33
|
+
config.mailer = "Devise::Async::Proxy"
|
34
|
+
```
|
31
35
|
|
32
36
|
Set your queuing backend by creating `config/initializers/devise_async.rb`:
|
33
37
|
|
34
|
-
|
35
|
-
|
38
|
+
```ruby
|
39
|
+
# Supported options: :resque, :sidekiq, :delayed_job
|
40
|
+
Devise::Async.backend = :resque
|
41
|
+
```
|
36
42
|
|
37
43
|
Tip: it defaults to Resque. You don't need to create the initializer if using it.
|
38
44
|
|
data/devise-async.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/
|
2
|
+
require File.expand_path('../lib/devise/async/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Marcelo Silveira"]
|
@@ -13,17 +13,17 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.name = "devise-async"
|
15
15
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version =
|
16
|
+
gem.version = Devise::Async::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency "devise"
|
18
|
+
gem.add_dependency "devise", ">= 1.1"
|
19
19
|
|
20
|
-
gem.add_development_dependency "activerecord",
|
21
|
-
gem.add_development_dependency "actionpack",
|
22
|
-
gem.add_development_dependency "actionmailer",
|
23
|
-
gem.add_development_dependency "
|
24
|
-
gem.add_development_dependency "resque",
|
25
|
-
gem.add_development_dependency "sidekiq",
|
20
|
+
gem.add_development_dependency "activerecord", "~> 3.2"
|
21
|
+
gem.add_development_dependency "actionpack", "~> 3.2"
|
22
|
+
gem.add_development_dependency "actionmailer", "~> 3.2"
|
23
|
+
gem.add_development_dependency "sqlite3", "~> 1.3"
|
24
|
+
gem.add_development_dependency "resque", "~> 1.20"
|
25
|
+
gem.add_development_dependency "sidekiq", "~> 1.2"
|
26
26
|
gem.add_development_dependency "delayed_job_active_record", "~> 0.3"
|
27
|
-
gem.add_development_dependency "mocha",
|
28
|
-
gem.add_development_dependency "minitest",
|
27
|
+
gem.add_development_dependency "mocha", "~> 0.11"
|
28
|
+
gem.add_development_dependency "minitest", "~> 3.0"
|
29
29
|
end
|
data/lib/devise-async.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require "
|
1
|
+
require "devise/async"
|
data/lib/devise/async.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "active_support/dependencies"
|
2
|
+
require "devise/async/version"
|
3
|
+
|
4
|
+
module Devise
|
5
|
+
module Async
|
6
|
+
autoload :Proxy, "devise/async/proxy"
|
7
|
+
autoload :Worker, "devise/async/worker"
|
8
|
+
autoload :Backend, "devise/async/backend"
|
9
|
+
|
10
|
+
module Backend
|
11
|
+
autoload :Base, "devise/async/backend/base"
|
12
|
+
autoload :Resque, "devise/async/backend/resque"
|
13
|
+
autoload :Sidekiq, "devise/async/backend/sidekiq"
|
14
|
+
autoload :DelayedJob, "devise/async/backend/delayed_job"
|
15
|
+
end
|
16
|
+
|
17
|
+
# Defines the queue backend to be used. Resque by default.
|
18
|
+
mattr_accessor :backend
|
19
|
+
@@backend = :resque
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Just to be compatible with first release
|
24
|
+
# TODO remove when appropriate
|
25
|
+
module DeviseAsync
|
26
|
+
class Proxy < Devise::Async::Proxy
|
27
|
+
def initialize(method, resource)
|
28
|
+
puts "DEPRECATION WARNING: DeviseAsync::Proxy has been deprecated. Please use Devise::Async::Proxy."
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Devise
|
2
|
+
module Async
|
3
|
+
module Backend
|
4
|
+
class Base
|
5
|
+
def self.enqueue(*args)
|
6
|
+
raise NotImplementedError, "Any DeviseAssync::Backend subclass should implement `self.enqueue`."
|
7
|
+
end
|
8
|
+
|
9
|
+
def perform(method, resource_class, resource_id)
|
10
|
+
resource = resource_class.constantize.find(resource_id)
|
11
|
+
Devise::Mailer.send(method, resource).deliver
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Devise
|
2
|
+
module Async
|
3
|
+
module Backend
|
4
|
+
class Resque < Base
|
5
|
+
@queue = :mailer
|
6
|
+
|
7
|
+
def self.enqueue(*args)
|
8
|
+
args.unshift(self)
|
9
|
+
::Resque.enqueue(*args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.perform(method, resource_class, resource_id)
|
13
|
+
new.perform(method, resource_class, resource_id)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Devise
|
2
|
+
module Async
|
3
|
+
class Proxy
|
4
|
+
# catches all devise emails
|
5
|
+
def self.method_missing(method, *args, &block)
|
6
|
+
new(method, args.first)
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(method, resource)
|
10
|
+
@method, @resource = method, resource
|
11
|
+
end
|
12
|
+
|
13
|
+
def deliver
|
14
|
+
Worker.enqueue(@method, @resource.class.name, @resource.id)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Devise
|
2
|
+
module Async
|
3
|
+
class Worker
|
4
|
+
def self.enqueue(method, resource_class, resource_id)
|
5
|
+
backend_class.enqueue(method, resource_class, resource_id)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def self.backend_class
|
11
|
+
Backend.for(Devise::Async.backend)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Devise
|
4
|
+
module Async
|
5
|
+
module Backend
|
6
|
+
describe "DelayedJob" do
|
7
|
+
it "enqueues job" do
|
8
|
+
delayed_instance = mock()
|
9
|
+
delayed_instance.expects(:perform).once.with(:mailer_method, "User", 123)
|
10
|
+
DelayedJob.any_instance.expects(:delay).once.returns(delayed_instance)
|
11
|
+
|
12
|
+
DelayedJob.enqueue(:mailer_method, "User", 123)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "delegates to devise mailer when delivering" do
|
16
|
+
user = create_user
|
17
|
+
ActionMailer::Base.deliveries = []
|
18
|
+
Backend::DelayedJob.new.perform(:confirmation_instructions, "User", user.id)
|
19
|
+
ActionMailer::Base.deliveries.size.must_equal 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Devise
|
4
|
+
module Async
|
5
|
+
module Backend
|
6
|
+
describe "Resque" do
|
7
|
+
it "enqueues job" do
|
8
|
+
::Resque.expects(:enqueue).with(Resque, :mailer_method, "User", 123)
|
9
|
+
Resque.enqueue(:mailer_method, "User", 123)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "delegates to devise mailer when delivering" do
|
13
|
+
user = create_user
|
14
|
+
ActionMailer::Base.deliveries = []
|
15
|
+
Backend::Resque.perform(:confirmation_instructions, "User", user.id)
|
16
|
+
ActionMailer::Base.deliveries.size.must_equal 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Devise
|
4
|
+
module Async
|
5
|
+
module Backend
|
6
|
+
describe "Sidekiq" do
|
7
|
+
it "enqueues job" do
|
8
|
+
Sidekiq.expects(:perform_async).with(:mailer_method, "User", 123)
|
9
|
+
Sidekiq.enqueue(:mailer_method, "User", 123)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "delegates to devise mailer when delivering" do
|
13
|
+
user = create_user
|
14
|
+
ActionMailer::Base.deliveries = []
|
15
|
+
Backend::Sidekiq.new.perform(:confirmation_instructions, "User", user.id)
|
16
|
+
ActionMailer::Base.deliveries.size.must_equal 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Devise
|
4
|
+
module Async
|
5
|
+
describe "Backend" do
|
6
|
+
it "gives resque as the backend" do
|
7
|
+
Backend.for(:resque).must_equal Backend::Resque
|
8
|
+
end
|
9
|
+
|
10
|
+
it "gives sidekiq as the backend" do
|
11
|
+
Backend.for(:sidekiq).must_equal Backend::Sidekiq
|
12
|
+
end
|
13
|
+
|
14
|
+
it "gives delayed job as the backend" do
|
15
|
+
Backend.for(:delayed_job).must_equal Backend::DelayedJob
|
16
|
+
end
|
17
|
+
|
18
|
+
it "alerts about unsupported backend" do
|
19
|
+
assert_raises ArgumentError do
|
20
|
+
Backend.for(:unsupported_backend)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Devise
|
4
|
+
module Async
|
5
|
+
describe "Proxy" do
|
6
|
+
it "gets called by devise operations and proxy to worker" do
|
7
|
+
user = create_user
|
8
|
+
Worker.expects(:enqueue).with(:confirmation_instructions, "User", user.id)
|
9
|
+
user.send_confirmation_instructions
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
module Devise
|
4
|
+
module Async
|
5
|
+
describe "Worker" do
|
6
|
+
it "enqueues job using the resque backend" do
|
7
|
+
Devise::Async.backend = :resque
|
8
|
+
|
9
|
+
Backend::Resque.expects(:enqueue).with(:mailer_method, "User", 123)
|
10
|
+
Worker.enqueue(:mailer_method, "User", 123)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "enqueues job using the sidekiq backend" do
|
14
|
+
Devise::Async.backend = :sidekiq
|
15
|
+
|
16
|
+
Backend::Sidekiq.expects(:enqueue).with(:mailer_method, "User", 123)
|
17
|
+
Worker.enqueue(:mailer_method, "User", 123)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "enqueues job using the delayed job backend" do
|
21
|
+
Devise::Async.backend = :delayed_job
|
22
|
+
|
23
|
+
Backend::DelayedJob.expects(:enqueue).with(:mailer_method, "User", 123)
|
24
|
+
Worker.enqueue(:mailer_method, "User", 123)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
File without changes
|
@@ -7,7 +7,7 @@ Devise.setup do |config|
|
|
7
7
|
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
|
8
8
|
|
9
9
|
# Configure the class responsible to send e-mails.
|
10
|
-
config.mailer = "
|
10
|
+
config.mailer = "Devise::Async::Proxy"
|
11
11
|
|
12
12
|
# ==> ORM configuration
|
13
13
|
# Load and configure the ORM. Supports :active_record (default) and
|
@@ -213,7 +213,4 @@ Devise.setup do |config|
|
|
213
213
|
# manager.intercept_401 = false
|
214
214
|
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
215
215
|
# end
|
216
|
-
|
217
|
-
# FIXME remove as soon as deprecation stops
|
218
|
-
config.use_salt_as_remember_token = true
|
219
216
|
end
|
File without changes
|
File without changes
|
data/test/test_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require "minitest/spec"
|
|
5
5
|
require "minitest/mock"
|
6
6
|
require "mocha"
|
7
7
|
|
8
|
-
require "
|
8
|
+
require "devise/async"
|
9
9
|
require "rails/all"
|
10
10
|
require "devise"
|
11
11
|
require "resque"
|
@@ -14,16 +14,19 @@ require "delayed_job_active_record"
|
|
14
14
|
|
15
15
|
require "support/helpers"
|
16
16
|
|
17
|
-
|
17
|
+
# Silent schema load output
|
18
|
+
ActiveRecord::Migration.verbose = false
|
18
19
|
|
19
|
-
module
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
module Devise
|
21
|
+
module Async
|
22
|
+
class RailsApp < ::Rails::Application
|
23
|
+
config.root = File.dirname(__FILE__) + "/support/rails_app"
|
24
|
+
config.active_support.deprecation = :log
|
25
|
+
config.action_mailer.default_url_options = { :host => "localhost:3000" }
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
end
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
28
|
-
|
29
|
-
load File.dirname(__FILE__) + "/support/
|
31
|
+
Devise::Async::RailsApp.initialize!
|
32
|
+
load File.dirname(__FILE__) + "/support/rails_app/db/schema.rb"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '1.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '1.1'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: activerecord
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -76,13 +76,13 @@ dependencies:
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '3.2'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: sqlite3
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: '
|
85
|
+
version: '1.3'
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: '
|
93
|
+
version: '1.3'
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: resque
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,34 +179,36 @@ extensions: []
|
|
179
179
|
extra_rdoc_files: []
|
180
180
|
files:
|
181
181
|
- .gitignore
|
182
|
+
- .travis.yml
|
182
183
|
- Gemfile
|
183
184
|
- LICENSE
|
184
185
|
- README.md
|
185
186
|
- Rakefile
|
186
187
|
- devise-async.gemspec
|
187
188
|
- lib/devise-async.rb
|
188
|
-
- lib/
|
189
|
-
- lib/
|
190
|
-
- lib/
|
191
|
-
- lib/
|
192
|
-
- lib/
|
193
|
-
- lib/
|
194
|
-
- lib/
|
195
|
-
- lib/
|
196
|
-
-
|
197
|
-
- test/backend/
|
198
|
-
- test/backend/
|
199
|
-
- test/
|
200
|
-
- test/
|
201
|
-
- test/
|
202
|
-
- test/
|
203
|
-
- test/support/app/config/initializers/devise.rb
|
204
|
-
- test/support/app/config/routes.rb
|
205
|
-
- test/support/app/db/schema.rb
|
206
|
-
- test/support/app/log/development.log
|
189
|
+
- lib/devise/async.rb
|
190
|
+
- lib/devise/async/backend.rb
|
191
|
+
- lib/devise/async/backend/base.rb
|
192
|
+
- lib/devise/async/backend/delayed_job.rb
|
193
|
+
- lib/devise/async/backend/resque.rb
|
194
|
+
- lib/devise/async/backend/sidekiq.rb
|
195
|
+
- lib/devise/async/proxy.rb
|
196
|
+
- lib/devise/async/version.rb
|
197
|
+
- lib/devise/async/worker.rb
|
198
|
+
- test/devise/async/backend/delayed_job_test.rb
|
199
|
+
- test/devise/async/backend/resque_test.rb
|
200
|
+
- test/devise/async/backend/sidekiq_test.rb
|
201
|
+
- test/devise/async/backend_test.rb
|
202
|
+
- test/devise/async/proxy_test.rb
|
203
|
+
- test/devise/async/worker_test.rb
|
207
204
|
- test/support/helpers.rb
|
205
|
+
- test/support/rails_app/app/models/user.rb
|
206
|
+
- test/support/rails_app/config/database.yml
|
207
|
+
- test/support/rails_app/config/initializers/devise.rb
|
208
|
+
- test/support/rails_app/config/routes.rb
|
209
|
+
- test/support/rails_app/db/schema.rb
|
210
|
+
- test/support/rails_app/log/development.log
|
208
211
|
- test/test_helper.rb
|
209
|
-
- test/worker_test.rb
|
210
212
|
homepage: https://github.com/mhfs/devise-async/
|
211
213
|
licenses: []
|
212
214
|
post_install_message:
|
@@ -221,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
223
|
version: '0'
|
222
224
|
segments:
|
223
225
|
- 0
|
224
|
-
hash:
|
226
|
+
hash: 198489558210198293
|
225
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
228
|
none: false
|
227
229
|
requirements:
|
@@ -230,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
232
|
version: '0'
|
231
233
|
segments:
|
232
234
|
- 0
|
233
|
-
hash:
|
235
|
+
hash: 198489558210198293
|
234
236
|
requirements: []
|
235
237
|
rubyforge_project:
|
236
238
|
rubygems_version: 1.8.23
|
@@ -240,17 +242,17 @@ summary: Devise Async provides an easy way to configure Devise to send its email
|
|
240
242
|
asynchronously using your preferred queuing backend. It supports Resque, Sidekiq
|
241
243
|
and Delayed::Job.
|
242
244
|
test_files:
|
243
|
-
- test/backend/delayed_job_test.rb
|
244
|
-
- test/backend/resque_test.rb
|
245
|
-
- test/backend/sidekiq_test.rb
|
246
|
-
- test/backend_test.rb
|
247
|
-
- test/proxy_test.rb
|
248
|
-
- test/
|
249
|
-
- test/support/app/config/database.yml
|
250
|
-
- test/support/app/config/initializers/devise.rb
|
251
|
-
- test/support/app/config/routes.rb
|
252
|
-
- test/support/app/db/schema.rb
|
253
|
-
- test/support/app/log/development.log
|
245
|
+
- test/devise/async/backend/delayed_job_test.rb
|
246
|
+
- test/devise/async/backend/resque_test.rb
|
247
|
+
- test/devise/async/backend/sidekiq_test.rb
|
248
|
+
- test/devise/async/backend_test.rb
|
249
|
+
- test/devise/async/proxy_test.rb
|
250
|
+
- test/devise/async/worker_test.rb
|
254
251
|
- test/support/helpers.rb
|
252
|
+
- test/support/rails_app/app/models/user.rb
|
253
|
+
- test/support/rails_app/config/database.yml
|
254
|
+
- test/support/rails_app/config/initializers/devise.rb
|
255
|
+
- test/support/rails_app/config/routes.rb
|
256
|
+
- test/support/rails_app/db/schema.rb
|
257
|
+
- test/support/rails_app/log/development.log
|
255
258
|
- test/test_helper.rb
|
256
|
-
- test/worker_test.rb
|
data/lib/devise_async.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require "active_support/dependencies"
|
2
|
-
require "devise_async/version"
|
3
|
-
|
4
|
-
module DeviseAsync
|
5
|
-
autoload :Proxy, "devise_async/proxy"
|
6
|
-
autoload :Worker, "devise_async/worker"
|
7
|
-
autoload :Backend, "devise_async/backend"
|
8
|
-
|
9
|
-
module Backend
|
10
|
-
autoload :Resque, "devise_async/backend/resque"
|
11
|
-
autoload :Sidekiq, "devise_async/backend/sidekiq"
|
12
|
-
autoload :DelayedJob, "devise_async/backend/delayed_job"
|
13
|
-
end
|
14
|
-
|
15
|
-
# Defines the queue backend to be used. Resque by default.
|
16
|
-
mattr_accessor :backend
|
17
|
-
@@backend = :resque
|
18
|
-
end
|
data/lib/devise_async/backend.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module DeviseAsync
|
2
|
-
module Backend
|
3
|
-
class DelayedJob
|
4
|
-
def self.enqueue(*args)
|
5
|
-
new.delay.perform(*args)
|
6
|
-
end
|
7
|
-
|
8
|
-
def perform(method, resource_class, resource_id)
|
9
|
-
resource = resource_class.constantize.find(resource_id)
|
10
|
-
Devise::Mailer.send(method, resource).deliver
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module DeviseAsync
|
2
|
-
module Backend
|
3
|
-
class Resque
|
4
|
-
@queue = :mailer
|
5
|
-
|
6
|
-
def self.enqueue(*args)
|
7
|
-
args.unshift(self)
|
8
|
-
::Resque.enqueue(*args)
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.perform(method, resource_class, resource_id)
|
12
|
-
resource = resource_class.constantize.find(resource_id)
|
13
|
-
Devise::Mailer.send(method, resource).deliver
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module DeviseAsync
|
2
|
-
module Backend
|
3
|
-
class Sidekiq
|
4
|
-
include ::Sidekiq::Worker
|
5
|
-
|
6
|
-
sidekiq_options :queue => :mailer
|
7
|
-
|
8
|
-
def self.enqueue(*args)
|
9
|
-
perform_async(*args)
|
10
|
-
end
|
11
|
-
|
12
|
-
def perform(method, resource_class, resource_id)
|
13
|
-
resource = resource_class.constantize.find(resource_id)
|
14
|
-
Devise::Mailer.send(method, resource).deliver
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/devise_async/proxy.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module DeviseAsync
|
2
|
-
class Proxy
|
3
|
-
# catches all devise emails
|
4
|
-
def self.method_missing(method, *args, &block)
|
5
|
-
new(method, args.first)
|
6
|
-
end
|
7
|
-
|
8
|
-
def initialize(method, resource)
|
9
|
-
@method, @resource = method, resource
|
10
|
-
end
|
11
|
-
|
12
|
-
def deliver
|
13
|
-
Worker.enqueue(@method, @resource.class.name, @resource.id)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/lib/devise_async/version.rb
DELETED
data/lib/devise_async/worker.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
module DeviseAsync
|
4
|
-
module Backend
|
5
|
-
describe "DelayedJob" do
|
6
|
-
it "enqueues job" do
|
7
|
-
delayed_instance = mock()
|
8
|
-
delayed_instance.expects(:perform).once.with(:mailer_method, "User", 123)
|
9
|
-
DelayedJob.any_instance.expects(:delay).once.returns(delayed_instance)
|
10
|
-
|
11
|
-
DelayedJob.enqueue(:mailer_method, "User", 123)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "delegates to devise mailer when delivering" do
|
15
|
-
user = create_user
|
16
|
-
ActionMailer::Base.deliveries = []
|
17
|
-
Backend::DelayedJob.new.perform(:confirmation_instructions, "User", user.id)
|
18
|
-
ActionMailer::Base.deliveries.size.must_equal 1
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/test/backend/resque_test.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
module DeviseAsync
|
4
|
-
module Backend
|
5
|
-
describe "Resque" do
|
6
|
-
it "enqueues job" do
|
7
|
-
::Resque.expects(:enqueue).with(Resque, :mailer_method, "User", 123)
|
8
|
-
Resque.enqueue(:mailer_method, "User", 123)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "delegates to devise mailer when delivering" do
|
12
|
-
user = create_user
|
13
|
-
ActionMailer::Base.deliveries = []
|
14
|
-
Backend::Resque.perform(:confirmation_instructions, "User", user.id)
|
15
|
-
ActionMailer::Base.deliveries.size.must_equal 1
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
module DeviseAsync
|
4
|
-
module Backend
|
5
|
-
describe "Sidekiq" do
|
6
|
-
it "enqueues job" do
|
7
|
-
Sidekiq.expects(:perform_async).with(:mailer_method, "User", 123)
|
8
|
-
Sidekiq.enqueue(:mailer_method, "User", 123)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "delegates to devise mailer when delivering" do
|
12
|
-
user = create_user
|
13
|
-
ActionMailer::Base.deliveries = []
|
14
|
-
Backend::Sidekiq.new.perform(:confirmation_instructions, "User", user.id)
|
15
|
-
ActionMailer::Base.deliveries.size.must_equal 1
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/test/backend_test.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
module DeviseAsync
|
4
|
-
describe "Backend" do
|
5
|
-
it "gives resque as the backend" do
|
6
|
-
Backend.for(:resque).must_equal Backend::Resque
|
7
|
-
end
|
8
|
-
|
9
|
-
it "gives sidekiq as the backend" do
|
10
|
-
Backend.for(:sidekiq).must_equal Backend::Sidekiq
|
11
|
-
end
|
12
|
-
|
13
|
-
it "gives delayed job as the backend" do
|
14
|
-
Backend.for(:delayed_job).must_equal Backend::DelayedJob
|
15
|
-
end
|
16
|
-
|
17
|
-
it "alerts about unsupported backend" do
|
18
|
-
assert_raises ArgumentError do
|
19
|
-
Backend.for(:unsupported_backend)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/test/proxy_test.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
module DeviseAsync
|
4
|
-
describe "Proxy" do
|
5
|
-
it "gets called by devise operations and proxy to worker" do
|
6
|
-
user = create_user
|
7
|
-
Worker.expects(:enqueue).with(:confirmation_instructions, "User", user.id)
|
8
|
-
user.send_confirmation_instructions
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
data/test/worker_test.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
module DeviseAsync
|
4
|
-
describe "Worker" do
|
5
|
-
it "enqueues job using the resque backend" do
|
6
|
-
DeviseAsync.backend = :resque
|
7
|
-
|
8
|
-
Backend::Resque.expects(:enqueue).with(:mailer_method, "User", 123)
|
9
|
-
Worker.enqueue(:mailer_method, "User", 123)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "enqueues job using the sidekiq backend" do
|
13
|
-
DeviseAsync.backend = :sidekiq
|
14
|
-
|
15
|
-
Backend::Sidekiq.expects(:enqueue).with(:mailer_method, "User", 123)
|
16
|
-
Worker.enqueue(:mailer_method, "User", 123)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "enqueues job using the delayed job backend" do
|
20
|
-
DeviseAsync.backend = :delayed_job
|
21
|
-
|
22
|
-
Backend::DelayedJob.expects(:enqueue).with(:mailer_method, "User", 123)
|
23
|
-
Worker.enqueue(:mailer_method, "User", 123)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|