sidekiq-unique-jobs 2.6.7 → 2.7.0

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 83bac10875a23de22118d256945b92fff679923a
4
- data.tar.gz: 71d378cca32301eebeb8c56bbfa1f76bdff3cd04
3
+ metadata.gz: 774a1d7ddc612a093c21bc717c839b2ad6c0eb86
4
+ data.tar.gz: 7b4c90512accf84894675887cee3addba328c9d5
5
5
  SHA512:
6
- metadata.gz: 43f2b221b8a1eaa2a42a334cc263fab1e66472316eedddfa8aab18a49f9d8524691ee7f7a0dbd3168cce0a31a0877c2cf08bbad6da24228591409b3712751aab
7
- data.tar.gz: c1fc0e67ab61a2c1def67563a0b3af418a76ff7645aa062183f2db093ddda532e852ad973cb21e5e54ad4ee54167e8862a848bae5910a89f90c02b13f6a6c33a
6
+ metadata.gz: 27f27613ec3338945275678c377ddd77500540ac28ebe4986ef45684c2461b20ea72c7e12c67d80feba466f141295f54bc23bbbfce30dc37304273596befc255
7
+ data.tar.gz: ce9a29bdd35166e5bdda72b8f45f48b0048d2f48e678d57c01c082441059f0b192c177d71d1b0e795805340dae7bf85f800bdc2bee609b66fba9b1cbca0c2442
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  Gemfile.lock
7
7
 
8
8
  .ruby-version
9
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format progress
3
+ --order random
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
+ services:
3
+ - redis-server
2
4
  rvm:
3
5
  - 1.9.3
4
6
  - jruby-19mode
@@ -1,3 +1,9 @@
1
+ ## v2.7.0
2
+ - Use mock_redis when testing in fake mode
3
+ - Replace minitest with rspec
4
+ - Add codeclimate badge
5
+ - Update travis with redis-server
6
+
1
7
  ## v2.6.5
2
8
  - via @sax - possibility to set which arguments should be counted as unique - https://github.com/form26/sidekiq-unique-jobs/pull/12
3
9
  - via @eduardosasso - possibility to set which arguments should be counted as unique - https://github.com/form26/sidekiq-unique-jobs/pull/11
data/Gemfile CHANGED
@@ -1,2 +1,10 @@
1
1
  source 'http://rubygems.org'
2
- gemspec
2
+ gemspec
3
+
4
+ group :development do
5
+ gem 'sidekiq', github: 'mperham/sidekiq'
6
+ end
7
+
8
+ gem 'pry'
9
+ gem 'pry-stack_explorer'
10
+ gem 'pry-debugger'
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # SidekiqUniqueJobs [![Build Status](https://travis-ci.org/form26/sidekiq-unique-jobs.png?branch=master)](https://travis-ci.org/form26/sidekiq-unique-jobs)
1
+ # SidekiqUniqueJobs [![Build Status](https://travis-ci.org/form26/sidekiq-unique-jobs.png?branch=master)](https://travis-ci.org/form26/sidekiq-unique-jobs) [![Code Climate](https://codeclimate.com/github/form26/sidekiq-unique-jobs.png)](https://codeclimate.com/github/form26/sidekiq-unique-jobs)
2
2
 
3
3
  The missing unique jobs for sidekiq
4
4
 
data/Rakefile CHANGED
@@ -1,11 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
- require 'rake/testtask'
4
- Rake::TestTask.new(:test) do |test|
5
- test.libs << 'test'
6
- #SO MUCH NOISE
7
- #test.warning = true
8
- test.pattern = 'test/**/test_*.rb'
9
- end
3
+ require 'rspec/core/rake_task'
10
4
 
11
- task :default => :test
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -4,49 +4,55 @@ module SidekiqUniqueJobs
4
4
  module Middleware
5
5
  module Client
6
6
  class UniqueJobs
7
- def call(worker_class, item, queue)
8
-
9
- klass = worker_class_constantize(worker_class)
7
+ attr_reader :item, :worker_class
10
8
 
11
- enabled = klass.get_sidekiq_options['unique'] || item['unique']
12
- unique_job_expiration = klass.get_sidekiq_options['unique_job_expiration']
9
+ def call(worker_class, item, queue)
10
+ @worker_class = worker_class_constantize(worker_class)
11
+ @item = item
13
12
 
14
- if enabled
13
+ if unique_enabled?
14
+ yield if unique?
15
+ else
16
+ yield
17
+ end
18
+ end
15
19
 
