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.
@@ -1,6 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
- - ree
5
- - 1.9.2
6
3
  - 1.9.3
@@ -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
@@ -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
 
@@ -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?
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Async
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
@@ -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
@@ -11,6 +11,11 @@ module Devise
11
11
  Async.backend.must_equal :something
12
12
  end
13
13
 
14
+ it "stores enabled config" do
15
+ Async.backend = false
16
+ Async.backend.must_equal false
17
+ end
18
+
14
19
  after do
15
20
  Async.backend = :resque
16
21
  end
@@ -3,7 +3,7 @@ ENV["RAILS_ENV"] = "test"
3
3
  require "minitest/autorun"
4
4
  require "minitest/spec"
5
5
  require "minitest/mock"
6
- require "mocha"
6
+ require "mocha/setup"
7
7
 
8
8
  require "devise"
9
9
  require "devise/async"
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.6.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-01-18 00:00:00.000000000 Z
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: 1115023412629133850
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: 1115023412629133850
261
+ hash: 2828079365640681626
262
262
  requirements: []
263
263
  rubyforge_project:
264
264
  rubygems_version: 1.8.23