devise-async 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +0 -1
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +144 -0
- data/README.md +12 -1
- data/devise-async.gemspec +5 -4
- data/lib/devise/async.rb +1 -0
- data/lib/devise/async/backend/base.rb +3 -3
- data/lib/devise/async/backend/queue_classic.rb +2 -2
- data/lib/devise/async/backend/resque.rb +2 -2
- data/lib/devise/async/backend/torquebox.rb +14 -0
- data/lib/devise/async/model.rb +5 -5
- data/lib/devise/async/version.rb +1 -1
- data/lib/devise/async/worker.rb +21 -4
- data/test/devise/async/backend/torquebox_test.rb +21 -0
- data/test/devise/async/model_test.rb +27 -5
- data/test/support/rails_app/config/initializers/devise.rb +2 -0
- data/test/support/test_helpers.rb +30 -0
- data/test/test_helper.rb +4 -1
- metadata +38 -12
- data/test/support/helpers.rb +0 -28
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
## Unreleased
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
* Support arbitrary number of arguments to mailer (glebm)
|
|
6
|
+
* Added torquebox support (astjohn)
|
|
7
|
+
|
|
3
8
|
## 0.7.0
|
|
4
9
|
|
|
5
10
|
* make sure options hash has string keys when enqueued and symbol keys when job runs
|
|
6
11
|
* stringfy options keys before enqueueing to make queue_classic happy (nickw)
|
|
7
|
-
* Added `
|
|
12
|
+
* Added `Devise::Async.enabled=` options to make it easier to skip async processing during tests (mohamedmagdy)
|
|
8
13
|
|
|
9
14
|
## 0.6.0
|
|
10
15
|
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
devise-async (0.8.0)
|
|
5
|
+
devise (>= 2.2, < 3.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
actionmailer (3.2.14)
|
|
11
|
+
actionpack (= 3.2.14)
|
|
12
|
+
mail (~> 2.5.4)
|
|
13
|
+
actionpack (3.2.14)
|
|
14
|
+
activemodel (= 3.2.14)
|
|
15
|
+
activesupport (= 3.2.14)
|
|
16
|
+
builder (~> 3.0.0)
|
|
17
|
+
erubis (~> 2.7.0)
|
|
18
|
+
journey (~> 1.0.4)
|
|
19
|
+
rack (~> 1.4.5)
|
|
20
|
+
rack-cache (~> 1.2)
|
|
21
|
+
rack-test (~> 0.6.1)
|
|
22
|
+
sprockets (~> 2.2.1)
|
|
23
|
+
activemodel (3.2.14)
|
|
24
|
+
activesupport (= 3.2.14)
|
|
25
|
+
builder (~> 3.0.0)
|
|
26
|
+
activerecord (3.2.14)
|
|
27
|
+
activemodel (= 3.2.14)
|
|
28
|
+
activesupport (= 3.2.14)
|
|
29
|
+
arel (~> 3.0.2)
|
|
30
|
+
tzinfo (~> 0.3.29)
|
|
31
|
+
activesupport (3.2.14)
|
|
32
|
+
i18n (~> 0.6, >= 0.6.4)
|
|
33
|
+
multi_json (~> 1.0)
|
|
34
|
+
arel (3.0.2)
|
|
35
|
+
atomic (1.1.13)
|
|
36
|
+
bcrypt-ruby (3.1.2)
|
|
37
|
+
builder (3.0.4)
|
|
38
|
+
celluloid (0.10.0)
|
|
39
|
+
connection_pool (0.9.3)
|
|
40
|
+
delayed_job (3.0.4)
|
|
41
|
+
activesupport (~> 3.0)
|
|
42
|
+
delayed_job_active_record (0.4.4)
|
|
43
|
+
activerecord (>= 2.1.0, < 4)
|
|
44
|
+
delayed_job (~> 3.0)
|
|
45
|
+
devise (3.1.0)
|
|
46
|
+
bcrypt-ruby (~> 3.0)
|
|
47
|
+
orm_adapter (~> 0.1)
|
|
48
|
+
railties (>= 3.2.6, < 5)
|
|
49
|
+
thread_safe (~> 0.1)
|
|
50
|
+
warden (~> 1.2.3)
|
|
51
|
+
erubis (2.7.0)
|
|
52
|
+
hike (1.2.3)
|
|
53
|
+
i18n (0.6.5)
|
|
54
|
+
journey (1.0.4)
|
|
55
|
+
json (1.8.0)
|
|
56
|
+
mail (2.5.4)
|
|
57
|
+
mime-types (~> 1.16)
|
|
58
|
+
treetop (~> 1.4.8)
|
|
59
|
+
metaclass (0.0.1)
|
|
60
|
+
mime-types (1.25)
|
|
61
|
+
minitest (3.5.0)
|
|
62
|
+
mocha (0.14.0)
|
|
63
|
+
metaclass (~> 0.0.1)
|
|
64
|
+
mono_logger (1.1.0)
|
|
65
|
+
multi_json (1.8.0)
|
|
66
|
+
orm_adapter (0.4.0)
|
|
67
|
+
pg (0.16.0)
|
|
68
|
+
polyglot (0.3.3)
|
|
69
|
+
queue_classic (2.2.2)
|
|
70
|
+
pg (~> 0.16.0)
|
|
71
|
+
rack (1.4.5)
|
|
72
|
+
rack-cache (1.2)
|
|
73
|
+
rack (>= 0.4)
|
|
74
|
+
rack-protection (1.5.0)
|
|
75
|
+
rack
|
|
76
|
+
rack-ssl (1.3.3)
|
|
77
|
+
rack
|
|
78
|
+
rack-test (0.6.2)
|
|
79
|
+
rack (>= 1.0)
|
|
80
|
+
railties (3.2.14)
|
|
81
|
+
actionpack (= 3.2.14)
|
|
82
|
+
activesupport (= 3.2.14)
|
|
83
|
+
rack-ssl (~> 1.3.2)
|
|
84
|
+
rake (>= 0.8.7)
|
|
85
|
+
rdoc (~> 3.4)
|
|
86
|
+
thor (>= 0.14.6, < 2.0)
|
|
87
|
+
rake (10.1.0)
|
|
88
|
+
rdoc (3.12.2)
|
|
89
|
+
json (~> 1.4)
|
|
90
|
+
redis (3.0.4)
|
|
91
|
+
redis-namespace (1.3.1)
|
|
92
|
+
redis (~> 3.0.0)
|
|
93
|
+
resque (1.24.1)
|
|
94
|
+
mono_logger (~> 1.0)
|
|
95
|
+
multi_json (~> 1.0)
|
|
96
|
+
redis-namespace (~> 1.2)
|
|
97
|
+
sinatra (>= 0.9.2)
|
|
98
|
+
vegas (~> 0.1.2)
|
|
99
|
+
sidekiq (1.2.1)
|
|
100
|
+
celluloid (~> 0.10.0)
|
|
101
|
+
connection_pool (~> 0.9.0)
|
|
102
|
+
multi_json (~> 1)
|
|
103
|
+
redis
|
|
104
|
+
redis-namespace
|
|
105
|
+
sinatra (1.4.3)
|
|
106
|
+
rack (~> 1.4)
|
|
107
|
+
rack-protection (~> 1.4)
|
|
108
|
+
tilt (~> 1.3, >= 1.3.4)
|
|
109
|
+
sprockets (2.2.2)
|
|
110
|
+
hike (~> 1.2)
|
|
111
|
+
multi_json (~> 1.0)
|
|
112
|
+
rack (~> 1.0)
|
|
113
|
+
tilt (~> 1.1, != 1.3.0)
|
|
114
|
+
sqlite3 (1.3.8)
|
|
115
|
+
thor (0.18.1)
|
|
116
|
+
thread_safe (0.1.2)
|
|
117
|
+
atomic
|
|
118
|
+
tilt (1.4.1)
|
|
119
|
+
torquebox-no-op (2.3.2)
|
|
120
|
+
treetop (1.4.15)
|
|
121
|
+
polyglot
|
|
122
|
+
polyglot (>= 0.3.1)
|
|
123
|
+
tzinfo (0.3.37)
|
|
124
|
+
vegas (0.1.11)
|
|
125
|
+
rack (>= 1.0.0)
|
|
126
|
+
warden (1.2.3)
|
|
127
|
+
rack (>= 1.0)
|
|
128
|
+
|
|
129
|
+
PLATFORMS
|
|
130
|
+
ruby
|
|
131
|
+
|
|
132
|
+
DEPENDENCIES
|
|
133
|
+
actionmailer (>= 3.2)
|
|
134
|
+
actionpack (>= 3.2)
|
|
135
|
+
activerecord (>= 3.2)
|
|
136
|
+
delayed_job_active_record (~> 0.3)
|
|
137
|
+
devise-async!
|
|
138
|
+
minitest (~> 3.0)
|
|
139
|
+
mocha (~> 0.11)
|
|
140
|
+
queue_classic (~> 2.0)
|
|
141
|
+
resque (~> 1.20)
|
|
142
|
+
sidekiq (~> 1.2)
|
|
143
|
+
sqlite3 (~> 1.3)
|
|
144
|
+
torquebox-no-op (~> 2.3)
|
data/README.md
CHANGED
|
@@ -8,6 +8,7 @@ Supported backends:
|
|
|
8
8
|
* Sidekiq
|
|
9
9
|
* Delayed::Job
|
|
10
10
|
* QueueClassic
|
|
11
|
+
* Torquebox
|
|
11
12
|
|
|
12
13
|
## Installation
|
|
13
14
|
|
|
@@ -38,7 +39,7 @@ end
|
|
|
38
39
|
Set your queuing backend by creating `config/initializers/devise_async.rb`:
|
|
39
40
|
|
|
40
41
|
```ruby
|
|
41
|
-
# Supported options: :resque, :sidekiq, :delayed_job, :queue_classic
|
|
42
|
+
# Supported options: :resque, :sidekiq, :delayed_job, :queue_classic, :torquebox
|
|
42
43
|
Devise::Async.backend = :resque
|
|
43
44
|
```
|
|
44
45
|
|
|
@@ -46,6 +47,15 @@ Tip: it defaults to Resque. You don't need to create the initializer if using it
|
|
|
46
47
|
|
|
47
48
|
## Advanced Options
|
|
48
49
|
|
|
50
|
+
### Enabling via config
|
|
51
|
+
|
|
52
|
+
The gem can be enabled/disabled easily via config, for example based on environment.
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
# config/initializers/devise_async.rb
|
|
56
|
+
Devise::Async.enabled = true # | false
|
|
57
|
+
```
|
|
58
|
+
|
|
49
59
|
### Custom mailer class
|
|
50
60
|
|
|
51
61
|
Customize `Devise.mailer` at will and `devise-async` will honor it.
|
|
@@ -71,6 +81,7 @@ similar do what `Devise` offers.
|
|
|
71
81
|
```ruby
|
|
72
82
|
# config/initializers/devise_async.rb
|
|
73
83
|
Devise::Async.setup do |config|
|
|
84
|
+
config.enabled = true
|
|
74
85
|
config.backend = :resque
|
|
75
86
|
config.queue = :my_custom_queue
|
|
76
87
|
end
|
data/devise-async.gemspec
CHANGED
|
@@ -15,11 +15,11 @@ Gem::Specification.new do |gem|
|
|
|
15
15
|
gem.require_paths = ["lib"]
|
|
16
16
|
gem.version = Devise::Async::VERSION
|
|
17
17
|
|
|
18
|
-
gem.add_dependency "devise", ">= 2.2"
|
|
18
|
+
gem.add_dependency "devise", ">= 2.2", "< 3.2"
|
|
19
19
|
|
|
20
|
-
gem.add_development_dependency "activerecord", "
|
|
21
|
-
gem.add_development_dependency "actionpack", "
|
|
22
|
-
gem.add_development_dependency "actionmailer", "
|
|
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
23
|
gem.add_development_dependency "sqlite3", "~> 1.3"
|
|
24
24
|
gem.add_development_dependency "resque", "~> 1.20"
|
|
25
25
|
gem.add_development_dependency "sidekiq", "~> 1.2"
|
|
@@ -27,4 +27,5 @@ Gem::Specification.new do |gem|
|
|
|
27
27
|
gem.add_development_dependency "queue_classic", "~> 2.0"
|
|
28
28
|
gem.add_development_dependency "mocha", "~> 0.11"
|
|
29
29
|
gem.add_development_dependency "minitest", "~> 3.0"
|
|
30
|
+
gem.add_development_dependency "torquebox-no-op", "~> 2.3"
|
|
30
31
|
end
|
data/lib/devise/async.rb
CHANGED
|
@@ -13,6 +13,7 @@ module Devise
|
|
|
13
13
|
autoload :Sidekiq, "devise/async/backend/sidekiq"
|
|
14
14
|
autoload :DelayedJob, "devise/async/backend/delayed_job"
|
|
15
15
|
autoload :QueueClassic, "devise/async/backend/queue_classic"
|
|
16
|
+
autoload :Torquebox, "devise/async/backend/torquebox"
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
# Defines the queue backend to be used. Resque by default.
|
|
@@ -10,10 +10,10 @@ module Devise
|
|
|
10
10
|
#
|
|
11
11
|
# It uses `orm_adapter` API to fetch the record in order to enforce
|
|
12
12
|
# compatibility among diferent ORMs.
|
|
13
|
-
def perform(method, resource_class, resource_id,
|
|
13
|
+
def perform(method, resource_class, resource_id, *args)
|
|
14
14
|
resource = resource_class.constantize.to_adapter.get!(resource_id)
|
|
15
|
-
|
|
16
|
-
mailer_class.send(method, resource,
|
|
15
|
+
args[-1] = args.last.symbolize_keys if args.last.is_a?(Hash)
|
|
16
|
+
mailer_class.send(method, resource, *args).deliver
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
private
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Devise
|
|
2
|
+
module Async
|
|
3
|
+
module Backend
|
|
4
|
+
class Torquebox < Base
|
|
5
|
+
include ::TorqueBox::Messaging::Backgroundable
|
|
6
|
+
always_background :perform
|
|
7
|
+
|
|
8
|
+
def self.enqueue(*args)
|
|
9
|
+
new.perform(*args) # using always_background
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/devise/async/model.rb
CHANGED
|
@@ -24,26 +24,26 @@ module Devise
|
|
|
24
24
|
# to capture all email notifications and enqueue it for background
|
|
25
25
|
# processing instead of sending it inline as devise does by
|
|
26
26
|
# default.
|
|
27
|
-
def send_devise_notification(notification,
|
|
27
|
+
def send_devise_notification(notification, *args)
|
|
28
28
|
return super unless Devise::Async.enabled
|
|
29
29
|
|
|
30
30
|
# If the record is dirty we keep pending notifications to be enqueued
|
|
31
31
|
# by the callback and avoid before commit job processing.
|
|
32
32
|
if changed?
|
|
33
|
-
devise_pending_notifications << [ notification,
|
|
33
|
+
devise_pending_notifications << [ notification, args ]
|
|
34
34
|
# If the record isn't dirty (aka has already been saved) enqueue right away
|
|
35
35
|
# because the callback has already been triggered.
|
|
36
36
|
else
|
|
37
|
-
Devise::Async::Worker.enqueue(notification, self.class.name, self.id.to_s,
|
|
37
|
+
Devise::Async::Worker.enqueue(notification, self.class.name, self.id.to_s, *args)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# Send all pending notifications.
|
|
42
42
|
def send_devise_pending_notifications
|
|
43
|
-
devise_pending_notifications.each do |notification,
|
|
43
|
+
devise_pending_notifications.each do |notification, args|
|
|
44
44
|
# Use `id.to_s` to avoid problems with mongoid 2.4.X ids being serialized
|
|
45
45
|
# wrong with YAJL.
|
|
46
|
-
Devise::Async::Worker.enqueue(notification, self.class.name, self.id.to_s,
|
|
46
|
+
Devise::Async::Worker.enqueue(notification, self.class.name, self.id.to_s, *args)
|
|
47
47
|
end
|
|
48
48
|
@devise_pending_notifications = []
|
|
49
49
|
end
|
data/lib/devise/async/version.rb
CHANGED
data/lib/devise/async/worker.rb
CHANGED
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
module Devise
|
|
2
2
|
module Async
|
|
3
3
|
class Worker
|
|
4
|
+
class << self
|
|
5
|
+
|
|
4
6
|
# Used is the internal interface for devise-async to enqueue notifications
|
|
5
7
|
# to the desired backend.
|
|
6
|
-
def
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
def enqueue(method, resource_class, resource_id, *args)
|
|
9
|
+
# convert args to strings and hashes with string keys before passing to backend
|
|
10
|
+
args = stringify_args args
|
|
11
|
+
backend_class.enqueue(method, resource_class, resource_id, *args)
|
|
9
12
|
end
|
|
10
13
|
|
|
11
14
|
private
|
|
12
15
|
|
|
13
|
-
def
|
|
16
|
+
def stringify_args(args)
|
|
17
|
+
args.map do |a|
|
|
18
|
+
case a
|
|
19
|
+
when Hash
|
|
20
|
+
a.stringify_keys
|
|
21
|
+
when Symbol
|
|
22
|
+
a.to_s
|
|
23
|
+
else
|
|
24
|
+
a
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def backend_class
|
|
14
30
|
Backend.for(Devise::Async.backend)
|
|
15
31
|
end
|
|
32
|
+
end
|
|
16
33
|
end
|
|
17
34
|
end
|
|
18
35
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
module Devise
|
|
4
|
+
module Async
|
|
5
|
+
module Backend
|
|
6
|
+
describe "Torquebox" do
|
|
7
|
+
it "enqueues job" do
|
|
8
|
+
Torquebox.any_instance.expects(:perform).with(:mailer_method, "User", 123, {})
|
|
9
|
+
Torquebox.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::Torquebox.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
|
|
@@ -6,13 +6,19 @@ module Devise
|
|
|
6
6
|
it "accumulates notifications to be sent after commit on Model creation" do
|
|
7
7
|
Admin.transaction do
|
|
8
8
|
admin = create_admin
|
|
9
|
-
admin.send(:devise_pending_notifications)
|
|
9
|
+
mailers = admin.send(:devise_pending_notifications) # [:confirmation_instructions, ["RUQUib67wLcCiEyZMwfx", {}]]
|
|
10
|
+
mailers.size.must_equal 1
|
|
11
|
+
|
|
12
|
+
mailer = mailers.first
|
|
13
|
+
mailer.size.must_equal 2
|
|
14
|
+
mailer.first.must_equal :confirmation_instructions
|
|
15
|
+
mailer.last.must_be_instance_of Array
|
|
10
16
|
end
|
|
11
17
|
end
|
|
12
18
|
|
|
13
19
|
it "immediately sends notifications when the model has not changed" do
|
|
14
20
|
admin = create_admin
|
|
15
|
-
Worker.expects(:enqueue).with(:confirmation_instructions, "Admin", admin.id.to_s, {})
|
|
21
|
+
Worker.expects(:enqueue).with(:confirmation_instructions, "Admin", admin.id.to_s, instance_of(String), {})
|
|
16
22
|
admin.send_confirmation_instructions
|
|
17
23
|
end
|
|
18
24
|
|
|
@@ -21,7 +27,15 @@ module Devise
|
|
|
21
27
|
Admin.transaction do
|
|
22
28
|
admin[:username] = "changed_username"
|
|
23
29
|
admin.send_confirmation_instructions
|
|
24
|
-
|
|
30
|
+
|
|
31
|
+
mailers = admin.send(:devise_pending_notifications) # [:confirmation_instructions, ["RUQUib67wLcCiEyZMwfx", {}]]
|
|
32
|
+
mailers.size.must_equal 1
|
|
33
|
+
|
|
34
|
+
mailer = mailers.first
|
|
35
|
+
mailer.size.must_equal 2
|
|
36
|
+
mailer.first.must_equal :confirmation_instructions
|
|
37
|
+
mailer.last.must_be_instance_of Array
|
|
38
|
+
|
|
25
39
|
Worker.expects(:enqueue).never # after_commit will not fire without save
|
|
26
40
|
end
|
|
27
41
|
end
|
|
@@ -31,9 +45,17 @@ module Devise
|
|
|
31
45
|
Admin.transaction do
|
|
32
46
|
admin[:username] = "changed_username"
|
|
33
47
|
admin.send_confirmation_instructions
|
|
34
|
-
|
|
48
|
+
|
|
49
|
+
mailers = admin.send(:devise_pending_notifications) # [:confirmation_instructions, ["RUQUib67wLcCiEyZMwfx", {}]]
|
|
50
|
+
mailers.size.must_equal 1
|
|
51
|
+
|
|
52
|
+
mailer = mailers.first
|
|
53
|
+
mailer.size.must_equal 2
|
|
54
|
+
mailer.first.must_equal :confirmation_instructions
|
|
55
|
+
mailer.last.must_be_instance_of Array
|
|
56
|
+
|
|
35
57
|
admin.save
|
|
36
|
-
Worker.expects(:enqueue).with(:confirmation_instructions, "Admin", admin.id.to_s, {})
|
|
58
|
+
Worker.expects(:enqueue).with(:confirmation_instructions, "Admin", admin.id.to_s, instance_of(String), {})
|
|
37
59
|
end
|
|
38
60
|
end
|
|
39
61
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module TestHelpers
|
|
2
|
+
def valid_attributes(attributes={})
|
|
3
|
+
{ :username => "usertest",
|
|
4
|
+
:email => generate_unique_email,
|
|
5
|
+
:password => '12345678',
|
|
6
|
+
:password_confirmation => '12345678' }.update(attributes)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
email_count = 0
|
|
10
|
+
define_method :generate_unique_email do
|
|
11
|
+
email_count += 1
|
|
12
|
+
"test#{email_count}@example.com"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def new_user(attributes={})
|
|
16
|
+
User.new(valid_attributes(attributes))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def create_user(attributes={})
|
|
20
|
+
User.create!(valid_attributes(attributes))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def new_admin(attributes={})
|
|
24
|
+
Admin.new(valid_attributes(attributes))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def create_admin(attributes={})
|
|
28
|
+
Admin.create!(valid_attributes(attributes))
|
|
29
|
+
end
|
|
30
|
+
end
|
data/test/test_helper.rb
CHANGED
|
@@ -12,9 +12,12 @@ require "resque"
|
|
|
12
12
|
require "sidekiq"
|
|
13
13
|
require "delayed_job_active_record"
|
|
14
14
|
require "sidekiq/testing"
|
|
15
|
+
require "torquebox-no-op"
|
|
15
16
|
|
|
16
17
|
require "support/rails_app"
|
|
17
|
-
require "support/
|
|
18
|
+
require "support/test_helpers"
|
|
18
19
|
require "support/my_mailer"
|
|
19
20
|
|
|
21
|
+
include TestHelpers
|
|
22
|
+
|
|
20
23
|
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.
|
|
4
|
+
version: 0.8.0
|
|
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: 2013-
|
|
12
|
+
date: 2013-09-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: devise
|
|
@@ -19,6 +19,9 @@ dependencies:
|
|
|
19
19
|
- - ! '>='
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
21
|
version: '2.2'
|
|
22
|
+
- - <
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: '3.2'
|
|
22
25
|
type: :runtime
|
|
23
26
|
prerelease: false
|
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -27,12 +30,15 @@ dependencies:
|
|
|
27
30
|
- - ! '>='
|
|
28
31
|
- !ruby/object:Gem::Version
|
|
29
32
|
version: '2.2'
|
|
33
|
+
- - <
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '3.2'
|
|
30
36
|
- !ruby/object:Gem::Dependency
|
|
31
37
|
name: activerecord
|
|
32
38
|
requirement: !ruby/object:Gem::Requirement
|
|
33
39
|
none: false
|
|
34
40
|
requirements:
|
|
35
|
-
- -
|
|
41
|
+
- - ! '>='
|
|
36
42
|
- !ruby/object:Gem::Version
|
|
37
43
|
version: '3.2'
|
|
38
44
|
type: :development
|
|
@@ -40,7 +46,7 @@ dependencies:
|
|
|
40
46
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
47
|
none: false
|
|
42
48
|
requirements:
|
|
43
|
-
- -
|
|
49
|
+
- - ! '>='
|
|
44
50
|
- !ruby/object:Gem::Version
|
|
45
51
|
version: '3.2'
|
|
46
52
|
- !ruby/object:Gem::Dependency
|
|
@@ -48,7 +54,7 @@ dependencies:
|
|
|
48
54
|
requirement: !ruby/object:Gem::Requirement
|
|
49
55
|
none: false
|
|
50
56
|
requirements:
|
|
51
|
-
- -
|
|
57
|
+
- - ! '>='
|
|
52
58
|
- !ruby/object:Gem::Version
|
|
53
59
|
version: '3.2'
|
|
54
60
|
type: :development
|
|
@@ -56,7 +62,7 @@ dependencies:
|
|
|
56
62
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
63
|
none: false
|
|
58
64
|
requirements:
|
|
59
|
-
- -
|
|
65
|
+
- - ! '>='
|
|
60
66
|
- !ruby/object:Gem::Version
|
|
61
67
|
version: '3.2'
|
|
62
68
|
- !ruby/object:Gem::Dependency
|
|
@@ -64,7 +70,7 @@ dependencies:
|
|
|
64
70
|
requirement: !ruby/object:Gem::Requirement
|
|
65
71
|
none: false
|
|
66
72
|
requirements:
|
|
67
|
-
- -
|
|
73
|
+
- - ! '>='
|
|
68
74
|
- !ruby/object:Gem::Version
|
|
69
75
|
version: '3.2'
|
|
70
76
|
type: :development
|
|
@@ -72,7 +78,7 @@ dependencies:
|
|
|
72
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
79
|
none: false
|
|
74
80
|
requirements:
|
|
75
|
-
- -
|
|
81
|
+
- - ! '>='
|
|
76
82
|
- !ruby/object:Gem::Version
|
|
77
83
|
version: '3.2'
|
|
78
84
|
- !ruby/object:Gem::Dependency
|
|
@@ -187,6 +193,22 @@ dependencies:
|
|
|
187
193
|
- - ~>
|
|
188
194
|
- !ruby/object:Gem::Version
|
|
189
195
|
version: '3.0'
|
|
196
|
+
- !ruby/object:Gem::Dependency
|
|
197
|
+
name: torquebox-no-op
|
|
198
|
+
requirement: !ruby/object:Gem::Requirement
|
|
199
|
+
none: false
|
|
200
|
+
requirements:
|
|
201
|
+
- - ~>
|
|
202
|
+
- !ruby/object:Gem::Version
|
|
203
|
+
version: '2.3'
|
|
204
|
+
type: :development
|
|
205
|
+
prerelease: false
|
|
206
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
207
|
+
none: false
|
|
208
|
+
requirements:
|
|
209
|
+
- - ~>
|
|
210
|
+
- !ruby/object:Gem::Version
|
|
211
|
+
version: '2.3'
|
|
190
212
|
description: Send Devise's emails in background. Supports Resque, Sidekiq, Delayed::Job
|
|
191
213
|
and QueueClassic.
|
|
192
214
|
email:
|
|
@@ -199,6 +221,7 @@ files:
|
|
|
199
221
|
- .travis.yml
|
|
200
222
|
- CHANGELOG.md
|
|
201
223
|
- Gemfile
|
|
224
|
+
- Gemfile.lock
|
|
202
225
|
- LICENSE
|
|
203
226
|
- README.md
|
|
204
227
|
- Rakefile
|
|
@@ -211,6 +234,7 @@ files:
|
|
|
211
234
|
- lib/devise/async/backend/queue_classic.rb
|
|
212
235
|
- lib/devise/async/backend/resque.rb
|
|
213
236
|
- lib/devise/async/backend/sidekiq.rb
|
|
237
|
+
- lib/devise/async/backend/torquebox.rb
|
|
214
238
|
- lib/devise/async/model.rb
|
|
215
239
|
- lib/devise/async/version.rb
|
|
216
240
|
- lib/devise/async/worker.rb
|
|
@@ -219,11 +243,11 @@ files:
|
|
|
219
243
|
- test/devise/async/backend/queue_classic_test.rb
|
|
220
244
|
- test/devise/async/backend/resque_test.rb
|
|
221
245
|
- test/devise/async/backend/sidekiq_test.rb
|
|
246
|
+
- test/devise/async/backend/torquebox_test.rb
|
|
222
247
|
- test/devise/async/backend_test.rb
|
|
223
248
|
- test/devise/async/model_test.rb
|
|
224
249
|
- test/devise/async/worker_test.rb
|
|
225
250
|
- test/devise/async_test.rb
|
|
226
|
-
- test/support/helpers.rb
|
|
227
251
|
- test/support/my_mailer.rb
|
|
228
252
|
- test/support/rails_app.rb
|
|
229
253
|
- test/support/rails_app/app/models/admin.rb
|
|
@@ -234,6 +258,7 @@ files:
|
|
|
234
258
|
- test/support/rails_app/config/routes.rb
|
|
235
259
|
- test/support/rails_app/db/schema.rb
|
|
236
260
|
- test/support/rails_app/log/development.log
|
|
261
|
+
- test/support/test_helpers.rb
|
|
237
262
|
- test/test_helper.rb
|
|
238
263
|
homepage: https://github.com/mhfs/devise-async/
|
|
239
264
|
licenses: []
|
|
@@ -249,7 +274,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
249
274
|
version: '0'
|
|
250
275
|
segments:
|
|
251
276
|
- 0
|
|
252
|
-
hash:
|
|
277
|
+
hash: -3289238140870980510
|
|
253
278
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
279
|
none: false
|
|
255
280
|
requirements:
|
|
@@ -258,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
258
283
|
version: '0'
|
|
259
284
|
segments:
|
|
260
285
|
- 0
|
|
261
|
-
hash:
|
|
286
|
+
hash: -3289238140870980510
|
|
262
287
|
requirements: []
|
|
263
288
|
rubyforge_project:
|
|
264
289
|
rubygems_version: 1.8.23
|
|
@@ -273,11 +298,11 @@ test_files:
|
|
|
273
298
|
- test/devise/async/backend/queue_classic_test.rb
|
|
274
299
|
- test/devise/async/backend/resque_test.rb
|
|
275
300
|
- test/devise/async/backend/sidekiq_test.rb
|
|
301
|
+
- test/devise/async/backend/torquebox_test.rb
|
|
276
302
|
- test/devise/async/backend_test.rb
|
|
277
303
|
- test/devise/async/model_test.rb
|
|
278
304
|
- test/devise/async/worker_test.rb
|
|
279
305
|
- test/devise/async_test.rb
|
|
280
|
-
- test/support/helpers.rb
|
|
281
306
|
- test/support/my_mailer.rb
|
|
282
307
|
- test/support/rails_app.rb
|
|
283
308
|
- test/support/rails_app/app/models/admin.rb
|
|
@@ -288,4 +313,5 @@ test_files:
|
|
|
288
313
|
- test/support/rails_app/config/routes.rb
|
|
289
314
|
- test/support/rails_app/db/schema.rb
|
|
290
315
|
- test/support/rails_app/log/development.log
|
|
316
|
+
- test/support/test_helpers.rb
|
|
291
317
|
- test/test_helper.rb
|
data/test/support/helpers.rb
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
def valid_attributes(attributes={})
|
|
2
|
-
{ :username => "usertest",
|
|
3
|
-
:email => generate_unique_email,
|
|
4
|
-
:password => '12345678',
|
|
5
|
-
:password_confirmation => '12345678' }.update(attributes)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def generate_unique_email
|
|
9
|
-
@@email_count ||= 0
|
|
10
|
-
@@email_count += 1
|
|
11
|
-
"test#{@@email_count}@example.com"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def new_user(attributes={})
|
|
15
|
-
User.new(valid_attributes(attributes))
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def create_user(attributes={})
|
|
19
|
-
User.create!(valid_attributes(attributes))
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def new_admin(attributes={})
|
|
23
|
-
Admin.new(valid_attributes(attributes))
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def create_admin(attributes={})
|
|
27
|
-
Admin.create!(valid_attributes(attributes))
|
|
28
|
-
end
|