16
- payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload(item['class'], item['queue'], item['args'])
20
+ def unique?
21
+ if testing_enabled?
22
+ unique_for_connection?(SidekiqUniqueJobs.redis_mock)
23
+ else
24
+ Sidekiq.redis do |conn|
25
+ unique_for_connection?(conn)
26
+ end
27
+ end
28
+ end
17
29
 
18
- unique = false
30
+ def unique_for_connection?(conn)
31
+ unique = false
32
+ conn.watch(payload_hash)
19
33
 
20
- Sidekiq.redis do |conn|
34
+ if conn.get(payload_hash).to_i == 1 ||
35
+ (conn.get(payload_hash).to_i == 2 && item['at'])
36
+ # if the job is already queued, or is already scheduled and
37
+ # we're trying to schedule again, abort
38
+ conn.unwatch
39
+ else
40
+ # if the job was previously scheduled and is now being queued,
41
+ # or we've never seen it before
42
+ expires_at = unique_job_expiration || SidekiqUniqueJobs::Config.default_expiration
43
+ expires_at = ((Time.at(item['at']) - Time.now.utc) + expires_at).to_i if item['at']
21
44
 
22
- conn.watch(payload_hash)
23
-
24
- if conn.get(payload_hash).to_i == 1 ||
25
- (conn.get(payload_hash).to_i == 2 && item['at'])
26
- # if the job is already queued, or is already scheduled and
27
- # we're trying to schedule again, abort
28
- conn.unwatch
29
- else
30
- # if the job was previously scheduled and is now being queued,
31
- # or we've never seen it before
32
- expires_at = unique_job_expiration || SidekiqUniqueJobs::Config.default_expiration
33
- expires_at = ((Time.at(item['at']) - Time.now.utc) + expires_at).to_i if item['at']
34
-
35
- unique = conn.multi do
36
- # set value of 2 for scheduled jobs, 1 for queued jobs.
37
- conn.setex(payload_hash, expires_at, item['at'] ? 2 : 1)
38
- end
39
- end
45
+ unique = conn.multi do
46
+ # set value of 2 for scheduled jobs, 1 for queued jobs.
47
+ conn.setex(payload_hash, expires_at, item['at'] ? 2 : 1)
40
48
  end
41
- yield if unique
42
- else
43
- yield
44
49
  end
50
+ unique
45
51
  end
46
52
 
47
53
  protected
48
54
 
49
- # Attempt to constantize a string worker_class argument, always
55
+ # Attempt to constantize a string worker_class argument, always
50
56
  # failing back to the original argument.
51
57
  def worker_class_constantize(worker_class)
52
58
  if worker_class.is_a?(String)
@@ -56,7 +62,32 @@ module SidekiqUniqueJobs
56
62
  end
57
63
  end
58
64
 
65
+ private
66
+
67
+ def payload_hash
68
+ SidekiqUniqueJobs::PayloadHelper.get_payload(item['class'], item['queue'], item['args'])
69
+ end
70
+
71
+ # When sidekiq/testing is loaded, the Sidekiq::Testing constant is
72
+ # present and testing is enabled.
73
+ def testing_enabled?
74
+ if Sidekiq.const_defined?('Testing') && Sidekiq::Testing.enabled?
75
+ require 'sidekiq-unique-jobs/testing'
76
+ return true
77
+ end
78
+
79
+ false
80
+ end
81
+
82
+ def unique_enabled?
83
+ worker_class.get_sidekiq_options['unique'] || item['unique']
84
+ end
85
+
86
+ def unique_job_expiration
87
+ worker_class.get_sidekiq_options['unique_job_expiration']
88
+ end
89
+
59
90
  end
60
91
  end
61
92
  end
62
- end
93
+ end
@@ -0,0 +1,6 @@
1
+ require 'mock_redis'
2
+ module SidekiqUniqueJobs
3
+ def self.redis_mock
4
+ @redis_mock ||= MockRedis.new
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module SidekiqUniqueJobs
2
- VERSION = "2.6.7"
2
+ VERSION = "2.7.0"
3
3
  end
@@ -15,10 +15,10 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = SidekiqUniqueJobs::VERSION
17
17
  gem.add_dependency 'sidekiq', '~> 2.6'
18
- gem.add_development_dependency 'minitest', '~> 3'
19
- gem.add_development_dependency 'sinatra'
20
- gem.add_development_dependency 'slim'
18
+ gem.add_dependency 'mock_redis'
19
+ gem.add_development_dependency 'rspec', '>= 2'
21
20
  gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'rspec-sidekiq'
