async_request 0.0.7 → 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/app/controllers/async_request/jobs_controller.rb +36 -6
- data/app/models/async_request/job.rb +49 -2
- data/app/poros/async_request/json_web_token.rb +26 -0
- data/app/workers/async_request/job_processor.rb +6 -6
- data/config/routes.rb +1 -1
- data/lib/async_request.rb +28 -0
- data/lib/async_request/engine.rb +2 -1
- data/lib/async_request/version.rb +1 -1
- data/lib/generators/async_request_generator.rb +6 -3
- data/lib/templates/async_request.rb +5 -0
- data/lib/templates/create_async_request_jobs.rb +1 -1
- data/spec/controllers/async_request/jobs_controller_spec.rb +80 -41
- data/spec/controllers/dummy_controller_spec.rb +49 -0
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/controllers/dummy_controller.rb +11 -0
- data/spec/dummy/app/workers/worker_returning_nil.rb +5 -0
- data/spec/dummy/app/workers/worker_with_errors.rb +8 -0
- data/spec/dummy/app/workers/worker_with_symbol.rb +5 -0
- data/spec/dummy/app/workers/worker_without_errors.rb +5 -0
- data/spec/dummy/bin/bundle +1 -0
- data/spec/dummy/bin/rails +1 -0
- data/spec/dummy/bin/rake +1 -0
- data/spec/dummy/bin/setup +9 -8
- data/spec/dummy/config/application.rb +1 -2
- data/spec/dummy/config/initializers/async_request.rb +5 -0
- data/spec/dummy/config/routes.rb +2 -2
- data/spec/dummy/db/migrate/20170815023204_create_async_request_jobs.rb +16 -0
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/dummy/log/test.log +0 -5472
- data/spec/factories/async_request_job.rb +6 -0
- data/spec/models/async_request/job_spec.rb +40 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/helpers.rb +5 -0
- data/spec/workers/async_request/job_processor_spec.rb +47 -17
- metadata +85 -54
- data/app/assets/javascripts/async_request/application.js +0 -13
- data/app/assets/stylesheets/async_request/application.css +0 -15
- data/app/helpers/async_request/application_helper.rb +0 -15
- data/lib/tasks/async_request_tasks.rake +0 -4
- data/spec/dummy/app/workers/test.rb +0 -7
- data/spec/dummy/log/development.log +0 -827
- data/spec/helpers/async_request/application_helper_spec.rb +0 -39
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module AsyncRequest
|
4
|
-
describe ApplicationHelper do
|
5
|
-
describe '.execute_async' do
|
6
|
-
context 'When no worker class is passed' do
|
7
|
-
it 'fails with ArgumentError' do
|
8
|
-
expect { execute_async(nil, []) }.to raise_error(ArgumentError)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context 'When called with valid params' do
|
13
|
-
it 'creates a new job object' do
|
14
|
-
expect { execute_async(Test, 'a') }.to change { Job.count }.by(1)
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'creates a new job object with Test as worker' do
|
18
|
-
job = Job.find_by(uid: execute_async(Test, 'a'))
|
19
|
-
expect(job.worker).to eq 'Test'
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'creates a new job object with [\'a\'] as params' do
|
23
|
-
job = Job.find_by(uid: execute_async(Test, 'a'))
|
24
|
-
expect(job.params).to eq ['a']
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'creates a new job object with [\'a\'] as params' do
|
28
|
-
job = Job.find_by(uid: execute_async(Test, 'a'))
|
29
|
-
expect(job.waiting?).to be_truthy
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'serializes complex params' do
|
33
|
-
job = Job.find_by(uid: execute_async(Test, { a: 'a' }, 3, 'a'))
|
34
|
-
expect(job.params).to eq [{ a: 'a' }, 3, 'a']
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|