devise-async 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -3
- data/CHANGELOG.md +6 -0
- data/lib/devise/async.rb +4 -1
- data/lib/devise/async/backend/base.rb +1 -0
- data/lib/devise/async/model.rb +2 -11
- data/lib/devise/async/version.rb +1 -1
- data/lib/devise/async/worker.rb +1 -0
- data/test/devise/async/model_test.rb +13 -0
- data/test/devise/async_test.rb +5 -0
- data/test/test_helper.rb +1 -1
- metadata +4 -4
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## 0.7.0
|
4
|
+
|
5
|
+
* make sure options hash has string keys when enqueued and symbol keys when job runs
|
6
|
+
* stringfy options keys before enqueueing to make queue_classic happy (nickw)
|
7
|
+
* Added `enable` options to make it easier to skip async processing during tests (mohamedmagdy)
|
8
|
+
|
3
9
|
## 0.6.0
|
4
10
|
|
5
11
|
* Now compatible with Devise 2.2+ only
|
data/lib/devise/async.rb
CHANGED
@@ -23,13 +23,16 @@ module Devise
|
|
23
23
|
mattr_accessor :queue
|
24
24
|
@@queue = :mailer
|
25
25
|
|
26
|
+
# Defines the enabled configuration that if set to false the emails will be sent synchronously
|
27
|
+
mattr_accessor :enabled
|
28
|
+
@@enabled = true
|
29
|
+
|
26
30
|
# Allow configuring Devise::Async with a block
|
27
31
|
#
|
28
32
|
# Example:
|
29
33
|
#
|
30
34
|
# Devise::Async.setup do |config|
|
31
35
|
# config.backend = :resque
|
32
|
-
# config.mailer = "MyMailer"
|
33
36
|
# config.queue = :my_custom_queue
|
34
37
|
# end
|
35
38
|
def self.setup
|
@@ -12,6 +12,7 @@ module Devise
|
|
12
12
|
# compatibility among diferent ORMs.
|
13
13
|
def perform(method, resource_class, resource_id, opts)
|
14
14
|
resource = resource_class.constantize.to_adapter.get!(resource_id)
|
15
|
+
opts.symbolize_keys!
|
15
16
|
mailer_class.send(method, resource, opts).deliver
|
16
17
|
end
|
17
18
|
|
data/lib/devise/async/model.rb
CHANGED
@@ -1,15 +1,4 @@
|
|
1
1
|
module Devise
|
2
|
-
# TODO remove when appropriate
|
3
|
-
module Async
|
4
|
-
module Model
|
5
|
-
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
included do
|
8
|
-
warn "Including Devise::Async::Model directly in your models is no longer supported and won't work. Please add `:async` to your `devise` call."
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
2
|
module Models
|
14
3
|
module Async
|
15
4
|
extend ActiveSupport::Concern
|
@@ -36,6 +25,8 @@ module Devise
|
|
36
25
|
# processing instead of sending it inline as devise does by
|
37
26
|
# default.
|
38
27
|
def send_devise_notification(notification, opts = {})
|
28
|
+
return super unless Devise::Async.enabled
|
29
|
+
|
39
30
|
# If the record is dirty we keep pending notifications to be enqueued
|
40
31
|
# by the callback and avoid before commit job processing.
|
41
32
|
if changed?
|
data/lib/devise/async/version.rb
CHANGED
data/lib/devise/async/worker.rb
CHANGED
@@ -4,6 +4,7 @@ module Devise
|
|
4
4
|
# Used is the internal interface for devise-async to enqueue notifications
|
5
5
|
# to the desired backend.
|
6
6
|
def self.enqueue(method, resource_class, resource_id, opts)
|
7
|
+
opts.stringify_keys!
|
7
8
|
backend_class.enqueue(method, resource_class, resource_id, opts)
|
8
9
|
end
|
9
10
|
|
@@ -36,6 +36,19 @@ module Devise
|
|
36
36
|
Worker.expects(:enqueue).with(:confirmation_instructions, "Admin", admin.id.to_s, {})
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
it "should not enqueue a job if the enabled config option is set to false" do
|
41
|
+
Devise::Async.stubs(:enabled).returns(false)
|
42
|
+
|
43
|
+
# Stubbing the devise's confirmation_instructions
|
44
|
+
confirmation_email = Object.new
|
45
|
+
Devise::Mailer.stubs(:confirmation_instructions).returns(confirmation_email)
|
46
|
+
confirmation_email.stubs(:deliver).returns(true) # Stubbing the email sending process
|
47
|
+
|
48
|
+
admin = create_admin
|
49
|
+
admin.send(:devise_pending_notifications).must_equal []
|
50
|
+
Worker.expects(:enqueue).never
|
51
|
+
end
|
39
52
|
end
|
40
53
|
end
|
41
54
|
end
|
data/test/devise/async_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
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.7.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-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise
|
@@ -249,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
249
249
|
version: '0'
|
250
250
|
segments:
|
251
251
|
- 0
|
252
|
-
hash:
|
252
|
+
hash: 2828079365640681626
|
253
253
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
254
|
none: false
|
255
255
|
requirements:
|
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
258
|
version: '0'
|
259
259
|
segments:
|
260
260
|
- 0
|
261
|
-
hash:
|
261
|
+
hash: 2828079365640681626
|
262
262
|
requirements: []
|
263
263
|
rubyforge_project:
|
264
264
|
rubygems_version: 1.8.23
|