sidejobs 4.0.0.2 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +5 -5
  4. data/Rakefile +1 -3
  5. data/lib/sidejobs.rb +2 -1
  6. data/lib/sidejobs/daemon.rb +35 -33
  7. data/lib/sidejobs/extensions/active_job/queue_adapter.rb +29 -31
  8. data/lib/sidejobs/loggable.rb +7 -0
  9. data/lib/sidejobs/processor.rb +1 -6
  10. data/lib/sidejobs/queue.rb +1 -1
  11. data/lib/sidejobs/version.rb +1 -1
  12. metadata +16 -125
  13. data/test/daemon_test.rb +0 -71
  14. data/test/dummy/Rakefile +0 -5
  15. data/test/dummy/app/assets/javascripts/application.js +0 -13
  16. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  17. data/test/dummy/app/controllers/application_controller.rb +0 -5
  18. data/test/dummy/app/helpers/application_helper.rb +0 -2
  19. data/test/dummy/app/jobs/charge_subscriptions_job.rb +0 -8
  20. data/test/dummy/app/jobs/clear_guest_users_job.rb +0 -8
  21. data/test/dummy/app/jobs/send_newsletters_job.rb +0 -8
  22. data/test/dummy/app/jobs/share_products_job.rb +0 -8
  23. data/test/dummy/app/jobs/update_exchanges_job.rb +0 -8
  24. data/test/dummy/app/mailers/user_mailer.rb +0 -7
  25. data/test/dummy/app/views/layouts/application.html.erb +0 -12
  26. data/test/dummy/app/views/user_mailer/invite.text.erb +0 -1
  27. data/test/dummy/bin/bundle +0 -4
  28. data/test/dummy/bin/rails +0 -5
  29. data/test/dummy/bin/rake +0 -5
  30. data/test/dummy/bin/setup +0 -30
  31. data/test/dummy/config.ru +0 -4
  32. data/test/dummy/config/application.rb +0 -25
  33. data/test/dummy/config/boot.rb +0 -5
  34. data/test/dummy/config/database.yml +0 -10
  35. data/test/dummy/config/database.yml.travis +0 -3
  36. data/test/dummy/config/environment.rb +0 -5
  37. data/test/dummy/config/environments/development.rb +0 -44
  38. data/test/dummy/config/environments/production.rb +0 -79
  39. data/test/dummy/config/environments/test.rb +0 -45
  40. data/test/dummy/config/initializers/assets.rb +0 -11
  41. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  42. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  43. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  44. data/test/dummy/config/initializers/inflections.rb +0 -16
  45. data/test/dummy/config/initializers/mime_types.rb +0 -4
  46. data/test/dummy/config/initializers/session_store.rb +0 -3
  47. data/test/dummy/config/initializers/sidejobs.rb +0 -7
  48. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  49. data/test/dummy/config/locales/en.yml +0 -23
  50. data/test/dummy/config/routes.rb +0 -56
  51. data/test/dummy/config/secrets.yml +0 -22
  52. data/test/dummy/db/migrate/20161022211612_create_sidejobs.rb +0 -21
  53. data/test/dummy/db/schema.rb +0 -37
  54. data/test/dummy/log/development.log +0 -23
  55. data/test/dummy/log/sidejobs.log +0 -739
  56. data/test/dummy/log/test.log +0 -3903
  57. data/test/dummy/public/404.html +0 -61
  58. data/test/dummy/public/422.html +0 -61
  59. data/test/dummy/public/500.html +0 -60
  60. data/test/dummy/public/favicon.ico +0 -0
  61. data/test/generator_test.rb +0 -19
  62. data/test/processor_test.rb +0 -49
  63. data/test/queue_test.rb +0 -69
  64. data/test/test_helper.rb +0 -14
