devise-async-stretch 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTI2MDhjNWJiYTUwMDUwN2RjMjk3OTE4ODAwMWJiNDAxMGE1NDU5ZA==
4
+ MjYwYjhlNmJkMTM3ZjBiOTRjZTcwYTIzNGVhYzJkZWZhOWU3NmM1YQ==
5
5
  data.tar.gz: !binary |-
6
- YzJkMjIwNTczMjgxMmM4ZjljYTMzYmVkNWI1ZmU5MmViZDViNGFiYw==
6
+ ZDEwMmQzMDAyYTRlOWE4NWE5NzI4MzI0MTQ0M2U3ZjBiYzk1N2Q4YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzQ5MGVhMTJiMmM0ZWM0NzUzNmFhNTYwYmU1ZGZlNWI5NTc1NmY5NTdjYjEw
10
- MGM1ZmJjMWZhNjE1ZGRhYmZiMTdmMzU2OGQ4ODdiOWVhZGMxOWI2MzI4MTZh
11
- ZjhlZjM1YWU0MWU4OWQ5NTU0YWRiYzg4MWExOTU5ZmUyY2NjOWU=
9
+ ZjU2ZGYzZjYxZjE0MjhjYjk4MGE3NzRkN2Y5OGI5NTcyYTVkOTBkZjMzOTZi
10
+ NmFlYTc2NWY1ZDg4NGEzOGM2MDU0Yzk5MzAxMTY5YzhhYjY0ZjYzZWI0YmY4
11
+ N2RkZWY5OWY0NDViN2JkNjI2ZmE2OTdjYjg1NTMwNWE1ODc2OTg=
12
12
  data.tar.gz: !binary |-
13
- YTVhZTc0YmUyNjIxM2E3ZTBlMDgwMzE4OTQ0YTQ4NjNmYTJmOTM1YTY3NDA0
14
- ZDk4YzZmZjRkNWVlYTJmNTljODFkZGMxYjYzYTk4MWNmODM1NTdjZmRlNzYy
15
- M2ZlMGJmNDUwNmFjNzE0NGE4OGU0MmRhOGNjZTFjNDI4YzQ0YTA=
13
+ NDFjZjE0YjgyZDVhMDdiNjJjNGJjMDk3MmI2MGQxM2Q3ODNhNmEyYWU5YjVk
14
+ YTRjMGMyMDkzMWQ2OGM0NmEyMDM5ZmUyYmMwMWQzMjQxODA2MjI2NTVkNjg2
15
+ ZTFmYjIyNjNlYTBhZDZjM2RkNzE5OTJlOWI2NzYwMzRkYTYwYTM=
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ *.gem
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "mocha", "~> 0.11"
28
28
  spec.add_development_dependency "sqlite3"
29
29
  spec.add_development_dependency "sidekiq"
30
+ spec.add_development_dependency "delayed_job_active_record"
30
31
  end
@@ -20,6 +20,7 @@ module Devise
20
20
  autoload :Base, "devise/async/stretch/backend/base"
21
21
  autoload :Sidekiq, "devise/async/stretch/backend/sidekiq"
22
22
  autoload :ActiveJob, "devise/async/stretch/backend/active_job"
23
+ autoload :DelayedJob, "devise/async/stretch/backend/delayed_job"
23
24
  end
24
25
 
25
26
  # Defines the queue backend to be used. Sidekiq by default.
@@ -0,0 +1,13 @@
1
+ module Devise
2
+ module Async
3
+ module Stretch
4
+ module Backend
5
+ class DelayedJob < Base
6
+ def self.enqueue_job(klass, id, password)
7
+ new.delay(queue: Devise::Async::Stretch.queue).perform(klass, id, password)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,7 +1,7 @@
1
1
  module Devise
2
2
  module Async
3
3
  module Stretch
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+ require 'delayed_job_active_record'
3
+
4
+ module Devise
5
+ module Async
6
+ module Stretch
7
+ module Backend
8
+ class DelayedJobTest < ActiveSupport::TestCase
9
+
10
+ setup do
11
+ @user = users(:bob)
12
+ Devise::Async::Stretch.enabled = true
13
+ Devise::Async::Stretch.backend = :delayed_job
14
+ end
15
+
16
+ test "the job is queued" do
17
+ assert_difference '::Delayed::Backend::ActiveRecord::Job.count' do
18
+ DelayedJob.enqueue_job("User", @user.id, "password")
19
+ end
20
+ end
21
+
22
+ test "the password gets updated when peformed" do
23
+ DelayedJob.new.perform("User", @user.id, 'password')
24
+ assert_not_empty @user.reload.encrypted_password
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -13,6 +13,14 @@ module Devise
13
13
  assert_equal Backend::Sidekiq, Backend.for(:sidekiq)
14
14
  end
15
15
 
16
+ test "active_job" do
17
+ assert_equal Backend::ActiveJob, Backend.for(:active_job)
18
+ end
19
+
20
+ test "delayed_job" do
21
+ assert_equal Backend::DelayedJob, Backend.for(:delayed_job)
22
+ end
23
+
16
24
  test "an error is thrown for unsupported backends" do
