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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/async_request/jobs_controller.rb +36 -6
  3. data/app/models/async_request/job.rb +49 -2
  4. data/app/poros/async_request/json_web_token.rb +26 -0
  5. data/app/workers/async_request/job_processor.rb +6 -6
  6. data/config/routes.rb +1 -1
  7. data/lib/async_request.rb +28 -0
  8. data/lib/async_request/engine.rb +2 -1
  9. data/lib/async_request/version.rb +1 -1
  10. data/lib/generators/async_request_generator.rb +6 -3
  11. data/lib/templates/async_request.rb +5 -0
  12. data/lib/templates/create_async_request_jobs.rb +1 -1
  13. data/spec/controllers/async_request/jobs_controller_spec.rb +80 -41
  14. data/spec/controllers/dummy_controller_spec.rb +49 -0
  15. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  16. data/spec/dummy/app/controllers/dummy_controller.rb +11 -0
  17. data/spec/dummy/app/workers/worker_returning_nil.rb +5 -0
  18. data/spec/dummy/app/workers/worker_with_errors.rb +8 -0
  19. data/spec/dummy/app/workers/worker_with_symbol.rb +5 -0
  20. data/spec/dummy/app/workers/worker_without_errors.rb +5 -0
  21. data/spec/dummy/bin/bundle +1 -0
  22. data/spec/dummy/bin/rails +1 -0
  23. data/spec/dummy/bin/rake +1 -0
  24. data/spec/dummy/bin/setup +9 -8
  25. data/spec/dummy/config/application.rb +1 -2
  26. data/spec/dummy/config/initializers/async_request.rb +5 -0
  27. data/spec/dummy/config/routes.rb +2 -2
  28. data/spec/dummy/db/migrate/20170815023204_create_async_request_jobs.rb +16 -0
  29. data/spec/dummy/db/schema.rb +1 -1
  30. data/spec/dummy/log/test.log +0 -5472
  31. data/spec/factories/async_request_job.rb +6 -0
  32. data/spec/models/async_request/job_spec.rb +40 -0
  33. data/spec/spec_helper.rb +1 -0
  34. data/spec/support/helpers.rb +5 -0
  35. data/spec/workers/async_request/job_processor_spec.rb +47 -17
  36. metadata +85 -54
  37. data/app/assets/javascripts/async_request/application.js +0 -13
  38. data/app/assets/stylesheets/async_request/application.css +0 -15
  39. data/app/helpers/async_request/application_helper.rb +0 -15
  40. data/lib/tasks/async_request_tasks.rake +0 -4
  41. data/spec/dummy/app/workers/test.rb +0 -7
  42. data/spec/dummy/log/development.log +0 -827
  43. 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