devise-async 0.0.2 → 0.1.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.
@@ -0,0 +1,20 @@
1
+ ## Unreleased
2
+
3
+ ## 0.1.0
4
+
5
+ * New
6
+ * Added `Devise::Async.mailer` option to proxy to custom mailers
7
+ * Added `Devise::Async.setup` to allow configuring with blocks
8
+
9
+ ## 0.0.2
10
+
11
+ * Enhancements
12
+ * Restructured gem to Devise::Async module instead of DeviseAsync.
13
+
14
+ * Deprecations
15
+ * DeviseAsync::Proxy is now Devise::Async::Proxy
16
+ * DeviseAsync.backend is now Devise::Async.backend
17
+
18
+ ## 0.0.1
19
+
20
+ * first release
data/README.md CHANGED
@@ -42,6 +42,31 @@ Devise::Async.backend = :resque
42
42
 
43
43
  Tip: it defaults to Resque. You don't need to create the initializer if using it.
44
44
 
45
+ ## Advanced Options
46
+
47
+ ### Custom mailer class
48
+
49
+ If you inherit `Devise::Mailer` to a class of your own for customization purposes,
50
+ you'll need to tell `Devise::Async` to proxy to that class.
51
+
52
+ ```ruby
53
+ # config/initializers/devise_async.rb
54
+ Devise::Async.mailer = "MyCustomMailer"
55
+ ```
56
+
57
+ ### Setup via block
58
+
59
+ To avoid repeating `Devise::Async` in the initializer file you can use the block syntax
60
+ similar do what `Devise` offers.
61
+
62
+ ```ruby
63
+ # config/initializers/devise_async.rb
64
+ Devise::Async.setup do |config|
65
+ config.backend = :resque
66
+ config.mailer = "MyCustomMailer"
67
+ end
68
+ ```
69
+
45
70
  ## Contributing
46
71
 
47
72
  1. Fork it
@@ -17,6 +17,22 @@ module Devise
17
17
  # Defines the queue backend to be used. Resque by default.
18
18
  mattr_accessor :backend
19
19
  @@backend = :resque
20
+
21
+ # Defines the mailer class to be used. Devise::Mailer by default.
22
+ mattr_accessor :mailer
23
+ @@mailer = "Devise::Mailer"
24
+
25
+ # Allow configuring Devise::Async with a block
26
+ #
27
+ # Example:
28
+ #
29
+ # Devise::Async.setup do |config|
30
+ # config.backend = :resque
31
+ # config.mailer = "MyMailer"
32
+ # end
33
+ def self.setup
34
+ yield self
35
+ end
20
36
  end
21
37
  end
22
38
 
@@ -29,4 +45,9 @@ module DeviseAsync
29
45
  super
30
46
  end
31
47
  end
48
+
49
+ def self.backend=(value)
50
+ puts "DEPRECATION WARNING: `DeviseAsync.backend=` has been deprecated. Please use `Devise::Async.backend=`."
51
+ Devise::Async.backend = value
52
+ end
32
53
  end
@@ -8,7 +8,13 @@ module Devise
8
8
 
9
9
  def perform(method, resource_class, resource_id)
10
10
  resource = resource_class.constantize.find(resource_id)
11
- Devise::Mailer.send(method, resource).deliver
11
+ mailer_class.send(method, resource).deliver
12
+ end
13
+
14
+ private
15
+
16
+ def mailer_class
17
+ @mailer_class ||= Devise::Async.mailer.constantize
12
18
  end
13
19
  end
14
20
  end
@@ -1,5 +1,5 @@
1
1
  module Devise
2
2
  module Async
3
- VERSION = "0.0.2"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,22 @@
1
+ require "test_helper"
2
+
3
+ module Devise
4
+ module Async
5
+ module Backend
6
+ describe "Base" do
7
+ it "delegates to configured mailer" do
8
+ Async.mailer = "MyMailer"
9
+ user = create_user
10
+ mailer_instance = mock(:deliver => true)
11
+
12
+ MyMailer.expects(:confirmation_instructions).once.returns(mailer_instance)
13
+ Base.new.perform(:confirmation_instructions, "User", user.id)
14
+ end
15
+
16
+ after do
17
+ Async.mailer = "Devise::Mailer"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ require "test_helper"
2
+
3
+ module Devise
4
+ describe "Async" do
5
+ it "yields self when setup is called" do
6
+ Async.setup { |config| config.must_equal Async }
7
+ end
8
+
9
+ it "stores backend config" do
10
+ Async.backend = :something
11
+ Async.backend.must_equal :something
12
+ end
13
+
14
+ it "stores mailer config" do
15
+ Async.mailer = "MyMailer"
16
+ Async.mailer.must_equal "MyMailer"
17
+ end
18
+
19
+ after do
20
+ Async.backend = :resque
21
+ Async.mailer = "Devise::Mailer"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,2 @@
1
+ class MyMailer < Devise::Mailer
2
+ end
@@ -0,0 +1,15 @@
1
+ # Silent schema load output
2
+ ActiveRecord::Migration.verbose = false
3
+
4
+ module Devise
5
+ module Async
6
+ class RailsApp < ::Rails::Application
7
+ config.root = File.dirname(__FILE__) + "/rails_app"
8
+ config.active_support.deprecation = :log
9
+ config.action_mailer.default_url_options = { :host => "localhost:3000" }
10
+ config.action_mailer.delivery_method = :test
11
+ end
12
+ end
13
+ end
14
+
15
+ Devise::Async::RailsApp.initialize!
@@ -12,21 +12,8 @@ require "resque"
12
12
  require "sidekiq"