17
25
  assert_raises ArgumentError do
18
26
  Backend.for(:fakeerz)
@@ -0,0 +1,22 @@
1
+ class CreateDelayedJobs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :delayed_jobs, force: true do |table|
4
+ table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue
5
+ table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually.
6
+ table.text :handler, null: false # YAML-encoded string of the object that will do work
7
+ table.text :last_error # reason for last failure (See Note below)
8
+ table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
9
+ table.datetime :locked_at # Set when a client is working on this object
10
+ table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
11
+ table.string :locked_by # Who is working on this object (if locked)
12
+ table.string :queue # The name of the queue this job is in
13
+ table.timestamps null: true
14
+ end
15
+
16
+ add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority"
17
+ end
18
+
19
+ def self.down
20
+ drop_table :delayed_jobs
21
+ end
22
+ end
@@ -11,9 +11,25 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20141228200636) do
14
+ ActiveRecord::Schema.define(version: 20150105232318) do
15
15
 
16
- create_table "users", force: true do |t|
16
+ create_table "delayed_jobs", force: :cascade do |t|
17
+ t.integer "priority", default: 0, null: false
18
+ t.integer "attempts", default: 0, null: false
19
+ t.text "handler", null: false
20
+ t.text "last_error"
21
+ t.datetime "run_at"
22
+ t.datetime "locked_at"
23
+ t.datetime "failed_at"
24
+ t.string "locked_by"
25
+ t.string "queue"
26
+ t.datetime "created_at"
27
+ t.datetime "updated_at"
28
+ end
29
+
30
+ add_index "delayed_jobs", ["priority", "run_at"], name: "delayed_jobs_priority"
31
+
32
+ create_table "users", force: :cascade do |t|
17
33
  t.string "email", default: "", null: false
18
34
  t.string "encrypted_password", default: "", null: false
19
35
  t.string "reset_password_token"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise-async-stretch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Westendorf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-03 00:00:00.000000000 Z
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ! '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: delayed_job_active_record
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  description: Uncompromised security for your user's passwords. Move password stretching
126
140
  into a background job for fast user creation, but maintainging safety.
127
141
  email:
@@ -141,15 +155,16 @@ files:
141
155
  - lib/devise/async/stretch/backend.rb
142
156
  - lib/devise/async/stretch/backend/active_job.rb
143
157
  - lib/devise/async/stretch/backend/base.rb
158
+ - lib/devise/async/stretch/backend/delayed_job.rb
144
159
  - lib/devise/async/stretch/backend/sidekiq.rb
145
160
  - lib/devise/async/stretch/model.rb
146
161
  - lib/devise/async/stretch/version.rb
147
162
  - lib/devise/async/stretch/worker.rb
148
163
  - lib/generators/devise/async/stretch/install_generator.rb
149
164
  - lib/generators/templates/devise_async_stretch.rb
150
- - log/test.log
151
165
  - test/devise/async/stretch/backend/active_job_test.rb
152
166
  - test/devise/async/stretch/backend/base_test.rb
167
+ - test/devise/async/stretch/backend/delayed_job_test.rb
153
168
  - test/devise/async/stretch/backend/sidekiq_test.rb
154
169
  - test/devise/async/stretch/backend_test.rb
155
170
  - test/devise/async/stretch/model_test.rb
@@ -196,6 +211,7 @@ files:
196
211
  - test/rails_app/config/routes.rb
197
212
  - test/rails_app/config/secrets.yml
198
213
  - test/rails_app/db/migrate/20141227205721_devise_create_users.rb
214
+ - test/rails_app/db/migrate/20150105232318_create_delayed_jobs.rb
199
215
  - test/rails_app/db/schema.rb
200
216
  - test/rails_app/db/seeds.rb
201
217
  - test/rails_app/lib/assets/.keep
@@ -245,6 +261,7 @@ summary: Move password stretching into a background job for fast user creation.
245
261
  test_files:
246
262
  - test/devise/async/stretch/backend/active_job_test.rb
247
263
  - test/devise/async/stretch/backend/base_test.rb
264
+ - test/devise/async/stretch/backend/delayed_job_test.rb
248
265
  - test/devise/async/stretch/backend/sidekiq_test.rb
249
266
  - test/devise/async/stretch/backend_test.rb
250
267
  - test/devise/async/stretch/model_test.rb
@@ -291,6 +308,7 @@ test_files:
291
308
  - test/rails_app/config/routes.rb
292
309
  - test/rails_app/config/secrets.yml
293
310
  - test/rails_app/db/migrate/20141227205721_devise_create_users.rb
311
+ - test/rails_app/db/migrate/20150105232318_create_delayed_jobs.rb
294
312
  - test/rails_app/db/schema.rb
295
313
  - test/rails_app/db/seeds.rb
296
314
  - test/rails_app/lib/assets/.keep
data/log/test.log DELETED
File without changes