22
22
  gem.add_development_dependency 'activesupport', '~> 3'
23
23
  gem.add_development_dependency 'simplecov'
24
24
  end
@@ -1,11 +1,11 @@
1
- require 'helper'
1
+ require 'spec_helper'
2
2
  require 'celluloid'
3
3
  require 'sidekiq/worker'
4
4
  require "sidekiq-unique-jobs"
5
5
  require 'sidekiq/scheduled'
6
6
  require 'sidekiq-unique-jobs/middleware/server/unique_jobs'
7
7
 
8
- class TestClient < MiniTest::Unit::TestCase
8
+ describe "Client" do
9
9
  describe 'with real redis' do
10
10
  before do
11
11
  Sidekiq.redis = REDIS
@@ -27,19 +27,22 @@ class TestClient < MiniTest::Unit::TestCase
27
27
 
28
28
  it 'does not push duplicate messages when configured for unique only' do
29
29
  QueueWorker.sidekiq_options :unique => true
30
- 10.times { Sidekiq::Client.push('class' => TestClient::QueueWorker, 'queue' => 'customqueue', 'args' => [1, 2]) }
31
- assert_equal 1, Sidekiq.redis {|c| c.llen("queue:customqueue") }
30
+ 10.times { Sidekiq::Client.push('class' => QueueWorker, 'queue' => 'customqueue', 'args' => [1, 2]) }
31
+ result = Sidekiq.redis {|c| c.llen("queue:customqueue") }
32
+ expect(result).to eq 1
32
33
  end
33
34
 
34
35
  it 'does not queue duplicates when when calling delay' do
35
36
  10.times { PlainClass.delay(unique: true, queue: 'customqueue').run(1) }
36
- assert_equal 1, Sidekiq.redis {|c| c.llen("queue:customqueue") }
37
+ result = Sidekiq.redis {|c| c.llen("queue:customqueue") }
38
+ expect(result).to eq 1
37
39
  end
38
40
 
39
41
  it 'does not schedule duplicates when calling perform_in' do
40
42
  QueueWorker.sidekiq_options :unique => true
41
43
  10.times { QueueWorker.perform_in(60, [1, 2]) }
42
- assert_equal 1, Sidekiq.redis { |c| c.zcount("schedule", -1, Time.now.to_f + 2 * 60) }
44
+ result = Sidekiq.redis { |c| c.zcount("schedule", -1, Time.now.to_f + 2 * 60) }
45
+ expect(result).to eq 1
43
46
  end
44
47
 
45
48
  it 'enqueues previously scheduled job' do
@@ -47,26 +50,31 @@ class TestClient < MiniTest::Unit::TestCase
47
50
  QueueWorker.perform_in(60 * 60, 1, 2)
48
51
 
49
52
  # time passes and the job is pulled off the schedule:
50
- Sidekiq::Client.push('class' => TestClient::QueueWorker, 'queue' => 'customqueue', 'args' => [1, 2])
53
+ Sidekiq::Client.push('class' => QueueWorker, 'queue' => 'customqueue', 'args' => [1, 2])
51
54
 
52
- assert_equal 1, Sidekiq.redis {|c| c.llen("queue:customqueue") }
55
+ result = Sidekiq.redis {|c| c.llen("queue:customqueue") }
56
+ expect(result).to eq 1
53
57
  end
54
58
 
55
59
  it 'sets an expiration when provided by sidekiq options' do
56
60
  one_hour_expiration = 60 * 60
57
61
  QueueWorker.sidekiq_options :unique => true, :unique_job_expiration => one_hour_expiration
58
- Sidekiq::Client.push('class' => TestClient::QueueWorker, 'queue' => 'customqueue', 'args' => [1, 2])
62
+ Sidekiq::Client.push('class' => QueueWorker, 'queue' => 'customqueue', 'args' => [1, 2])
59
63
 
60
- payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload("TestClient::QueueWorker", "customqueue", [1, 2])
64
+ payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload("QueueWorker", "customqueue", [1, 2])
61
65
  actual_expires_at = Sidekiq.redis {|c| c.ttl(payload_hash) }
62
66
 
63
- assert_in_delta one_hour_expiration, actual_expires_at, 2
67
+ result = Sidekiq.redis {|c| c.llen("queue:customqueue") }
68
+ expect(actual_expires_at).to be_within(2).of(one_hour_expiration)
64
69
  end
