sidekiq_publisher 1.5.0 → 1.6.0.pre0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 253cd9228ac0f0dbd5b1c62656da427ca5a70974e9f7b8b310266520e0aaa841
4
- data.tar.gz: 4e1f95c9bc0c42049bf80f9f2782649b2741cbbaae877c5d31d7dbd5735ebdea
3
+ metadata.gz: 02bfb6951b101ad86457fd06cf205ffc486ebbc60e38d82020b507bbdef7a719
4
+ data.tar.gz: 970f3c1eee45e69b7b5a95e4bc1875308e793c1eb95b3c5371515e8721af9d78
5
5
  SHA512:
6
- metadata.gz: c727d2b2aff3e503ce76c04f5afc99962ad18837b885ba281c4d9fdcd3af60e11afabacaa836162f07654a601821a62a59687af142906985c5949f61d8f6d5fb
7
- data.tar.gz: 7f5b6cdda88db63c148985c7b00d2c24106244294d224c83d8549e5741a1be8321f80e5e9ce28fac19b0c17df2b107689fb90a96ef24dc67676cc3221f5b8ade
6
+ metadata.gz: c736514d421542ac208fb4e3a065ca02d56957877ee58ec63aa5267cc51bfb34a173310869e1a733b28e51b717b4463eaf3361b9fcb064ca050caac27df1d18a
7
+ data.tar.gz: 5902f22f92d0ca5ad307b3ced3d185cf43a189be7dc2266e5737260d9c06f3b7b28492ad6cc4117ac68444a6af3365085d7d90ad199a04e28c00526c021380ff
@@ -1,5 +1,9 @@
1
1
  # sidekiq_publisher
2
2
 
3
+ ## v1.6.0 (unreleased)
4
+ - Support `Sidekiq::Testing` modes. This only applies to `SidekiqPublisher::Worker`
5
+ and not the `ActiveJob` adapter.
6
+
3
7
  ## v1.5.0
4
8
  - Expand sidekiq support to v5.0.x-v6.0.x.
5
9
 
data/README.md CHANGED
@@ -150,6 +150,31 @@ can be run with a rake task that is added via Railtie for Rails applications:
150
150
  bundle exec rake sidekiq_publisher:publish
151
151
  ```
152
152
 
153
+ ## Testing
154
+
155
+ ### Sidekiq
156
+
157
+ When using sidekiq_publisher directly with Sidekiq workers, the testing modes
158
+ provided by Sidekiq are supported.
159
+
160
+ Require the `sidekiq_publisher/testing` file. (This should only be done in test!)
161
+
162
+ ```ruby
163
+ require "sidekiq_publisher/testing"
164
+ ```
165
+
166
+ This file requires "sidekiq/testing" so there is no need to explictly require both.
167
+ Note that by default, Sidekiq sets the test mode to `fake` and stores jobs in a
168
+ `jobs` array for each worker class.
169
+
170
+ To have `SidekiqPublisher` continue to insert jobs into a table within tests
171
+ call `Sidekiq::Testing.disable!`.
172
+
173
+ ### ActiveJob
174
+
175
+ When using the sidekiq_publisher adapter for `ActiveJob`, use the `ActiveJob`
176
+ test adapter if you want to run jobs inline during tests.
177
+
153
178
  ## Development
154
179
 
155
180
  After checking out the repo, run `bin/setup` to install dependencies. Then,
@@ -18,6 +18,15 @@ module SidekiqPublisher
18
18
  scope :published, -> { where.not(published_at: nil) }
19
19
  scope :purgeable, -> { where("published_at < ?", Time.now.utc - job_retention_period) }
20
20
 
21
+ def self.create_job!(item)
22
+ create!(
23
+ job_class: item["class"].to_s,
24
+ args: item["args"],
25
+ run_at: item["at"],
26
+ queue: item["queue"]
27
+ )
28
+ end
29
+
21
30
  def self.generate_sidekiq_jid
22
31
  SecureRandom.hex(12)
23
32
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sidekiq_publisher"
4
+ require "sidekiq/testing"
5
+
6
+ module SidekiqPublisher
7
+ module Testing
8
+ def self.prepended(base)
9
+ base.singleton_class.public_send(:alias_method, :original_create_job!, :create_job!)
10
+ base.singleton_class.prepend(ClassMethods)
11
+ end
12
+
13
+ module ClassMethods
14
+ def create_job!(item)
15
+ if Sidekiq::Testing.enabled?
16
+ item["class"].sidekiq_client_push(item)
17
+ else
18
+ original_create_job!(item)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ SidekiqPublisher::Job.prepend(SidekiqPublisher::Testing)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqPublisher
4
- VERSION = "1.5.0"
4
+ VERSION = "1.6.0.pre0"
5
5
  end
@@ -10,12 +10,7 @@ module SidekiqPublisher
10
10
 
11
11
  module ClassMethods
12
12
  def client_push(item)
13
- SidekiqPublisher::Job.create!(
14
- job_class: item["class"].to_s,
15
- args: item["args"],
16
- run_at: item["at"],
17
- queue: item["queue"]
18
- )
13
+ SidekiqPublisher::Job.create_job!(item)
19
14
  end
20
15
  end
21
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0.pre0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-11 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob
@@ -306,6 +306,7 @@ files:
306
306
  - lib/sidekiq_publisher/report_unpublished_count.rb
307
307
  - lib/sidekiq_publisher/runner.rb
308
308
  - lib/sidekiq_publisher/tasks.rake
309
+ - lib/sidekiq_publisher/testing.rb
309
310
  - lib/sidekiq_publisher/version.rb
310
311
  - lib/sidekiq_publisher/worker.rb
311
312
  - log/.gitkeep
@@ -326,11 +327,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
326
327
  version: '0'
327
328
  required_rubygems_version: !ruby/object:Gem::Requirement
328
329
  requirements:
329
- - - ">="
330
+ - - ">"
330
331
  - !ruby/object:Gem::Version
331
- version: '0'
332
+ version: 1.3.1
332
333
  requirements: []
333
- rubygems_version: 3.0.6
334
+ rubyforge_project:
335
+ rubygems_version: 2.7.9
334
336
  signing_key:
335
337
  specification_version: 4
336
338
  summary: Publisher for enqueuing jobs to Sidekiq