devise-async 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  ## Unreleased
2
2
 
3
+ * Enhancements
4
+ * Added `Devise::Async.queue` option to let configure the queue
5
+ the jobs will be enqueued to.
6
+
3
7
  ## 0.1.1
4
8
 
5
9
  * Fixes
data/README.md CHANGED
@@ -54,6 +54,16 @@ you'll need to tell `Devise::Async` to proxy to that class.
54
54
  Devise::Async.mailer = "MyCustomMailer"
55
55
  ```
56
56
 
57
+ ### Custom queue
58
+
59
+ Let you specify a custom queue where to enqueue your background Devise jobs. Works
60
+ only for Resque and Sidekiq. Defaults to :mailer.
61
+
62
+ ```ruby
63
+ # config/initializers/devise_async.rb
64
+ Devise::Async.queue = :my_custom_queue
65
+ ```
66
+
57
67
  ### Setup via block
58
68
 
59
69
  To avoid repeating `Devise::Async` in the initializer file you can use the block syntax
@@ -64,6 +74,7 @@ similar do what `Devise` offers.
64
74
  Devise::Async.setup do |config|
65
75
  config.backend = :resque
66
76
  config.mailer = "MyCustomMailer"
77
+ config.queue = :my_custom_queue
67
78
  end
68
79
  ```
69
80
 
@@ -22,6 +22,10 @@ module Devise
22
22
  mattr_accessor :mailer
23
23
  @@mailer = "Devise::Mailer"
24
24
 
25
+ # Defines the queue in which the background job will be enqueued. Default is :mailer.
26
+ mattr_accessor :queue
27
+ @@queue = :mailer
28
+
25
29
  # Allow configuring Devise::Async with a block
26
30
  #
27
31
  # Example:
@@ -2,7 +2,7 @@ module Devise
2
2
  module Async
3
3
  module Backend
4
4
  class Resque < Base
5
- @queue = :mailer
5
+ @queue = Devise::Async.queue
6
6
 
7
7
  def self.enqueue(*args)
8
8
  args.unshift(self)
@@ -4,7 +4,7 @@ module Devise
4
4
  class Sidekiq < Base
5
5
  include ::Sidekiq::Worker
6
6
 
7
- sidekiq_options :queue => :mailer
7
+ sidekiq_options :queue => Devise::Async.queue
8
8
 
9
9
  def self.enqueue(*args)
10
10
  perform_async(*args)
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Async
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -15,6 +15,12 @@ module Devise
15
15
  Backend::Resque.perform(:confirmation_instructions, "User", user.id)
16
16
  ActionMailer::Base.deliveries.size.must_equal 1
17
17
  end
18
+
19
+ it "enqueues to configured queue" do
20
+ expected_size = 1 + ::Resque.size(:custom_queue)
21
+ Resque.enqueue(:mailer_method, "User", 123)
22
+ ::Resque.size(:custom_queue).must_equal expected_size
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -15,6 +15,12 @@ module Devise
15
15
  Backend::Sidekiq.new.perform(:confirmation_instructions, "User", user.id)
16
16
  ActionMailer::Base.deliveries.size.must_equal 1
17
17
  end
18
+
19
+ it "enqueues to configured queue" do
20
+ expected_size = 1 + Sidekiq.jobs.size
21
+ Sidekiq.enqueue(:mailer_method, "User", 123)
22
+ Sidekiq.jobs.size.must_equal expected_size
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -0,0 +1,3 @@
1
+ Devise::Async.setup do |config|
2
+ config.queue = :custom_queue
3
+ end
@@ -11,6 +11,7 @@ require "devise"
11
11
  require "resque"
12
12
  require "sidekiq"
13
13
  require "delayed_job_active_record"
14
+ require "sidekiq/testing"
14
15
 
15
16
  require "support/rails_app"
16
17
  require "support/helpers"
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.1.1
4
+ version: 0.2.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: 2012-06-01 00:00:00.000000000 Z
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
@@ -210,6 +210,7 @@ files:
210
210
  - test/support/rails_app/app/models/user.rb
211
211
  - test/support/rails_app/config/database.yml
212
212
  - test/support/rails_app/config/initializers/devise.rb
213
+ - test/support/rails_app/config/initializers/devise_async.rb
213
214
  - test/support/rails_app/config/routes.rb
214
215
  - test/support/rails_app/db/schema.rb
215
216
  - test/support/rails_app/log/development.log
@@ -229,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
229
230
  version: '0'
230
231
  segments:
231
232
  - 0
232
- hash: 752797920512014551
233
+ hash: -2016895500650412107
233
234
  required_rubygems_version: !ruby/object:Gem::Requirement
234
235
  none: false
235
236
  requirements:
@@ -238,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
239
  version: '0'
239
240
  segments:
240
241
  - 0
241
- hash: 752797920512014551
242
+ hash: -2016895500650412107
242
243
  requirements: []
243
244
  rubyforge_project:
244
245
  rubygems_version: 1.8.23
@@ -262,6 +263,7 @@ test_files:
262
263
  - test/support/rails_app/app/models/user.rb
263
264
  - test/support/rails_app/config/database.yml
264
265
  - test/support/rails_app/config/initializers/devise.rb
266
+ - test/support/rails_app/config/initializers/devise_async.rb
265
267
  - test/support/rails_app/config/routes.rb
266
268
  - test/support/rails_app/db/schema.rb
267
269
  - test/support/rails_app/log/development.log