65
70
 
66
71
  it 'does push duplicate messages when not configured for unique only' do
67
72
  QueueWorker.sidekiq_options :unique => false
68
- 10.times { Sidekiq::Client.push('class' => TestClient::QueueWorker, 'queue' => 'customqueue', 'args' => [1, 2]) }
69
- assert_equal 10, Sidekiq.redis {|c| c.llen("queue:customqueue") }
73
+ 10.times { Sidekiq::Client.push('class' => QueueWorker, 'queue' => 'customqueue', 'args' => [1, 2]) }
74
+ expect(Sidekiq.redis {|c| c.llen("queue:customqueue") }).to eq 10
75
+
76
+ result = Sidekiq.redis {|c| c.llen("queue:customqueue") }
77
+ expect(result).to eq 10
70
78
  end
71
79
 
72
80
  describe 'when unique_args is defined' do
@@ -87,22 +95,25 @@ class TestClient < MiniTest::Unit::TestCase
87
95
  end
88
96
 
89
97
  it 'does not push duplicate messages based on args filter method' do
90
- assert TestClient::QueueWorkerWithFilterMethod.respond_to?(:args_filter)
91
- assert_equal :args_filter, TestClient::QueueWorkerWithFilterMethod.get_sidekiq_options['unique_args']
98
+ expect(QueueWorkerWithFilterMethod).to respond_to(:args_filter)
99
+ expect(QueueWorkerWithFilterMethod.get_sidekiq_options['unique_args']).to eq :args_filter
100
+
92
101
 
93
102
  for i in (0..10).to_a
94
- Sidekiq::Client.push('class' => TestClient::QueueWorkerWithFilterMethod, 'queue' => 'customqueue', 'args' => [1, i])
103
+ Sidekiq::Client.push('class' => QueueWorkerWithFilterMethod, 'queue' => 'customqueue', 'args' => [1, i])
95
104
  end
96
- assert_equal 1, Sidekiq.redis {|c| c.llen("queue:customqueue") }
105
+ result = Sidekiq.redis {|c| c.llen("queue:customqueue") }
106
+ expect(result).to eq 1
97
107
  end
98
108
 
99
109
  it 'does not push duplicate messages based on args filter proc' do
100
- assert_kind_of Proc, TestClient::QueueWorkerWithFilterProc.get_sidekiq_options['unique_args']
110
+ expect(QueueWorkerWithFilterProc.get_sidekiq_options['unique_args']).to be_a(Proc)
101
111
 
102
112
  10.times do
103
- Sidekiq::Client.push('class' => TestClient::QueueWorkerWithFilterProc, 'queue' => 'customqueue', 'args' => [ 1, {:random => rand(), :name => "foobar"} ])
113
+ Sidekiq::Client.push('class' => QueueWorkerWithFilterProc, 'queue' => 'customqueue', 'args' => [ 1, {:random => rand(), :name => "foobar"} ])
104
114
  end
105
- assert_equal 1, Sidekiq.redis {|c| c.llen("queue:customqueue") }
115
+ result = Sidekiq.redis {|c| c.llen("queue:customqueue") }
116
+ expect(result).to eq 1
106
117
  end
107
118
  end
108
119
 
@@ -116,12 +127,12 @@ class TestClient < MiniTest::Unit::TestCase
116
127
  expected_expires_at = (Time.at(at) - Time.now.utc) + SidekiqUniqueJobs::Config.default_expiration
117
128
 
118
129
  QueueWorker.perform_in(at, 'mike')
119
- payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload("TestClient::QueueWorker", "customqueue", ['mike'])
130
+ payload_hash = SidekiqUniqueJobs::PayloadHelper.get_payload("QueueWorker", "customqueue", ['mike'])
120
131
 
121
132
  # deconstruct this into a time format we can use to get a decent delta for
122
133
  actual_expires_at = Sidekiq.redis {|c| c.ttl(payload_hash) }
123
134
 
124
- assert_in_delta expected_expires_at, actual_expires_at, 2
135
+ expect(actual_expires_at).to be_within(2).of(expected_expires_at)
125
136
  end
126
137
  end
127
138
  end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+ require 'sidekiq/worker'
