devise-async 1.0.0beta → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/README.md +11 -75
- data/Rakefile +0 -11
- data/lib/devise/async/version.rb +1 -1
- data/spec/devise/async/model_spec.rb +7 -9
- data/spec/rails_helper.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b371e54937dd66d336e24152c8a3bdd30cbc24e
|
4
|
+
data.tar.gz: 0d066d3fab7d1d1b8d564691688bb88273582a62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dba241c296c5001d81a8848c0747cf5402dac71c20f099c936e6b12c53237ee0b693f99f92ac47b81891bfeb37cb2eba429b0bdd4a6bd0eaf4fb3e70d11e1534
|
7
|
+
data.tar.gz: 8c4372972c8303580626d9c12406d70770fce86d22fb569f2c30fc45fd7d15a42408e6194e8ffc9213840b71ab701515d33d2685681f98dbea595b6e919d58da
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,18 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Tag](https://img.shields.io/github/tag/mhfs/devise-async.svg?style=flat-square)](https://github.com/mhfs/devise-async/releases) [![Build Status](https://img.shields.io/travis/mhfs/devise-async.svg?style=flat-square)](https://travis-ci.org/mhfs/devise-async) [![Code Climate](https://img.shields.io/codeclimate/github/mhfs/devise-async.svg?style=flat-square)](https://codeclimate.com/github/mhfs/devise-async)
|
4
4
|
|
5
|
-
Devise Async provides an easy way to configure Devise to send its emails asynchronously using
|
6
|
-
|
7
|
-
Supported backends:
|
8
|
-
|
9
|
-
* Resque
|
10
|
-
* Sidekiq
|
11
|
-
* Delayed::Job
|
12
|
-
* QueueClassic
|
13
|
-
* Torquebox
|
14
|
-
* Backburner
|
15
|
-
* Que
|
16
|
-
* SuckerPunch
|
5
|
+
Devise Async provides an easy way to configure Devise to send its emails asynchronously using ActiveJob.
|
17
6
|
|
18
7
|
## Installation
|
19
8
|
|
@@ -33,7 +22,8 @@ Or install it yourself as:
|
|
33
22
|
|
34
23
|
## Usage
|
35
24
|
|
36
|
-
|
25
|
+
1. Setup [ActiveJob](http://edgeguides.rubyonrails.org/active_job_basics.html),
|
26
|
+
2. Add `:async` to the `devise` call in your model:
|
37
27
|
|
38
28
|
```ruby
|
39
29
|
class User < ActiveRecord::Base
|
@@ -41,16 +31,7 @@ class User < ActiveRecord::Base
|
|
41
31
|
end
|
42
32
|
```
|
43
33
|
|
44
|
-
|
45
|
-
|
46
|
-
```ruby
|
47
|
-
# Supported options: :resque, :sidekiq, :delayed_job, :queue_classic, :torquebox, :backburner, :que, :sucker_punch
|
48
|
-
Devise::Async.backend = :resque
|
49
|
-
```
|
50
|
-
|
51
|
-
Tip: it defaults to Resque. You don't need to create the initializer if using it.
|
52
|
-
|
53
|
-
## Advanced Options
|
34
|
+
## Options
|
54
35
|
|
55
36
|
### Enabling via config
|
56
37
|
|
@@ -61,33 +42,6 @@ The gem can be enabled/disabled easily via config, for example based on environm
|
|
61
42
|
Devise::Async.enabled = true # | false
|
62
43
|
```
|
63
44
|
|
64
|
-
### Custom mailer class
|
65
|
-
|
66
|
-
Customize `Devise.mailer` at will and `devise-async` will honor it.
|
67
|
-
|
68
|
-
Upgrade note: if you're upgrading from any version < 0.6 and getting errors
|
69
|
-
trying to set `Devise::Async.mailer` just use `Devise.mailer` instead.
|
70
|
-
|
71
|
-
### Custom queue
|
72
|
-
|
73
|
-
Let you specify a custom queue where to enqueue your background Devise jobs.
|
74
|
-
Defaults to :mailer.
|
75
|
-
|
76
|
-
```ruby
|
77
|
-
# config/initializers/devise_async.rb
|
78
|
-
Devise::Async.queue = :my_custom_queue
|
79
|
-
```
|
80
|
-
|
81
|
-
### Custom priority
|
82
|
-
|
83
|
-
You can specify a custom priority for created background jobs in Devise or Backburner.
|
84
|
-
If no value is specified, jobs will be enqueued with whatever default priority is configured in Devise or Backburner.
|
85
|
-
|
86
|
-
```ruby
|
87
|
-
# config/initializers/devise_async.rb
|
88
|
-
Devise::Async.priority = 10
|
89
|
-
```
|
90
|
-
|
91
45
|
### Setup via block
|
92
46
|
|
93
47
|
To avoid repeating `Devise::Async` in the initializer file you can use the block syntax
|
@@ -97,40 +51,22 @@ similar to what `Devise` offers.
|
|
97
51
|
# config/initializers/devise_async.rb
|
98
52
|
Devise::Async.setup do |config|
|
99
53
|
config.enabled = true
|
100
|
-
config.backend = :resque
|
101
|
-
config.queue = :my_custom_queue
|
102
|
-
end
|
103
|
-
```
|
104
|
-
|
105
|
-
## Troubleshooting
|
106
|
-
|
107
|
-
If you are using Sidekiq and your jobs are enqueued but not processed you might need to set a queue explicitly:
|
108
|
-
|
109
|
-
```ruby
|
110
|
-
# config/initializers/devise_async.rb
|
111
|
-
Devise::Async.setup do |config|
|
112
|
-
config.backend = :sidekiq
|
113
|
-
config.queue = :default
|
114
54
|
end
|
115
55
|
```
|
116
56
|
|
117
|
-
|
118
|
-
|
119
|
-
Be aware that since version 0.3.0 devise-async enqueues the background job in active
|
120
|
-
record's `after_commit` hook. If you're using rspec's `use_transactional_fixtures` the jobs
|
121
|
-
might not be enqueued as you'd expect.
|
57
|
+
### Custom mailer class
|
122
58
|
|
123
|
-
|
59
|
+
Customize `Devise.mailer` at will and `devise-async` will honor it.
|
124
60
|
|
125
|
-
##
|
61
|
+
## Older versions of Rails and devise
|
126
62
|
|
127
|
-
|
63
|
+
If you want to use this gem with Rails < 5 and/or devise < 4 check out older releases, please.
|
128
64
|
|
129
|
-
|
65
|
+
## Testing
|
130
66
|
|
131
|
-
|
67
|
+
RSpec is used for testing. The following should be enough for running the test:
|
132
68
|
|
133
|
-
|
69
|
+
$ bundle exec rspec
|
134
70
|
|
135
71
|
## Contributing
|
136
72
|
|
data/Rakefile
CHANGED
@@ -1,14 +1,3 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
|
-
require "rake/testtask"
|
5
|
-
|
6
|
-
task :default => :test
|
7
|
-
|
8
|
-
Rake::TestTask.new do |t|
|
9
|
-
t.libs << "lib"
|
10
|
-
t.libs << "test"
|
11
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
12
|
-
t.verbose = true
|
13
|
-
t.warning = false
|
14
|
-
end
|
data/lib/devise/async/version.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
RSpec.describe Devise::Models::Async do
|
2
|
-
before
|
2
|
+
before do
|
3
3
|
ActiveJob::Base.queue_adapter = :test
|
4
4
|
end
|
5
5
|
|
6
6
|
context 'with unchanged model' do
|
7
|
-
subject {
|
7
|
+
subject { admin }
|
8
8
|
|
9
|
-
|
10
|
-
subject
|
11
|
-
end
|
9
|
+
let!(:admin) { create_admin }
|
12
10
|
|
13
11
|
it 'enqueues notifications immediately when the model did not change' do
|
14
12
|
expect(ActionMailer::DeliveryJob).to have_been_enqueued
|
@@ -47,7 +45,7 @@ RSpec.describe Devise::Models::Async do
|
|
47
45
|
end
|
48
46
|
|
49
47
|
context 'with saving the model' do
|
50
|
-
let(:
|
48
|
+
let(:saved_admin) { admin.save }
|
51
49
|
|
52
50
|
it 'accumulates a pending notification to be sent after commit' do
|
53
51
|
expect(subject).to eq([
|
@@ -59,13 +57,13 @@ RSpec.describe Devise::Models::Async do
|
|
59
57
|
subject
|
60
58
|
|
61
59
|
expect {
|
62
|
-
|
60
|
+
saved_admin
|
63
61
|
}.to have_enqueued_job(ActionMailer::DeliveryJob)
|
64
62
|
end
|
65
63
|
|
66
64
|
it 'forwards the correct data to the job' do
|
67
65
|
subject
|
68
|
-
|
66
|
+
saved_admin
|
69
67
|
|
70
68
|
job_data = ActiveJob::Base.queue_adapter.enqueued_jobs.first[:args]
|
71
69
|
expected_job_data = ['Devise::Mailer', 'confirmation_instructions', admin.send(:confirmation_token)]
|
@@ -76,7 +74,7 @@ RSpec.describe Devise::Models::Async do
|
|
76
74
|
end
|
77
75
|
|
78
76
|
context 'when devise async is disabled' do
|
79
|
-
around
|
77
|
+
around do |example|
|
80
78
|
Devise::Async.enabled = false
|
81
79
|
example.run
|
82
80
|
Devise::Async.enabled = true
|
data/spec/rails_helper.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -11,7 +11,7 @@ RSpec.configure do |config|
|
|
11
11
|
config.filter_run_when_matching :focus
|
12
12
|
config.example_status_persistence_file_path = "spec/examples.txt"
|
13
13
|
config.disable_monkey_patching!
|
14
|
-
config.warnings =
|
14
|
+
config.warnings = false
|
15
15
|
config.order = :random
|
16
16
|
|
17
17
|
if config.files_to_run.one?
|
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: 1.0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Oelke
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-09-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise
|
@@ -185,9 +185,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
187
|
requirements:
|
188
|
-
- - "
|
188
|
+
- - ">="
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
version:
|
190
|
+
version: '0'
|
191
191
|
requirements: []
|
192
192
|
rubyforge_project:
|
193
193
|
rubygems_version: 2.4.5.1
|