sidekiq-unique-jobs 5.0.2 → 5.0.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sidekiq-unique-jobs might be problematic. Click here for more details.

Files changed (207) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +8 -0
  3. data/.rubocop.yml +20 -13
  4. data/.simplecov +1 -1
  5. data/.travis.yml +30 -20
  6. data/Appraisals +10 -2
  7. data/CHANGELOG.md +33 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +13 -12
  10. data/LICENSE.txt +21 -0
  11. data/README.md +48 -4
  12. data/Rakefile +0 -1
  13. data/bin/bench +1 -1
  14. data/lib/sidekiq/simulator.rb +4 -10
  15. data/lib/sidekiq-unique-jobs.rb +16 -6
  16. data/lib/sidekiq_unique_jobs/cli.rb +14 -12
  17. data/lib/sidekiq_unique_jobs/client/middleware.rb +2 -0
  18. data/lib/sidekiq_unique_jobs/config.rb +2 -0
  19. data/lib/sidekiq_unique_jobs/constants.rb +20 -17
  20. data/lib/sidekiq_unique_jobs/core_ext.rb +18 -0
  21. data/lib/sidekiq_unique_jobs/lock/until_and_while_executing.rb +2 -0
  22. data/lib/sidekiq_unique_jobs/lock/until_executed.rb +4 -5
  23. data/lib/sidekiq_unique_jobs/lock/until_executing.rb +2 -0
  24. data/lib/sidekiq_unique_jobs/lock/until_timeout.rb +2 -0
  25. data/lib/sidekiq_unique_jobs/lock/while_executing.rb +10 -9
  26. data/lib/sidekiq_unique_jobs/lock.rb +2 -0
  27. data/lib/sidekiq_unique_jobs/middleware.rb +2 -0
  28. data/lib/sidekiq_unique_jobs/normalizer.rb +3 -1
  29. data/lib/sidekiq_unique_jobs/options_with_fallback.rb +22 -3
  30. data/lib/sidekiq_unique_jobs/run_lock_failed.rb +2 -0
  31. data/lib/sidekiq_unique_jobs/script_mock.rb +16 -15
  32. data/lib/sidekiq_unique_jobs/scripts/acquire_lock.rb +2 -0
  33. data/lib/sidekiq_unique_jobs/scripts/release_lock.rb +2 -0
  34. data/lib/sidekiq_unique_jobs/scripts.rb +17 -12
  35. data/lib/sidekiq_unique_jobs/server/middleware.rb +2 -0
  36. data/lib/sidekiq_unique_jobs/sidekiq_unique_ext.rb +4 -14
  37. data/lib/sidekiq_unique_jobs/testing/sidekiq_overrides.rb +2 -0
  38. data/lib/sidekiq_unique_jobs/testing.rb +4 -2
  39. data/lib/sidekiq_unique_jobs/timeout_calculator.rb +2 -0
  40. data/lib/sidekiq_unique_jobs/unique_args.rb +27 -14
  41. data/lib/sidekiq_unique_jobs/unlockable.rb +6 -6
  42. data/lib/sidekiq_unique_jobs/util.rb +34 -14
  43. data/lib/sidekiq_unique_jobs/version.rb +3 -1
  44. data/redis/acquire_lock.lua +1 -1
  45. data/sidekiq-unique-jobs.gemspec +27 -23
  46. metadata +44 -212
  47. data/LICENSE +0 -13
  48. data/circle.yml +0 -41
  49. data/gemfiles/sidekiq_4.0.gemfile +0 -22
  50. data/gemfiles/sidekiq_4.1.gemfile +0 -22
  51. data/gemfiles/sidekiq_4.2.gemfile +0 -22
  52. data/gemfiles/sidekiq_5.0.gemfile +0 -22
  53. data/gemfiles/sidekiq_develop.gemfile +0 -22
  54. data/rails_example/.env +0 -12
  55. data/rails_example/.env.test +0 -12
  56. data/rails_example/.gitignore +0 -13
  57. data/rails_example/.rspec +0 -2
  58. data/rails_example/Gemfile +0 -38
  59. data/rails_example/Procfile +0 -2
  60. data/rails_example/README.rdoc +0 -28
  61. data/rails_example/Rakefile +0 -6
  62. data/rails_example/app/assets/images/.keep +0 -0
  63. data/rails_example/app/assets/javascripts/application.js +0 -16
  64. data/rails_example/app/assets/stylesheets/application.css +0 -15
  65. data/rails_example/app/channels/appearance_channel.rb +0 -17
  66. data/rails_example/app/channels/application_cable/channel.rb +0 -4
  67. data/rails_example/app/channels/application_cable/connection.rb +0 -9
  68. data/rails_example/app/channels/post_channel.rb +0 -5
  69. data/rails_example/app/controllers/application_controller.rb +0 -5
  70. data/rails_example/app/controllers/concerns/.keep +0 -0
  71. data/rails_example/app/controllers/work_controller.rb +0 -39
  72. data/rails_example/app/helpers/application_helper.rb +0 -2
  73. data/rails_example/app/mailers/.keep +0 -0
  74. data/rails_example/app/models/.keep +0 -0
  75. data/rails_example/app/models/application_record.rb +0 -3
  76. data/rails_example/app/models/concerns/.keep +0 -0
  77. data/rails_example/app/models/guest.rb +0 -18
  78. data/rails_example/app/models/post.rb +0 -2
  79. data/rails_example/app/views/layouts/application.html.erb +0 -15
  80. data/rails_example/app/workers/simple_worker.rb +0 -15
  81. data/rails_example/app/workers/slow_until_executing_worker.rb +0 -15
  82. data/rails_example/app/workers/spawn_simple_worker.rb +0 -10
  83. data/rails_example/app/workers/while_executing_worker.rb +0 -12
  84. data/rails_example/app/workers/without_args_worker.rb +0 -16
  85. data/rails_example/app/workers/without_argument_worker.rb +0 -12
  86. data/rails_example/bin/bundle +0 -3
  87. data/rails_example/bin/check_or_setup_db +0 -56
  88. data/rails_example/bin/docker-setup +0 -20
  89. data/rails_example/bin/rails +0 -4
  90. data/rails_example/bin/rake +0 -4
  91. data/rails_example/bin/setup +0 -34
  92. data/rails_example/bin/update +0 -29
  93. data/rails_example/cable.ru +0 -6
  94. data/rails_example/common-services.yml +0 -52
  95. data/rails_example/config/application.rb +0 -27
  96. data/rails_example/config/boot.rb +0 -3
  97. data/rails_example/config/cable.yml +0 -9
  98. data/rails_example/config/database.docker.yml +0 -12
  99. data/rails_example/config/database.yml +0 -19
  100. data/rails_example/config/environment.rb +0 -5
  101. data/rails_example/config/environments/development.rb +0 -54
  102. data/rails_example/config/environments/production.rb +0 -86
  103. data/rails_example/config/environments/test.rb +0 -42
  104. data/rails_example/config/initializers/application_controller_renderer.rb +0 -6
  105. data/rails_example/config/initializers/assets.rb +0 -11
  106. data/rails_example/config/initializers/backtrace_silencers.rb +0 -9
  107. data/rails_example/config/initializers/cookies_serializer.rb +0 -5
  108. data/rails_example/config/initializers/filter_parameter_logging.rb +0 -4
  109. data/rails_example/config/initializers/inflections.rb +0 -16
  110. data/rails_example/config/initializers/mime_types.rb +0 -4
  111. data/rails_example/config/initializers/new_framework_defaults.rb +0 -23
  112. data/rails_example/config/initializers/session_store.rb +0 -3
  113. data/rails_example/config/initializers/sidekiq.rb +0 -13
  114. data/rails_example/config/initializers/wrap_parameters.rb +0 -14
  115. data/rails_example/config/locales/en.yml +0 -23
  116. data/rails_example/config/puma.rb +0 -38
  117. data/rails_example/config/routes.rb +0 -8
  118. data/rails_example/config/secrets.yml +0 -22
  119. data/rails_example/config/sidekiq.yml +0 -6
  120. data/rails_example/config/spring.rb +0 -6
  121. data/rails_example/config.ru +0 -4
  122. data/rails_example/db/migrate/20160724111322_create_posts.rb +0 -12
  123. data/rails_example/db/schema.rb +0 -25
  124. data/rails_example/db/seeds.rb +0 -7
  125. data/rails_example/dev-entrypoint.sh +0 -55
  126. data/rails_example/dev.env +0 -12
  127. data/rails_example/docker/rails.Dockerfile +0 -27
  128. data/rails_example/docker-compose.yml +0 -71
  129. data/rails_example/lib/assets/.keep +0 -0
  130. data/rails_example/lib/tasks/.keep +0 -0
  131. data/rails_example/log/.keep +0 -0
  132. data/rails_example/public/404.html +0 -67
  133. data/rails_example/public/422.html +0 -67
  134. data/rails_example/public/500.html +0 -66
  135. data/rails_example/public/favicon.ico +0 -0
  136. data/rails_example/public/robots.txt +0 -5
  137. data/rails_example/simple.ru +0 -12
  138. data/rails_example/spec/controllers/work_controller_mock_spec.rb +0 -91
  139. data/rails_example/spec/controllers/work_controller_spec.rb +0 -77
  140. data/rails_example/spec/factories/posts.rb +0 -8
  141. data/rails_example/spec/models/post_spec.rb +0 -4
  142. data/rails_example/spec/rails_helper.rb +0 -20
  143. data/rails_example/spec/spec_helper.rb +0 -20
  144. data/rails_example/spec/support/sidekiq_meta.rb +0 -12
  145. data/rails_example/spec/workers/simple_worker_spec.rb +0 -4
  146. data/rails_example/vendor/assets/javascripts/.keep +0 -0
  147. data/rails_example/vendor/assets/stylesheets/.keep +0 -0
  148. data/spec/jobs/another_unique_job.rb +0 -13
  149. data/spec/jobs/custom_queue_job.rb +0 -5
  150. data/spec/jobs/custom_queue_job_with_filter_method.rb +0 -7
  151. data/spec/jobs/custom_queue_job_with_filter_proc.rb +0 -10
  152. data/spec/jobs/expiring_job.rb +0 -4
  153. data/spec/jobs/inline_worker.rb +0 -8
  154. data/spec/jobs/just_a_worker.rb +0 -7
  155. data/spec/jobs/long_running_job.rb +0 -6
  156. data/spec/jobs/main_job.rb +0 -7
  157. data/spec/jobs/my_job.rb +0 -12
  158. data/spec/jobs/my_unique_job.rb +0 -11
  159. data/spec/jobs/my_unique_job_with_filter_method.rb +0 -17
  160. data/spec/jobs/my_unique_job_with_filter_proc.rb +0 -15
  161. data/spec/jobs/notify_worker.rb +0 -10
  162. data/spec/jobs/plain_class.rb +0 -3
  163. data/spec/jobs/simple_worker.rb +0 -11
  164. data/spec/jobs/spawn_simple_worker.rb +0 -8
  165. data/spec/jobs/test_class.rb +0 -3
  166. data/spec/jobs/unique_job_with_conditional_parameter.rb +0 -14
  167. data/spec/jobs/unique_job_with_filter_method.rb +0 -18
  168. data/spec/jobs/unique_job_with_nil_unique_args.rb +0 -16
  169. data/spec/jobs/unique_job_with_no_unique_args_method.rb +0 -12
  170. data/spec/jobs/unique_job_withthout_unique_args_parameter.rb +0 -14
  171. data/spec/jobs/unique_on_all_queues_job.rb +0 -13
  172. data/spec/jobs/until_and_while_executing_job.rb +0 -7
  173. data/spec/jobs/until_executed_job.rb +0 -17
  174. data/spec/jobs/until_executing_job.rb +0 -7
  175. data/spec/jobs/until_global_timeout_job.rb +0 -8
  176. data/spec/jobs/until_timeout_job.rb +0 -8
  177. data/spec/jobs/while_executing_job.rb +0 -12
  178. data/spec/jobs/without_argument_job.rb +0 -9
  179. data/spec/lib/sidekiq_unique_jobs/cli_spec.rb +0 -183
  180. data/spec/lib/sidekiq_unique_jobs/client/middleware_spec.rb +0 -316
  181. data/spec/lib/sidekiq_unique_jobs/config_spec.rb +0 -84
  182. data/spec/lib/sidekiq_unique_jobs/core_ext_spec.rb +0 -25
  183. data/spec/lib/sidekiq_unique_jobs/lock/until_and_while_executing_spec.rb +0 -42
  184. data/spec/lib/sidekiq_unique_jobs/lock/until_executed_spec.rb +0 -37
  185. data/spec/lib/sidekiq_unique_jobs/lock/until_timeout_spec.rb +0 -26
  186. data/spec/lib/sidekiq_unique_jobs/lock/while_executing_spec.rb +0 -86
  187. data/spec/lib/sidekiq_unique_jobs/normalizer_spec.rb +0 -21
  188. data/spec/lib/sidekiq_unique_jobs/options_with_fallback_spec.rb +0 -113
  189. data/spec/lib/sidekiq_unique_jobs/queue_lock_timeout_calculator_spec.rb +0 -47
  190. data/spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb +0 -36
  191. data/spec/lib/sidekiq_unique_jobs/script_mock_spec.rb +0 -88
  192. data/spec/lib/sidekiq_unique_jobs/scripts/acquire_lock_spec.rb +0 -50
  193. data/spec/lib/sidekiq_unique_jobs/scripts/release_lock_spec.rb +0 -41
  194. data/spec/lib/sidekiq_unique_jobs/scripts_spec.rb +0 -68
  195. data/spec/lib/sidekiq_unique_jobs/server/middleware_spec.rb +0 -78
  196. data/spec/lib/sidekiq_unique_jobs/sidekiq_testing_enabled_spec.rb +0 -164
  197. data/spec/lib/sidekiq_unique_jobs/sidekiq_unique_ext_spec.rb +0 -75
  198. data/spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb +0 -41
  199. data/spec/lib/sidekiq_unique_jobs/timeout_calculator_spec.rb +0 -70
  200. data/spec/lib/sidekiq_unique_jobs/unique_args_spec.rb +0 -257
  201. data/spec/lib/sidekiq_unique_jobs/unlockable_spec.rb +0 -37
  202. data/spec/lib/sidekiq_unique_jobs/util_spec.rb +0 -81
  203. data/spec/spec_helper.rb +0 -92
  204. data/spec/support/matchers/redis_matchers.rb +0 -29
  205. data/spec/support/ruby_meta.rb +0 -17
  206. data/spec/support/sidekiq_meta.rb +0 -30
  207. data/spec/support/unique_macros.rb +0 -71