13
13
  require "delayed_job_active_record"
14
14
 
15
+ require "support/rails_app"
15
16
  require "support/helpers"
17
+ require "support/my_mailer"
16
18
 
17
- # Silent schema load output
18
- ActiveRecord::Migration.verbose = false
19
-
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
28
- end
29
- end
30
-
31
- Devise::Async::RailsApp.initialize!
32
19
  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.2
4
+ version: 0.1.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-05-18 00:00:00.000000000 Z
12
+ date: 2012-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
@@ -180,6 +180,7 @@ extra_rdoc_files: []
180
180
  files:
181
181
  - .gitignore
182
182
  - .travis.yml
183
+ - CHANGELOG.md
183
184
  - Gemfile
184
185
  - LICENSE
185
186
  - README.md
@@ -195,19 +196,24 @@ files:
195
196
  - lib/devise/async/proxy.rb
196
197
  - lib/devise/async/version.rb
197
198
  - lib/devise/async/worker.rb
199
+ - test/devise/async/backend/base_test.rb
198
200
  - test/devise/async/backend/delayed_job_test.rb
199
201
  - test/devise/async/backend/resque_test.rb
200
202
  - test/devise/async/backend/sidekiq_test.rb
201
203
  - test/devise/async/backend_test.rb
202
204
  - test/devise/async/proxy_test.rb
203
205
  - test/devise/async/worker_test.rb
206
+ - test/devise/async_test.rb
204
207
  - test/support/helpers.rb
208
+ - test/support/my_mailer.rb
209
+ - test/support/rails_app.rb
205
210
  - test/support/rails_app/app/models/user.rb
206
211
  - test/support/rails_app/config/database.yml
207
212
  - test/support/rails_app/config/initializers/devise.rb
208
213
  - test/support/rails_app/config/routes.rb
209
214
  - test/support/rails_app/db/schema.rb
210
215
  - test/support/rails_app/log/development.log
216
+ - test/support/support/rails_app/log/test.log
211
217
  - test/test_helper.rb
212
218
  homepage: https://github.com/mhfs/devise-async/
213
219
  licenses: []
@@ -223,7 +229,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
223
229
  version: '0'
224
230
  segments:
225
231
  - 0
226
- hash: 198489558210198293
232
+ hash: 3668830136326538611
227
233
  required_rubygems_version: !ruby/object:Gem::Requirement
228
234
  none: false
229
235
  requirements:
@@ -232,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
238
  version: '0'
233
239
  segments:
234
240
  - 0
235
- hash: 198489558210198293
241
+ hash: 3668830136326538611
236
242
  requirements: []
237
243
  rubyforge_project:
238
244
  rubygems_version: 1.8.23
@@ -242,17 +248,22 @@ summary: Devise Async provides an easy way to configure Devise to send its email
242
248
  asynchronously using your preferred queuing backend. It supports Resque, Sidekiq
243
249
  and Delayed::Job.
244
250
  test_files:
251
+ - test/devise/async/backend/base_test.rb
245
252
  - test/devise/async/backend/delayed_job_test.rb
246
253
  - test/devise/async/backend/resque_test.rb
247
254
  - test/devise/async/backend/sidekiq_test.rb
248
255
  - test/devise/async/backend_test.rb
249
256
  - test/devise/async/proxy_test.rb
250
257
  - test/devise/async/worker_test.rb
258
+ - test/devise/async_test.rb
251
259
  - test/support/helpers.rb
260
+ - test/support/my_mailer.rb
261
+ - test/support/rails_app.rb
252
262
  - test/support/rails_app/app/models/user.rb
253
263
  - test/support/rails_app/config/database.yml
254
264
  - test/support/rails_app/config/initializers/devise.rb
255
265
  - test/support/rails_app/config/routes.rb
256
266
  - test/support/rails_app/db/schema.rb
257
267
  - test/support/rails_app/log/development.log
268
+ - test/support/support/rails_app/log/test.log
258
269
  - test/test_helper.rb