reactor 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/reactor/models/concerns/publishable.rb +1 -1
- data/lib/reactor/version.rb +1 -1
- data/spec/models/concerns/publishable_spec.rb +27 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d94c9e88b1e39de193207ebfb0ac79144ec9506
|
4
|
+
data.tar.gz: e5d673c488dc337113cf581c715fcdeb1da9da09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4a8ac148d6b9c2d1bcf5686b7bd6a3db9247be7853bde3671d1b72bb01b982d3691b8c5470e26406b95a922c820578684097c68574274efa51b8a1414cc9a66
|
7
|
+
data.tar.gz: 5ade72a5fc8fc294710fd6be3910ef3f03f12daa0ad1f83f5cc353fe175475bd537e467fa06a5f83f827f577921d9ea35521123373764dc508f6cf57e77cbb24
|
@@ -49,7 +49,7 @@ module Reactor::Publishable
|
|
49
49
|
at: send(data[:at]),
|
50
50
|
actor: ( data[:actor] ? send(data[:actor]) : self ),
|
51
51
|
target: ( data[:target] ? self : nil),
|
52
|
-
was: previous_changes[
|
52
|
+
was: previous_changes[data[:at]].try(:first) || send("#{data[:at]}_was")
|
53
53
|
end
|
54
54
|
if data[:if]
|
55
55
|
need_to_fire = case (ifarg = data[:if])
|
data/lib/reactor/version.rb
CHANGED
@@ -8,15 +8,15 @@ class Auction < ActiveRecord::Base
|
|
8
8
|
belongs_to :pet
|
9
9
|
|
10
10
|
def ring_timeout
|
11
|
-
|
11
|
+
start_at + 30.seconds
|
12
12
|
end
|
13
13
|
|
14
14
|
def ring_timeout_was
|
15
|
-
|
15
|
+
previous_changes[:start_at][0] + 30.seconds
|
16
16
|
end
|
17
17
|
|
18
18
|
publishes :bell
|
19
|
-
publishes :ring, at: :ring_timeout, watch: :
|
19
|
+
publishes :ring, at: :ring_timeout, watch: :start_at
|
20
20
|
publishes :begin, at: :start_at
|
21
21
|
publishes :conditional_event_on_save, if: -> { we_want_it }
|
22
22
|
publishes :woof, actor: :pet, target: :self
|
@@ -55,20 +55,31 @@ describe Reactor::Publishable do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'reschedules an event when the :at time changes' do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
start_at = auction.start_at
|
59
|
+
new_start_at = start_at + 1.week
|
60
|
+
Reactor::Event.should_receive(:reschedule).with :ring, anything
|
61
|
+
Reactor::Event.should_receive(:reschedule).with :begin,
|
62
|
+
hash_including(
|
63
|
+
at: new_start_at,
|
64
|
+
actor: auction,
|
65
|
+
was: start_at
|
66
|
+
)
|
67
|
+
auction.start_at = new_start_at
|
68
|
+
auction.save!
|
69
|
+
end
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
71
|
+
it 'reschedules an event when the :watch field changes' do
|
72
|
+
ring_time = auction.ring_timeout
|
73
|
+
new_start_at = auction.start_at + 1.week
|
74
|
+
new_ring_time = new_start_at + 30.seconds
|
75
|
+
Reactor::Event.should_receive(:reschedule).with :begin, anything
|
76
|
+
Reactor::Event.should_receive(:reschedule).with :ring,
|
77
|
+
hash_including(
|
78
|
+
at: new_ring_time,
|
79
|
+
actor: auction,
|
80
|
+
was: ring_time
|
81
|
+
)
|
82
|
+
auction.start_at = new_start_at
|
72
83
|
auction.save!
|
73
84
|
end
|
74
85
|
|