@@ -1,67 +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
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,67 +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
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,66 +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
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
62
- </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
66
- </html>
File without changes
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-agent: *
5
- # Disallow: /
@@ -1,12 +0,0 @@
1
- # Easiest way to run Sidekiq::Web.
2
- # Run with "bundle exec rackup simple.ru"
3
-
4
- require 'sidekiq'
5
-
6
- # A Web process always runs as client, no need to configure server
7
- Sidekiq.configure_client do |config|
8
- config.redis = { url: 'redis://localhost:6379/0', size: 1, namespace: 'foo' }
9
- end
10
-
11
- require 'sidekiq/web'
12
- run Sidekiq::Web
@@ -1,91 +0,0 @@
1
- require 'rails_helper'
2
-
3
- MOCK_REDIS = MockRedis.new
4
-
5
- describe WorkController, 'with mock redis' do
6
- before do
7
- MOCK_REDIS.keys.each do |key|
8
- MOCK_REDIS.del(key)
9
- end
10
-
11
- Sidekiq::Queues.clear_all
12
- Sidekiq::Worker.clear_all
13
-
14
- SidekiqUniqueJobs.configure do |config|
15
- config.redis_test_mode = :mock
16
- end
17
- allow(Sidekiq).to receive(:redis).and_yield(MOCK_REDIS)
18
- end
19
-
20
- describe 'GET /work/duplicate_simple' do
21
- context 'when test mode is fake', sidekiq: :fake do
22
- specify do
23
- expect { get :duplicate_simple, params: { id: 10 } }
24
- .to change { SimpleWorker.jobs.size }
25
- .from(0)
26
- .to(1)
27
- end
28
- end
29
-
30
- context 'when test mode is disabled', sidekiq: :disable do
31
- specify do
32
- get :duplicate_simple, params: { id: 11 }
33
- Sidekiq.redis do |c|
34
- expect(c.keys.size).to eq(2)
35
- expect(c.llen('queue:default')).to eq(0)
36
- end
37
- end
38
- end
39
-
40
- context 'when test mode is inline', sidekiq: :inline do
41
- specify do
42
- get :duplicate_simple, params: { id: 12 }
43
- Sidekiq.redis do |c|
44
- expect(c).to be_a(MockRedis)
45
- expect(c.keys.size).to eq(0)
46
- expect(c.llen('queue:default')).to eq(0)
47
- end
48
- end
49
- end
50
- end
51
-
52
- describe 'GET /work/duplicate_nested' do
53
- context 'when test mode is fake', sidekiq: :fake do
54
- specify do
55
- expect { get :duplicate_nested, params: { id: 20 } }
56
- .to change { SpawnSimpleWorker.jobs.size }
57
- .from(0)
58
- .to(4)
59
-
60
- SpawnSimpleWorker.perform_one
61
- SpawnSimpleWorker.perform_one
62
- expect(SpawnSimpleWorker.jobs.size).to eq(2)
63
- expect(SimpleWorker.jobs.size).to eq(1)
64
- end
65
- end
66
-
67
- context 'when test mode is disabled', sidekiq: :disable do
68
- specify do
69
- get :duplicate_nested, params: { id: 21 }
70
-
71
- Sidekiq.redis do |c|
72
- expect(c).to be_a(MockRedis)
73
- expect(c.keys.size).to eq(0)
74
- expect(c.llen('queue:default')).to eq(0)
75
- end
76
- end
77
- end
78
-
79
- context 'when test mode is inline', sidekiq: :inline do
80
- specify do
81
- get :duplicate_nested, params: { id: 22 }
82
-
83
- Sidekiq.redis do |c|
84
- expect(c).to be_a(MockRedis)
85
- expect(c.keys.size).to eq(0)
86
- expect(c.llen('queue:default')).to eq(0)
87
- end
88
- end
89
- end
90
- end
91
- end
@@ -1,77 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe WorkController, 'with real redis' do
4
- before(:each) do
5
- SidekiqUniqueJobs.configure do |config|
6
- config.redis_test_mode = :redis
7
- end
8
-
9
- Sidekiq::Queues.clear_all
10
- Sidekiq.redis(&:flushdb)
11
- end
12
-
13
- describe 'GET /work/duplicate_simple' do
14
- context 'when test mode is fake', sidekiq: :fake do
15
- specify do
16
- expect { get :duplicate_simple, params: { id: 40 } }
17
- .to change { SimpleWorker.jobs.size }
18
- .from(0)
19
- .to(1)
20
- end
21
- end
22
-
23
- context 'when test mode is disabled', sidekiq: :disable do
24
- specify do
25
- get :duplicate_simple, params: { id: 41 }
26
- Sidekiq.redis do |c|
27
- expect(c.llen('queue:default')).to eq(1)
28
- end
29
- end
30
- end
31
-
32
- context 'when test mode is inline', sidekiq: :inline do
33
- specify do
34
- get :duplicate_simple, params: { id: 42 }
35
- Sidekiq.redis do |c|
36
- expect(c.llen('queue:default')).to eq(0)
37
- end
38
- end
39
- end
40
- end
41
-
42
- describe 'GET /work/duplicate_nested' do
43
- context 'when test mode is fake', sidekiq: :fake do
44
- specify do
45
- expect { get :duplicate_nested, params: { id: 34 } }
46
- .to change { SpawnSimpleWorker.jobs.size }
47
- .from(0)
48
- .to(4)
49
-
50
- SpawnSimpleWorker.perform_one
51
- SpawnSimpleWorker.perform_one
52
- expect(SpawnSimpleWorker.jobs.size).to eq(2)
53
- expect(SimpleWorker.jobs.size).to eq(1)
54
- end
55
- end
56
-
57
- context 'when test mode is disabled', sidekiq: :disable do
58
- specify do
59
- get :duplicate_nested, params: { id: 35 }
60
-
61
- Sidekiq.redis do |c|
62
- expect(c.llen('queue:default')).to eq(4)
63
- end
64
- end
65
- end
66
-
67
- context 'when test mode is inline', sidekiq: :inline do
68
- specify do
69
- get :duplicate_nested, params: { id: 36 }
70
-
71
- Sidekiq.redis do |c|
72
- expect(c.llen('queue:default')).to eq(0)
73
- end
74
- end
75
- end
76
- end
77
- end
@@ -1,8 +0,0 @@
1
- FactoryGirl.define do
2
- factory :post do
3
- title 'MyString'
4
- body 'MyText'
5
- excerpt 'MyString'
6
- read_count 1
7
- end
8
- end
@@ -1,4 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe Post, type: :model do
4
- end
@@ -1,20 +0,0 @@
1
- # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV['RAILS_ENV'] ||= 'test'
3
- require File.expand_path('../../config/environment', __FILE__)
4
- # Prevent database truncation if the environment is production
5
- abort('The Rails environment is running in production mode!') if Rails.env.production?
6
- require 'spec_helper'
7
- require 'rspec/rails'
8
- require 'pry-byebug'
9
- require 'sidekiq_unique_jobs/testing'
10
-
11
- Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
12
-
13
- ActiveRecord::Migration.maintain_test_schema!
14
-
15
- RSpec.configure do |config|
16
- config.use_transactional_fixtures = true
17
- config.infer_spec_type_from_file_location!
18
- config.filter_rails_from_backtrace!
19
- # config.filter_gems_from_backtrace("gem name")
20
- end
@@ -1,20 +0,0 @@
1
- RSpec.configure do |config|
2
- config.expect_with :rspec do |expectations|
3
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
4
- end
5
-
6
- config.mock_with :rspec do |mocks|
7
- mocks.verify_partial_doubles = true
8
- end
9
-
10
- config.shared_context_metadata_behavior = :apply_to_host_groups
11
- config.filter_run_when_matching :focus
12
- config.example_status_persistence_file_path = 'spec/examples.txt'
13
- # config.disable_monkey_patching!
14
-
15
- config.default_formatter = 'doc' if config.files_to_run.one?
16
-
17
- config.profile_examples = 10
18
- config.order = :random
19
- Kernel.srand config.seed
20
- end
@@ -1,12 +0,0 @@
1
- RSpec.configure do |config|
2
- config.before(:each) do |example|
3
- if (sidekiq = example.metadata[:sidekiq])
4
- sidekiq = :fake if sidekiq == true
5
- Sidekiq::Testing.send("#{sidekiq}!")
6
- end
7
- end
8
-
9
- config.after(:each) do |example|
10
- Sidekiq::Testing.disable! unless example.metadata[:sidekiq].nil?
11
- end
12
- end
@@ -1,4 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe SimpleWorker do
4
- end
File without changes
File without changes
@@ -1,13 +0,0 @@
1
- class AnotherUniqueJob
2
- include Sidekiq::Worker
3
- sidekiq_options queue: :working2, retry: 1, backtrace: 10,
4
- unique: :until_executed
5
-
6
- sidekiq_retries_exhausted do |msg|
7
- logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
8
- end
9
-
10
- def perform(*)
11
- # NO-OP
12
- end
13
- end
@@ -1,5 +0,0 @@
1
- class CustomQueueJob
2
- include Sidekiq::Worker
3
- sidekiq_options queue: :customqueue
4
- def perform(_); end
5
- end
@@ -1,7 +0,0 @@
1
- class CustomQueueJobWithFilterMethod < CustomQueueJob
2
- sidekiq_options unique: :until_executed, unique_args: :args_filter
3
-
4
- def self.args_filter(args)
5
- args.first
6
- end
7
- end
@@ -1,10 +0,0 @@
1
- class CustomQueueJobWithFilterProc < CustomQueueJob
2
- # slightly contrived example of munging args to the
3
- # worker and removing a random bit.
4
- sidekiq_options unique: :until_timeout,
5
- unique_args: (lambda do |args|
6
- options = args.extract_options!
7
- options.delete('random')
8
- args + [options]
9
- end)
10
- end
@@ -1,4 +0,0 @@
1
- class ExpiringJob
2
- include Sidekiq::Worker
3
- sidekiq_options unique: :until_executed, unique_expiration: 10 * 60
4
- end
@@ -1,8 +0,0 @@
1
- class InlineWorker
2
- include Sidekiq::Worker
3
- sidekiq_options unique: :while_executing
4
-
5
- def perform(x)
6
- TestClass.run(x)
7
- end
8
- end
@@ -1,7 +0,0 @@
1
- class JustAWorker
2
- include Sidekiq::Worker
3
-
4
- sidekiq_options unique: :until_executed, queue: 'testqueue'
5
-
6
- def perform; end
7
- end
@@ -1,6 +0,0 @@
1
- class LongRunningJob
2
- include Sidekiq::Worker
3
- sidekiq_options queue: :customqueue, retry: true, unique: :until_and_while_executing,
4
- run_lock_expiration: 7_200, retry_count: 10
5
- def perform(_one, _two); end
6
- end
@@ -1,7 +0,0 @@
1
- class MainJob
2
- include Sidekiq::Worker
3
- sidekiq_options queue: :customqueue, unique: :until_executed,
4
- log_duplicate_payload: true
5
-
6
- def perform(_); end
7
- end
data/spec/jobs/my_job.rb DELETED
@@ -1,12 +0,0 @@
1
- class MyJob
2
- include Sidekiq::Worker
3
- sidekiq_options queue: :working, retry: 1, backtrace: 10, unique: false
4
-
5
- sidekiq_retries_exhausted do |msg|
6
- logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
7
- end
8
-
9
- def perform(*)
10
- # NO-OP
11
- end
12
- end
@@ -1,11 +0,0 @@
1
- class MyUniqueJob
2
- include Sidekiq::Worker
3
- sidekiq_options(
4
- queue: :customqueue,
5
- retry: true,
6
- unique: :until_executed,
7
- unique_expiration: 7_200,
8
- retry_count: 10,
9
- )
10
- def perform(_one, _two); end
11
- end
@@ -1,17 +0,0 @@
1
- class MyUniqueJobWithFilterMethod
2
- include Sidekiq::Worker
3
- sidekiq_options queue: :customqueue,
4
- retry: true,
5
- backtrace: true,
6
- unique: :until_executed,
7
- unique_args: :filtered_args
8
-
9
- def perform(*)
10
- # NO-OP
11
- end
12
-
13
- def self.filtered_args(args)
14
- options = args.extract_options!
15
- [args.first, options['type']]
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- class MyUniqueJobWithFilterProc
2
- include Sidekiq::Worker
3
- sidekiq_options queue: :customqueue,
4
- retry: true,
5
- backtrace: true,
6
- unique: :until_executed,
7
- unique_args: (lambda do |args|
8
- options = args.extract_options!
9
- [args.first, options['type']]
10
- end)
11
-
12
- def perform(*)
13
- # NO-OP
14
- end
15
- end
@@ -1,10 +0,0 @@
1
- class NotifyWorker
2
- include Sidekiq::Worker
3
-
4
- sidekiq_options queue: :notify_worker,
5
- unique: :until_executed
6
-
7
- def perform(id, _blob)
8
- # puts "NotifyWorker -- #{id}"
9
- end
10
- end
@@ -1,3 +0,0 @@
1
- class PlainClass
2
- def run(_x); end
3
- end
@@ -1,11 +0,0 @@
1
- class SimpleWorker
2
- include Sidekiq::Worker
3
- sidekiq_options unique: :until_executed,
4
- unique_args: ->(args) { [args.first] },
5
- queue: :default,
6
- default_queue_lock_expiration: 5 * 60 * 60
7
-
8
- def perform(_arg)
9
- sleep 5
10
- end
11
- end
@@ -1,8 +0,0 @@
1
- class SpawnSimpleWorker
2
- include Sidekiq::Worker
3
- sidekiq_options queue: :not_default
4
-
5
- def perform(arg)
6
- SimpleWorker.perform_async arg
7
- end
8
- end
@@ -1,3 +0,0 @@
1
- class TestClass
2
- def self.run(_); end
3
- end
@@ -1,14 +0,0 @@
1
- class UniqueJobWithoutUniqueArgsParameter
2
- include Sidekiq::Worker
3
- sidekiq_options queue: :customqueue,
4
- retry: true,
5
- backtrace: true,
6
- unique: :until_executed,
7
- unique_args: :unique_args
8
-
9
- def perform(conditional = nil)
10
- # NO-OP
11
- end
12
-
13
- def self.unique_args; end
14
- end