seam 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/lib/seam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Seam
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
data/lib/seam/worker.rb CHANGED
@@ -28,6 +28,11 @@ module Seam
28
28
  operation_args[:seconds] = seconds
29
29
  end
30
30
 
31
+ def try_again_on time
32
+ @operation_to_execute = :try_again_on
33
+ operation_args[:time] = time
34
+ end
35
+
31
36
  attr_accessor :operation_args
32
37
  def operation_args
33
38
  @operation_args ||= {}
@@ -43,6 +48,10 @@ module Seam
43
48
 
44
49
  effort.next_execute_at = try_again_on
45
50
  end,
51
+ try_again_on: -> do
52
+ history[:try_again_on] = operation_args[:time]
53
+ effort.next_execute_at = operation_args[:time]
54
+ end,
46
55
  move_to_next_step: -> do
47
56
  effort.completed_steps << effort.next_step
48
57
 
@@ -94,12 +94,54 @@ describe "worker" do
94
94
  fresh_effort.next_step.must_equal "apple"
95
95
  end
96
96
 
97
- it "should not update the next execute date" do
97
+ it "should update the next execute date" do
98
98
  fresh_effort = Seam::Effort.find(effort.id)
99
99
  fresh_effort.next_execute_at.must_equal Time.parse('4/4/2013')
100
100
  end
101
101
  end
102
102
 
103
+ describe "try_again_on" do
104
+
105
+ describe "putting it off for one day" do
106
+ let(:effort) do
107
+ flow = Seam::Flow.new
108
+ flow.apple
109
+ flow.orange
110
+
111
+ e = flow.start( { first_name: 'John' } )
112
+ Seam::Effort.find(e.id)
113
+ end
114
+
115
+ before do
116
+ Timecop.freeze Time.parse('3/4/2013')
117
+ effort.next_step.must_equal "apple"
118
+
119
+ apple_worker = Seam::Worker.new
120
+ apple_worker.handles(:apple)
121
+ def apple_worker.process
122
+ try_again_on Time.parse('4/4/2013')
123
+ end
124
+
125
+ apple_worker.execute effort
126
+ end
127
+
128
+ it "should not update the next step" do
129
+ fresh_effort = Seam::Effort.find(effort.id)
130
+ fresh_effort.next_step.must_equal "apple"
131
+ end
132
+
133
+ it "should update the next execute date" do
134
+ fresh_effort = Seam::Effort.find(effort.id)
135
+ fresh_effort.next_execute_at.must_equal Time.parse('4/4/2013')
136
+ end
137
+
138
+ it "should update the history" do
139
+ fresh_effort = Seam::Effort.find(effort.id)
140
+ fresh_effort.history[0]['try_again_on'].must_equal Time.parse('4/4/2013')
141
+ end
142
+ end
143
+ end
144
+
103
145
  describe "more copmlex example" do
104
146
 
105
147
  let(:effort1) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-28 00:00:00.000000000 Z
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -228,7 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
228
  version: '0'
229
229
  segments:
230
230
  - 0
231
- hash: 1262616031405311885
231
+ hash: 2234950607663767066
232
232
  required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  none: false
234
234
  requirements:
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  version: '0'
238
238
  segments:
239
239
  - 0
240
- hash: 1262616031405311885
240
+ hash: 2234950607663767066
241
241
  requirements: []
242
242
  rubyforge_project:
243
243
  rubygems_version: 1.8.25