3
+ require "sidekiq-unique-jobs"
4
+ require 'sidekiq/scheduled'
5
+ require 'sidekiq-unique-jobs/middleware/server/unique_jobs'
6
+
7
+ describe "When Sidekiq::Testing is enabled" do
8
+ describe 'when set to :fake!', sidekiq: :fake do
9
+ context "with unique worker" do
10
+ it "does not push duplicate messages" do
11
+ param = 'work'
12
+ expect(UniqueWorker).to have_enqueued_jobs(0)
13
+ UniqueWorker.perform_async(param)
14
+ expect(UniqueWorker).to have_enqueued_jobs(1)
15
+ expect(UniqueWorker).to have_enqueued_job(param)
16
+ UniqueWorker.perform_async(param)
17
+ expect(UniqueWorker).to have_enqueued_jobs(1)
18
+ end
19
+ end
20
+
21
+ context "with non-unique worker" do
22
+
23
+ it "pushes duplicates messages" do
24
+ param = 'work'
25
+ expect(MyWorker).to have_enqueued_jobs(0)
26
+ MyWorker.perform_async(param)
27
+ expect(MyWorker).to have_enqueued_jobs(1)
28
+ expect(MyWorker).to have_enqueued_job(param)
29
+ MyWorker.perform_async(param)
30
+ expect(MyWorker).to have_enqueued_jobs(2)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,8 +1,8 @@
1
- require 'helper'
1
+ require 'spec_helper'
2
2
  require 'sidekiq/worker'
3
3
  require 'sidekiq-unique-jobs/middleware/server/unique_jobs'
4
4
 
5
- class TestUnlockOrdering < MiniTest::Unit::TestCase
5
+ describe "Unlock order" do
6
6
  QUEUE = 'unlock_ordering'
7
7
 
8
8
  class BeforeYieldOrderingWorker
@@ -41,7 +41,7 @@ class TestUnlockOrdering < MiniTest::Unit::TestCase
41
41
  end
42
42
  end
43
43
 
44
- assert_nil result
44
+ expect(result).to eq nil
45
45
  end
46
46
  end
47
47
 
@@ -56,7 +56,7 @@ class TestUnlockOrdering < MiniTest::Unit::TestCase
56
56
  end
57
57
  end
58
58
 
59
- assert_equal '1', result
59
+ expect(result).to eq '1'
60
60
  end
61
61
  end
62
62
  end
@@ -0,0 +1,29 @@
1
+ $TESTING = true
2
+
3
+ begin
4
+ require 'pry'
5
+ rescue LoadError
6
+ end
7
+
8
+ require 'rspec/autorun'
9
+ require 'rspec'
10
+
11
+ require 'celluloid/test'
12
+ require 'sidekiq'
13
+ require 'sidekiq/util'
14
+ require 'sidekiq-unique-jobs'
15
+ Sidekiq.logger.level = Logger::ERROR
16
+
17
+ require 'sidekiq/testing'
18
+ require 'rspec-sidekiq'
19
+
20
+ Sidekiq::Testing.disable!
21
+
22
+ require 'sidekiq/redis_connection'
23
+ redis_url = ENV['REDIS_URL'] || 'redis://localhost/15'
24
+ REDIS = Sidekiq::RedisConnection.create(:url => redis_url, :namespace => 'testy')
25
+
26
+ Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each { |f| require f }
27
+ RSpec.configure do |config|
28
+ config.treat_symbols_as_metadata_keys_with_true_values = true
29
+ end
@@ -0,0 +1,13 @@
1
+ class MyWorker
2
+ include Sidekiq::Worker
3
+ sidekiq_options :queue => :working, :retry => 1, :backtrace => 10
4
+ sidekiq_options :unique => false
5
+
6
+ sidekiq_retries_exhausted do |msg|
7
+ Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
8
+ end
9
+
10
+ def perform(param)
11
+ puts param
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ RSpec.configure do |config|
2
+ config.before(:each) do # |example| TODO: Add this for RSpec 3
3
+ sidekiq = example.metadata[:sidekiq]
4
+ if sidekiq
5
+ sidekiq = :fake if sidekiq == true
6
+ Sidekiq::Testing.send("#{sidekiq}!")
7
+ end
8
+ end
9
+
10
+ config.after(:each) do # |example| TODO: Add this for RSpec 3
11
+ if sidekiq = example.metadata[:sidekiq]
12
+ Sidekiq::Testing.disable!
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ class UniqueWorker
2
+ include Sidekiq::Worker
3
+ sidekiq_options :queue => :working, :retry => 1, :backtrace => 10
4
+ sidekiq_options :unique => true
5
+
6
+ sidekiq_retries_exhausted do |msg|
7
+ Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
8
+ end
9
+
10
+ def perform(param)
11
+ puts param
12
+ end
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-unique-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.7
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-30 00:00:00.000000000 Z
11
+ date: 2013-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -25,35 +25,35 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.6'
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: mock_redis
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: '3'
34
- type: :development
33
+ version: '0'
34
+ type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
- version: '3'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: sinatra
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2'
55
55
  - !ruby/object:Gem::Dependency