@@ -1,61 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
- div.dialog {
15
- width: 95%;
16
- max-width: 33em;
17
- margin: 4em auto 0;
18
- }
19
- div.dialog > div {
20
- border: 1px solid #CCC;
21
- border-right-color: #999;
22
- border-left-color: #999;
23
- border-bottom-color: #BBB;
24
- border-top: #B00100 solid 4px;
25
- border-top-left-radius: 9px;
26
- border-top-right-radius: 9px;
27
- background-color: white;
28
- padding: 7px 12% 0;
29
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
- }
31
- h1 {
32
- font-size: 100%;
33
- color: #730E15;
34
- line-height: 1.5em;
35
- }
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- </style>
51
- </head>
52
- <body>
53
- <div class="dialog">
54
- <div>
55
- <h1>The page you were looking for doesn't exist.</h1>
56
- <p>You may have mistyped the address or the page may have moved.</p>
57
- </div>
58
- <p>If you are the application owner check the logs for more information.</p>
59
- </div>
60
- </body>
61
- </html>
@@ -1,61 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
- div.dialog {
15
- width: 95%;
16
- max-width: 33em;
17
- margin: 4em auto 0;
18
- }
19
- div.dialog > div {
20
- border: 1px solid #CCC;
21
- border-right-color: #999;
22
- border-left-color: #999;
23
- border-bottom-color: #BBB;
24
- border-top: #B00100 solid 4px;
25
- border-top-left-radius: 9px;
26
- border-top-right-radius: 9px;
27
- background-color: white;
28
- padding: 7px 12% 0;
29
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
- }
31
- h1 {
32
- font-size: 100%;
33
- color: #730E15;
34
- line-height: 1.5em;
35
- }
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- </style>
51
- </head>
52
- <body>
53
- <div class="dialog">
54
- <div>
55
- <h1>The change you wanted was rejected.</h1>
56
- <p>Maybe you tried to change something you didn't have access to.</p>
57
- </div>
58
- <p>If you are the application owner check the logs for more information.</p>
59
- </div>
60
- </body>
61
- </html>
@@ -1,60 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
- div.dialog {
15
- width: 95%;
16
- max-width: 33em;
17
- margin: 4em auto 0;
18
- }
19
- div.dialog > div {
20
- border: 1px solid #CCC;
21
- border-right-color: #999;
22
- border-left-color: #999;
23
- border-bottom-color: #BBB;
24
- border-top: #B00100 solid 4px;
25
- border-top-left-radius: 9px;
26
- border-top-right-radius: 9px;
27
- background-color: white;
28
- padding: 7px 12% 0;
29
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
- }
31
- h1 {
32
- font-size: 100%;
33
- color: #730E15;
34
- line-height: 1.5em;
35
- }
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- </style>
51
- </head>
52
- <body>
53
- <div class="dialog">
54
- <div>
55
- <h1>We're sorry, but something went wrong.</h1>
56
- </div>
57
- <p>If you are the application owner check the logs for more information.</p>
58
- </div>
59
- </body>
60
- </html>
File without changes
@@ -1,19 +0,0 @@
1
- require 'test_helper'
2
- require 'rails/generators'
3
- require 'generators/sidejobs/install/install_generator'
4
-
5
- class GeneratorsTest < Rails::Generators::TestCase
6
- destination Rails.root.join('tmp')
7
-
8
- teardown do
9
- FileUtils.rm_rf destination_root
10
- end
11
-
12
- test 'install' do
13
- self.class.tests Sidejobs::Generators::InstallGenerator
14
- run_generator
15
- assert_file 'config/initializers/sidejobs.rb'
16
- assert_migration 'db/migrate/create_sidejobs.rb'
17
- end
18
-
19
- end
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ProcessorTest < ActiveSupport::TestCase
4
-
5
- setup do
6
- @processor = Sidejobs::Processor.new
7
- @batch_size = Sidejobs.configuration.batch_size
8
- @max_attempts = Sidejobs.configuration.max_attempts
9
- end
10
-
11
- test 'process' do
12
- UserMailer.invite('test@mail.com').deliver_later
13
- @processor.process
14
- job = Sidejobs::Job.last
15
- assert job.complete?
16
- assert_nil job.error
17
- assert_equal 1, job.attempts
18
- assert_operator job.completed_at, :>, job.processed_at
19
- end
20
-
21
- test 'batch' do
22
- (@batch_size + 4).times do
23
- UserMailer.invite('test@mail.com').deliver_later
24
- end
25
- @processor.process
26
- assert_equal @batch_size, Sidejobs::Job.complete.count
27
- assert_equal 0, Sidejobs::Job.processing.count
28
- assert_equal 4, Sidejobs::Job.pending.count
29
-
30
- Sidejobs::Job.last.update status: 'processing', processed_at: Time.now
31
- @processor.process
32
- assert_equal (@batch_size + 3), Sidejobs::Job.complete.count
33
- assert_equal 1, Sidejobs::Job.processing.count
34
- assert_equal 0, Sidejobs::Job.pending.count
35
- end
36
-
37
- test 'retries' do
38
- ShareProductsJob.perform_later
39
- (@max_attempts + 1).times do
40
- @processor.process
41
- end
42
- job = Sidejobs::Job.last
43
- assert job.failing?
44
- assert_equal 'Social network unavailable', job.error
45
- assert_equal @max_attempts, job.attempts
46
- assert_operator job.failed_at, :>, job.processed_at
47
- end
48
-
49
- end
@@ -1,69 +0,0 @@
1
- require 'test_helper'
2
-
3
- class QueueTest < ActiveSupport::TestCase
4
-
5
- test 'enqueue' do
6
- UserMailer.invite('test@mail.com').deliver_later
7
- job = Sidejobs::Job.last
8
- assert_equal 'mailers', job.queue
9
- assert_equal 80, job.priority
10
- assert_nil job.scheduled_at
11
-
12
- ChargeSubscriptionsJob.perform_later
13
- job = Sidejobs::Job.last
14
- assert_equal 'high_priority', job.queue
15
- assert_equal 60, job.priority
16
- assert_nil job.scheduled_at
17
-
18
- SendNewslettersJob.perform_later
19
- job = Sidejobs::Job.last
20
- assert_equal 'default', job.queue
21
- assert_equal 40, job.priority
22
- assert_nil job.scheduled_at
23
-
24
- UpdateExchangesJob.perform_later
25
- job = Sidejobs::Job.last
26
- assert_equal 'low_priority', job.queue
27
- assert_equal 20, job.priority
28
- assert_nil job.scheduled_at
29
-
30
- ClearGuestUsersJob.perform_later
31
- job = Sidejobs::Job.last
32
- assert_equal 'other', job.queue
33
- assert_equal 0, job.priority
34
- assert_nil job.scheduled_at
35
-
36
- time = 10.hours.from_now
37
-
38
- UserMailer.invite('test@mail.com').deliver_later wait_until: time
39
- job = Sidejobs::Job.last
40
- assert_equal 'mailers', job.queue
41
- assert_equal 80, job.priority
42
- assert_equal time.to_i, job.scheduled_at.to_i
43
-
44
- ChargeSubscriptionsJob.set(wait_until: time).perform_later
45
- job = Sidejobs::Job.last
46
- assert_equal 'high_priority', job.queue
47
- assert_equal 60, job.priority
48
- assert_equal time.to_i, job.scheduled_at.to_i
49
-
50
- SendNewslettersJob.set(wait_until: time).perform_later
51
- job = Sidejobs::Job.last
52
- assert_equal 'default', job.queue
53
- assert_equal 40, job.priority
54
- assert_equal time.to_i, job.scheduled_at.to_i
55
-
56
- UpdateExchangesJob.set(wait_until: time).perform_later
57
- job = Sidejobs::Job.last
58
- assert_equal 'low_priority', job.queue
59
- assert_equal 20, job.priority
60
- assert_equal time.to_i, job.scheduled_at.to_i
61
-
62
- ClearGuestUsersJob.set(wait_until: time).perform_later
63
- job = Sidejobs::Job.last
64
- assert_equal 'other', job.queue
65
- assert_equal 0, job.priority
66
- assert_equal time.to_i, job.scheduled_at.to_i
67
- end
68
-
69
- end
@@ -1,14 +0,0 @@
1
- # Configure Rails Environment
2
- ENV['RAILS_ENV'] = 'test'
3
-
4
- require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
5
- ActiveRecord::Migrator.migrations_paths = [File.expand_path('../../test/dummy/db/migrate', __FILE__)]
6
- require 'rails/test_help'
7
- require 'mocha/mini_test'
8
-
9
- # Filter out Minitest backtrace while allowing backtrace from other libraries
10
- # to be shown.
11
- Minitest.backtrace_filter = Minitest::BacktraceFilter.new
12
-
13
- # Load support files
14
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }