reactor 0.9.2 → 0.9.4

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
  SHA1:
3
- metadata.gz: 2c9de12205e0a8f3710f84534cb634fb2270b2e7
4
- data.tar.gz: dc1e8f7268a6ca74d744f3e524b742f9bf4fcec9
3
+ metadata.gz: 703450e6a7d56fa44bbfcfa8a9eed1263df5cc0b
4
+ data.tar.gz: f2e523fbc25b98abeb47b5f67d16b4cbf6b388e7
5
5
  SHA512:
6
- metadata.gz: c12f75f204e699aabd87ce268f06f1d4aebed23e96af6b9d844b76cb7998c2d9d6ca50e52b8439a5c25e6969659de676c376e73b61003410f9e360f8bb766ebb
7
- data.tar.gz: 218dd37d4a43ce958a2482347cc5b87e3fe43edad8ce2af84e5cd78f4ad1459ad9af9f9f897be7d98e35a205c3cdc91abd283c89c3d5267f2ca11565d21d4fb3
6
+ metadata.gz: b9d620ea6f462727a488d71c236420a18f36bca937916d58836604de3098d4a2e638527aa9c9e502ee0040cd55d79b179ccc1291b0f969c149d0369a7f38391f
7
+ data.tar.gz: 442cf06b6d18b3ef38347836d072b1cf3bfe1907f1d28e44048f1e451b74aec0006224741c27a5b1f07d977a0ae3ed25beb5670037d76f890c9e0d4ddef623cd
data/lib/reactor/event.rb CHANGED
@@ -66,9 +66,24 @@ class Reactor::Event
66
66
  def reschedule(name, data = {})
67
67
  scheduled_jobs = Sidekiq::ScheduledSet.new
68
68
  job = scheduled_jobs.detect do |job|
69
- job['class'] == self.name.to_s &&
70
- job['args'].first == name.to_s &&
71
- job.score.to_i == data[:was].to_i
69
+ same_class = job['class'] == self.name.to_s
70
+ same_name = job['args'].first == name.to_s
71
+ same_at = job.score.to_i == data[:was].to_i
72
+
73
+ if data[:actor]
74
+ job_data = job['args'].second
75
+
76
+ if job_data
77
+ same_actor = job_data['actor_type'] == data[:actor].class.name &&
78
+ job_data['actor_id'] == data[:actor].id
79
+ else
80
+ same_actor = false
81
+ end
82
+
83
+ same_class && same_name && same_at && same_actor
84
+ else
85
+ same_class && same_name && same_at
86
+ end
72
87
  end
73
88
 
74
89
  job.delete if job
@@ -1,3 +1,3 @@
1
1
  module Reactor
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.4"
3
3
  end
data/reactor.gemspec CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "sidekiq", "> 2.0"
22
- spec.add_dependency 'activerecord', '> 3.0'
21
+ spec.add_dependency "sidekiq", "< 4.0"
22
+ spec.add_dependency 'activerecord', '< 4.2'
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
data/spec/event_spec.rb CHANGED
@@ -84,16 +84,36 @@ describe Reactor::Event do
84
84
 
85
85
  it 'will schedule an event in the future even if that event was not previously scheduled in the past' do
86
86
  expect {
87
- jid = Reactor::Event.reschedule :no_old_turtule_time, at: (time + 2.hours), was: time
87
+ jid = Reactor::Event.reschedule :no_old_turtle_time, at: (time + 2.hours), was: time
88
88
  expect(scheduled.find_job(jid).score).to eq((time + 2.hours).to_f)
89
89
  }.to change{ scheduled.size }.by(1)
90
90
  end
91
91
 
92
92
  it 'will not schedule an event when the time passed in is nil' do
93
93
  expect {
94
- Reactor::Event.reschedule :no_old_turtule_time, at: nil, was: time
94
+ Reactor::Event.reschedule :no_old_turtle_time, at: nil, was: time
95
95
  }.to_not change{ scheduled.size }
96
96
  end
97
+
98
+ context 'when an actor is passed' do
99
+ let(:actor) { ArbitraryModel.create! }
100
+
101
+ it 'will not delete a job which is not associated with the actor' do
102
+ Reactor::Event.publish :turtle_time, at: time
103
+
104
+ expect {
105
+ Reactor::Event.reschedule :turtle_time, at: time + 2.hours, was: time, actor: actor
106
+ }.to change { scheduled.size}.from(1).to(2)
107
+ end
108
+
109
+ it 'will delete a job associated with the actor' do
110
+ Reactor::Event.publish :turtle_time, at: time, actor: actor
111
+
112
+ expect {
113
+ Reactor::Event.reschedule :turtle_time, at: time + 2.hours, was: time, actor: actor
114
+ }.not_to change { scheduled.size}.from(1)
115
+ end
116
+ end
97
117
  end
98
118
 
99
119
  describe 'event content' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - winfred
@@ -11,36 +11,36 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-12-15 00:00:00.000000000 Z
14
+ date: 2015-01-06 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sidekiq
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - ">"
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '2.0'
22
+ version: '4.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">"
27
+ - - "<"
28
28
  - !ruby/object:Gem::Version
29
- version: '2.0'
29
+ version: '4.0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: activerecord
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - ">"
34
+ - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '3.0'
36
+ version: '4.2'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ">"
41
+ - - "<"
42
42
  - !ruby/object:Gem::Version
43
- version: '3.0'
43
+ version: '4.2'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: bundler
46
46
  requirement: !ruby/object:Gem::Requirement
@@ -216,7 +216,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
216
  version: '0'
217
217
  requirements: []
218
218
  rubyforge_project:
219
- rubygems_version: 2.4.3
219
+ rubygems_version: 2.2.2
220
220
  signing_key:
221
221
  specification_version: 4
222
222
  summary: Sidekiq/ActiveRecord pubsub lib