56
- name: slim
56
+ name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rake
70
+ name: rspec-sidekiq
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '>='
@@ -116,6 +116,7 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - .gitignore
119
+ - .rspec
119
120
  - .travis.yml
120
121
  - CHANGELOG.md
121
122
  - Gemfile
@@ -128,12 +129,16 @@ files:
128
129
  - lib/sidekiq-unique-jobs/middleware/client/unique_jobs.rb
129
130
  - lib/sidekiq-unique-jobs/middleware/server/unique_jobs.rb
130
131
  - lib/sidekiq-unique-jobs/payload_helper.rb
132
+ - lib/sidekiq-unique-jobs/testing.rb
131
133
  - lib/sidekiq-unique-jobs/version.rb
132
134
  - sidekiq-unique-jobs.gemspec
133
- - test/helper.rb
134
- - test/lib/sidekiq/another_test_client.rb
135
- - test/lib/sidekiq/test_client.rb
136
- - test/lib/sidekiq/test_unlock_ordering.rb
135
+ - spec/lib/client_spec.rb
136
+ - spec/lib/sidekiq_testing_enabled_spec.rb
137
+ - spec/lib/unlock_order_spec.rb
138
+ - spec/spec_helper.rb
139
+ - spec/support/my_worker.rb
140
+ - spec/support/sidekiq_meta.rb
141
+ - spec/support/unique_worker.rb
137
142
  homepage: http://mperham.github.com/sidekiq
138
143
  licenses:
139
144
  - LGPL-3.0
@@ -154,13 +159,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
159
  version: '0'
155
160
  requirements: []
156
161
  rubyforge_project:
157
- rubygems_version: 2.0.7
162
+ rubygems_version: 2.1.11
158
163
  signing_key:
159
164
  specification_version: 4
160
165
  summary: The unique jobs that were removed from sidekiq
161
- test_files:
162
- - test/helper.rb
163
- - test/lib/sidekiq/another_test_client.rb
164
- - test/lib/sidekiq/test_client.rb
165
- - test/lib/sidekiq/test_unlock_ordering.rb
166
+ test_files: []
166
167
  has_rdoc:
@@ -1,16 +0,0 @@
1
- ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'test'
2
- if ENV.has_key?("SIMPLECOV")
3
- require 'simplecov'
4
- SimpleCov.start
5
- end
6
- require 'minitest/unit'
7
- require 'minitest/pride'
8
- require 'minitest/autorun'
9
-
10
- require 'sidekiq-unique-jobs'
11
- require "sidekiq"
12
- require 'sidekiq/util'
13
- Sidekiq.logger.level = Logger::ERROR
14
-
15
- require 'sidekiq/redis_connection'
16
- REDIS = Sidekiq::RedisConnection.create(:url => "redis://localhost/15", :namespace => 'testy')
@@ -1,28 +0,0 @@
1
- require 'helper'
2
- require 'sidekiq/worker'
3
- require "sidekiq-unique-jobs"
4
- require 'sidekiq/scheduled'
5
- require 'sidekiq-unique-jobs/middleware/server/unique_jobs'
6
-
7
- class AnotherTestClient < MiniTest::Unit::TestCase
8
- describe 'with real redis' do
9
- before do
10
- Sidekiq.redis = REDIS
11
- Sidekiq.redis {|c| c.flushdb }
12
- QueueWorker.sidekiq_options :unique => nil, :unique_job_expiration => nil
13
- end
14
-
15
- class QueueWorker
16
- include Sidekiq::Worker
17
- sidekiq_options :queue => 'customqueue'
18
- def perform(x)
19
- end
20
- end
21
-
22
- it 'does not push duplicate messages when configured for unique only' do
23
- QueueWorker.sidekiq_options :unique => true
24
- 10.times { Sidekiq::Client.push('class' => TestClient::QueueWorker, 'queue' => 'customqueue', 'args' => [1, 2]) }
25
- assert_equal 1, Sidekiq.redis {|c| c.llen("queue:customqueue") }
26
- end
27
- end
28
- end