ruote-kit 2.1.10 → 2.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/CHANGELOG.txt +10 -0
- data/Gemfile +21 -5
- data/LICENSE.txt +20 -0
- data/README.rdoc +132 -80
- data/Rakefile +4 -15
- data/TODO.txt +12 -0
- data/config.ru +22 -14
- data/lib/ruote-kit/application.rb +46 -22
- data/lib/ruote-kit/helpers/json_helpers.rb +280 -0
- data/lib/ruote-kit/helpers/link_helpers.rb +117 -0
- data/lib/ruote-kit/helpers/misc_helpers.rb +35 -0
- data/lib/ruote-kit/helpers/pagination_helpers.rb +30 -0
- data/lib/ruote-kit/helpers/render_helpers.rb +39 -92
- data/lib/ruote-kit/public/_ruote/images/favicon.ico +0 -0
- data/lib/ruote-kit/public/_ruote/images/ruote.png +0 -0
- data/lib/ruote-kit/public/_ruote/images/ruote_buttons.png +0 -0
- data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.4.2.min.js +154 -0
- data/lib/ruote-kit/public/_ruote/javascripts/rk.js +40 -0
- data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-editor.js +548 -0
- data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js +32 -1
- data/lib/ruote-kit/public/_ruote/stylesheets/reset.css +53 -0
- data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +355 -16
- data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +108 -0
- data/lib/ruote-kit/resources/errors.rb +46 -43
- data/lib/ruote-kit/resources/expressions.rb +92 -35
- data/lib/ruote-kit/resources/participants.rb +53 -0
- data/lib/ruote-kit/resources/processes.rb +68 -36
- data/lib/ruote-kit/resources/schedules.rb +27 -0
- data/lib/ruote-kit/resources/workitems.rb +93 -31
- data/lib/ruote-kit/spec/ruote_helpers.rb +25 -16
- data/lib/ruote-kit/version.rb +3 -1
- data/lib/ruote-kit/views/_pagination.html.haml +38 -0
- data/lib/ruote-kit/views/_tree_editor.html.haml +52 -0
- data/lib/ruote-kit/views/error.html.haml +69 -0
- data/lib/ruote-kit/views/errors.html.haml +28 -12
- data/lib/ruote-kit/views/expression.html.haml +161 -30
- data/lib/ruote-kit/views/expressions.html.haml +26 -21
- data/lib/ruote-kit/views/http_error.html.haml +11 -0
- data/lib/ruote-kit/views/index.html.haml +4 -0
- data/lib/ruote-kit/views/layout.html.haml +52 -32
- data/lib/ruote-kit/views/participants.html.haml +79 -0
- data/lib/ruote-kit/views/process.html.haml +109 -42
- data/lib/ruote-kit/views/process_launched.html.haml +6 -2
- data/lib/ruote-kit/views/processes.html.haml +55 -24
- data/lib/ruote-kit/views/processes_new.html.haml +36 -0
- data/lib/ruote-kit/views/schedules.html.haml +42 -0
- data/lib/ruote-kit/views/workitem.html.haml +83 -29
- data/lib/ruote-kit/views/workitems.html.haml +42 -19
- data/lib/ruote-kit.rb +17 -88
- data/ruote-kit.gemspec +68 -80
- data/spec/it_has_an_engine.rb +69 -0
- data/spec/resources/errors_spec.rb +198 -270
- data/spec/resources/expressions_spec.rb +308 -52
- data/spec/resources/index_spec.rb +28 -16
- data/spec/resources/participants_spec.rb +102 -0
- data/spec/resources/processes_spec.rb +218 -104
- data/spec/resources/schedules_spec.rb +97 -0
- data/spec/resources/workitems_spec.rb +195 -100
- data/spec/ruote-kit_configure_spec.rb +32 -75
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +31 -92
- data/spec/webapp_helpers_spec.rb +309 -0
- metadata +87 -152
- data/lib/ruote-kit/configuration.rb +0 -83
- data/lib/ruote-kit/helpers/engine_helpers.rb +0 -24
- data/lib/ruote-kit/helpers/form_helpers.rb +0 -11
- data/lib/ruote-kit/helpers/launch_item_parser.rb +0 -59
- data/lib/ruote-kit/helpers/navigation_helpers.rb +0 -54
- data/lib/ruote-kit/helpers.rb +0 -9
- data/lib/ruote-kit/public/_ruote/images/bg.gif +0 -0
- data/lib/ruote-kit/public/_ruote/images/bg_button_left.gif +0 -0
- data/lib/ruote-kit/public/_ruote/images/bg_button_left_cancel.gif +0 -0
- data/lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif +0 -0
- data/lib/ruote-kit/public/_ruote/images/bg_button_right.gif +0 -0
- data/lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js +0 -191
- data/lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js +0 -149
- data/lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css +0 -226
- data/lib/ruote-kit/public/_ruote/stylesheets/base.css +0 -336
- data/lib/ruote-kit/public/_ruote/stylesheets/style.css +0 -393
- data/lib/ruote-kit/views/launch_process.html.haml +0 -19
- data/lib/ruote-kit/views/process_failed_to_launch.html.haml +0 -7
- data/lib/ruote-kit/views/resource_not_found.html.haml +0 -7
- data/spec/helpers/render_helpers_spec.rb +0 -214
- data/spec/ruote-kit_spec.rb +0 -4
- data/spec/views/expressions.html.haml_spec.rb +0 -31
- data/spec/views/launch_process.html.haml_spec.rb +0 -22
- data/spec/views/process.html.haml_spec.rb +0 -17
- data/spec/views/process_launched.html.haml_spec.rb +0 -16
- data/spec/views/processes.html.haml_spec.rb +0 -31
- data/spec/views/workitems.html.haml_spec.rb +0 -69
@@ -1,121 +1,212 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
1
|
|
3
|
-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
undef :context if defined?(context)
|
5
|
+
|
6
|
+
|
7
|
+
def process_links(wfid)
|
8
|
+
[
|
9
|
+
{ 'href' => "/_ruote/processes/#{wfid}",
|
10
|
+
'rel' => 'self' },
|
11
|
+
{ 'href' => "/_ruote/processes/#{wfid}",
|
12
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process' },
|
13
|
+
{ 'href' => "/_ruote/expressions/#{wfid}",
|
14
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process_expressions' },
|
15
|
+
{ 'href' => "/_ruote/workitems/#{wfid}",
|
16
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process_workitems' },
|
17
|
+
{ 'href' => "/_ruote/errors/#{wfid}",
|
18
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process_errors' },
|
19
|
+
{ 'href' => "/_ruote/schedules/#{wfid}",
|
20
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process_schedules' }
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
describe 'GET /_ruote/processes' do
|
26
|
+
|
27
|
+
it_has_an_engine
|
28
|
+
|
29
|
+
describe 'without any running processes' do
|
30
|
+
|
31
|
+
it 'should give no processes back (HTML)' do
|
32
|
+
|
33
|
+
get '/_ruote/processes?limit=100&skip=0'
|
4
34
|
|
5
|
-
|
6
|
-
it "should give no processes back (HTML)" do
|
7
|
-
get "/_ruote/processes"
|
35
|
+
last_response.status.should be(200)
|
8
36
|
|
9
|
-
last_response.should
|
37
|
+
last_response.should have_selector(
|
38
|
+
'a', :content => 'as JSON')
|
39
|
+
last_response.should have_selector(
|
40
|
+
'a', :href => '/_ruote/processes.json?limit=100&skip=0')
|
10
41
|
end
|
11
42
|
|
12
|
-
it
|
13
|
-
get "/_ruote/processes.json"
|
43
|
+
it 'should give an empty array (JSON)' do
|
14
44
|
|
15
|
-
|
45
|
+
get '/_ruote/processes.json'
|
46
|
+
|
47
|
+
last_response.status.should be(200)
|
16
48
|
|
17
49
|
body = last_response.json_body
|
18
|
-
body.should have_key(
|
50
|
+
body.should have_key('processes')
|
19
51
|
|
20
|
-
body[
|
52
|
+
body['processes'].should be_empty
|
21
53
|
end
|
22
54
|
end
|
23
55
|
|
24
|
-
describe
|
56
|
+
describe 'with running processes' do
|
57
|
+
|
25
58
|
before(:each) do
|
26
59
|
@wfid = launch_test_process
|
27
60
|
end
|
28
61
|
|
29
|
-
it
|
30
|
-
|
62
|
+
it 'should give process information back (HTML)' do
|
63
|
+
|
64
|
+
get '/_ruote/processes'
|
31
65
|
|
32
|
-
last_response.should
|
66
|
+
last_response.status.should be(200)
|
33
67
|
end
|
34
68
|
|
35
|
-
it
|
36
|
-
get "/_ruote/processes.json"
|
69
|
+
it 'should give process information back (JSON)' do
|
37
70
|
|
38
|
-
|
71
|
+
get '/_ruote/processes.json'
|
72
|
+
|
73
|
+
last_response.status.should be(200)
|
39
74
|
|
40
75
|
body = last_response.json_body
|
41
76
|
|
42
|
-
body[
|
77
|
+
body['processes'].should_not be_empty
|
78
|
+
|
79
|
+
body['links'].should == [
|
80
|
+
{ 'href' => '/_ruote',
|
81
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#root' },
|
82
|
+
{ 'href' => '/_ruote/processes',
|
83
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#processes' },
|
84
|
+
{ 'href' => '/_ruote/workitems',
|
85
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#workitems' },
|
86
|
+
{ 'href' => '/_ruote/errors',
|
87
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#errors' },
|
88
|
+
{ 'href' => '/_ruote/participants',
|
89
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#participants' },
|
90
|
+
{ 'href' => '/_ruote/schedules',
|
91
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#schedules' },
|
92
|
+
{ 'href' => '/_ruote/history',
|
93
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#history' },
|
94
|
+
{ 'href' => '/_ruote/processes',
|
95
|
+
'rel' => 'self' },
|
96
|
+
{ 'href' => '/_ruote/processes',
|
97
|
+
'rel' => 'all' },
|
98
|
+
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
99
|
+
'rel' => 'first' },
|
100
|
+
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
101
|
+
'rel' => 'last' },
|
102
|
+
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
103
|
+
'rel' => 'previous' },
|
104
|
+
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
105
|
+
'rel' => 'next' } ]
|
106
|
+
|
107
|
+
body['processes'].first['links'].should == process_links(@wfid)
|
43
108
|
end
|
44
109
|
end
|
45
110
|
end
|
46
111
|
|
47
|
-
describe
|
112
|
+
describe 'GET /_ruote/processes/wfid' do
|
113
|
+
|
114
|
+
it_has_an_engine
|
115
|
+
|
116
|
+
describe 'with a running process' do
|
48
117
|
|
49
|
-
describe "with a running process" do
|
50
118
|
before(:each) do
|
51
119
|
@wfid = launch_test_process
|
52
120
|
end
|
53
121
|
|
54
|
-
it
|
122
|
+
it 'should give process information back (HTML)' do
|
123
|
+
|
55
124
|
get "/_ruote/processes/#{@wfid}"
|
56
125
|
|
57
|
-
last_response.should
|
126
|
+
last_response.status.should be(200)
|
127
|
+
|
128
|
+
last_response.should have_selector(
|
129
|
+
'a[rel="http://ruote.rubyforge.org/rels.html#process_schedules"]')
|
58
130
|
end
|
59
131
|
|
60
|
-
it
|
132
|
+
it 'should give process information back (JSON)' do
|
133
|
+
|
61
134
|
get "/_ruote/processes/#{@wfid}.json"
|
62
135
|
|
63
|
-
last_response.should
|
136
|
+
last_response.status.should be(200)
|
64
137
|
|
65
138
|
body = last_response.json_body
|
66
139
|
|
67
140
|
body.should have_key('process')
|
141
|
+
|
142
|
+
body['process']['links'].should == process_links(@wfid)
|
68
143
|
end
|
69
144
|
end
|
70
145
|
|
71
|
-
describe
|
72
|
-
|
73
|
-
|
146
|
+
describe 'without a running process' do
|
147
|
+
|
148
|
+
it 'should 404 correctly (HTML)' do
|
149
|
+
|
150
|
+
get '/_ruote/processes/foo'
|
74
151
|
|
75
|
-
last_response.should_not be_ok
|
76
152
|
last_response.status.should be(404)
|
77
153
|
|
78
|
-
last_response.should match(/
|
154
|
+
last_response.should match(/resource not found/)
|
79
155
|
end
|
80
156
|
|
81
|
-
it
|
157
|
+
it 'should 404 correctly (JSON)' do
|
82
158
|
|
83
|
-
get
|
159
|
+
get '/_ruote/processes/foo.json'
|
84
160
|
|
85
|
-
last_response.should_not be_ok
|
86
161
|
last_response.status.should be(404)
|
87
162
|
|
88
|
-
last_response.json_body.keys.should include(
|
89
|
-
|
163
|
+
last_response.json_body.keys.should include('http_error')
|
164
|
+
|
165
|
+
last_response.json_body['http_error'].should == {
|
166
|
+
'code' => 404, 'message' => 'resource not found', 'cause' => ''
|
167
|
+
}
|
90
168
|
end
|
91
169
|
end
|
92
170
|
end
|
93
171
|
|
94
|
-
describe
|
172
|
+
describe 'GET /_ruote/processes/new' do
|
173
|
+
|
174
|
+
it_has_an_engine
|
95
175
|
|
96
|
-
it
|
97
|
-
get "/_ruote/processes/new"
|
176
|
+
it 'should return a launch form' do
|
98
177
|
|
99
|
-
|
178
|
+
get '/_ruote/processes/new'
|
179
|
+
|
180
|
+
last_response.status.should be(200)
|
181
|
+
|
182
|
+
last_response.should_not have_selector('a', :content => 'as JSON')
|
100
183
|
end
|
101
184
|
end
|
102
185
|
|
103
|
-
describe
|
186
|
+
describe 'POST /_ruote/processes' do
|
187
|
+
|
188
|
+
it_has_an_engine
|
104
189
|
|
105
190
|
before(:each) do
|
106
191
|
engine.processes.should be_empty
|
107
192
|
end
|
108
193
|
|
109
|
-
it
|
194
|
+
it 'should launch a valid process definition (JSON)' do
|
195
|
+
|
110
196
|
params = {
|
111
|
-
:definition => %q{
|
112
|
-
|
113
|
-
|
197
|
+
:definition => %q{
|
198
|
+
Ruote.process_definition :name => 'test' do
|
199
|
+
wait '1m'
|
200
|
+
end
|
201
|
+
}
|
114
202
|
}
|
115
203
|
|
116
|
-
post
|
204
|
+
post(
|
205
|
+
'/_ruote/processes.json',
|
206
|
+
Rufus::Json.encode(params),
|
207
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
117
208
|
|
118
|
-
last_response.should
|
209
|
+
last_response.status.should be(201)
|
119
210
|
|
120
211
|
last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
|
121
212
|
|
@@ -124,163 +215,186 @@ describe "POST /_ruote/processes", :type => :with_engine do
|
|
124
215
|
engine.processes.should_not be_empty
|
125
216
|
end
|
126
217
|
|
127
|
-
it
|
218
|
+
it 'should launch a valid process definition with fields (JSON)' do
|
219
|
+
|
128
220
|
params = {
|
129
|
-
:definition => %q{
|
130
|
-
|
131
|
-
|
221
|
+
:definition => %q{
|
222
|
+
Ruote.process_definition :name => 'test' do
|
223
|
+
echo '${f:foo}'
|
224
|
+
end
|
225
|
+
},
|
132
226
|
:fields => { :foo => 'bar' }
|
133
227
|
}
|
134
228
|
|
135
|
-
post
|
229
|
+
post(
|
230
|
+
'/_ruote/processes.json',
|
231
|
+
Rufus::Json.encode(params),
|
232
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
136
233
|
|
137
|
-
last_response.should
|
234
|
+
last_response.status.should be(201)
|
138
235
|
last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
|
139
236
|
|
140
237
|
sleep 0.5
|
141
238
|
|
142
|
-
@tracer.to_s.should ==
|
239
|
+
@tracer.to_s.should == 'bar'
|
143
240
|
end
|
144
241
|
|
145
|
-
it
|
242
|
+
it 'should launch a valid process definition (HTML)' do
|
243
|
+
|
146
244
|
params = {
|
147
|
-
:
|
148
|
-
|
149
|
-
|
245
|
+
:definition => %q{
|
246
|
+
Ruote.process_definition :name => 'test' do
|
247
|
+
wait '1m'
|
248
|
+
end
|
150
249
|
}
|
151
250
|
}
|
152
251
|
|
153
|
-
post
|
252
|
+
post '/_ruote/processes', params
|
154
253
|
|
155
|
-
last_response.should
|
254
|
+
last_response.status.should == 201
|
156
255
|
|
157
256
|
sleep 0.4
|
158
257
|
|
159
258
|
engine.processes.should_not be_empty
|
160
259
|
end
|
161
260
|
|
162
|
-
it
|
261
|
+
it 'should launch a process definition with fields (HTML)' do
|
262
|
+
|
163
263
|
params = {
|
164
|
-
:
|
165
|
-
|
166
|
-
|
167
|
-
|
264
|
+
:definition => %{
|
265
|
+
Ruote.process_definition :name => 'test' do
|
266
|
+
echo '${f:foo}'
|
267
|
+
end
|
268
|
+
},
|
269
|
+
:fields => '{ "foo": "bar" }'
|
168
270
|
}
|
169
271
|
|
170
272
|
post '/_ruote/processes', params
|
171
273
|
|
172
|
-
last_response.should
|
274
|
+
last_response.status.should == 201
|
173
275
|
|
174
276
|
sleep 0.5
|
175
277
|
|
176
|
-
@tracer.to_s.should ==
|
278
|
+
@tracer.to_s.should == 'bar'
|
177
279
|
end
|
178
280
|
|
179
|
-
it
|
281
|
+
it 'should correct for empty fields sent by browsers' do
|
282
|
+
|
180
283
|
params = {
|
181
|
-
:
|
182
|
-
|
183
|
-
|
184
|
-
|
284
|
+
:definition => %q{
|
285
|
+
Ruote.process_definition :name => 'test' do
|
286
|
+
wait '5m'
|
287
|
+
end
|
288
|
+
},
|
289
|
+
:fields => ''
|
185
290
|
}
|
186
291
|
|
187
292
|
post '/_ruote/processes', params
|
188
293
|
|
189
|
-
last_response.should
|
294
|
+
last_response.status.should == 201
|
190
295
|
|
191
296
|
sleep 0.4
|
192
297
|
|
193
298
|
engine.processes.should_not be_empty
|
194
299
|
end
|
195
300
|
|
196
|
-
it
|
197
|
-
params = { :definition => 'http://invalid.invalid' }
|
301
|
+
it 'should 400 code when it fails to determine what to launch (JSON)' do
|
198
302
|
|
199
|
-
|
303
|
+
params = { :definition => 'http://invalid.invalid' }
|
200
304
|
|
201
|
-
|
202
|
-
|
305
|
+
post(
|
306
|
+
'/_ruote/processes.json',
|
307
|
+
Rufus::Json.encode(params),
|
308
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
203
309
|
|
204
|
-
last_response.
|
310
|
+
last_response.status.should be(400)
|
311
|
+
last_response.json_body.keys.should include('http_error')
|
205
312
|
end
|
206
313
|
|
207
|
-
it
|
208
|
-
params = { :process_definition => %q{http://invalid.invalid} }
|
314
|
+
it 'should 400 when it fails to determine what to launch (HTML)' do
|
209
315
|
|
210
|
-
|
316
|
+
params = { :definition => %q{http://invalid.invalid} }
|
211
317
|
|
212
|
-
|
213
|
-
last_response.status.should be(422)
|
318
|
+
post '/_ruote/processes', params
|
214
319
|
|
215
|
-
last_response.should
|
320
|
+
last_response.status.should be(400)
|
321
|
+
last_response.should match(/bad request/)
|
216
322
|
end
|
217
323
|
|
218
324
|
end
|
219
325
|
|
220
|
-
describe
|
326
|
+
describe 'DELETE /_ruote/processes/wfid' do
|
327
|
+
|
328
|
+
it_has_an_engine
|
221
329
|
|
222
330
|
before(:each) do
|
331
|
+
|
223
332
|
@wfid = launch_test_process do
|
224
333
|
Ruote.process_definition :name => 'test' do
|
225
334
|
sequence :on_cancel => 'bail_out' do
|
226
|
-
echo
|
335
|
+
echo 'done.'
|
227
336
|
wait '1d'
|
228
337
|
end
|
229
338
|
|
230
339
|
define :name => 'bail_out' do
|
231
|
-
echo
|
340
|
+
echo 'bailout.'
|
232
341
|
end
|
233
342
|
end
|
234
343
|
end
|
235
344
|
end
|
236
345
|
|
237
|
-
it
|
346
|
+
it 'should cancel processes (JSON)' do
|
347
|
+
|
238
348
|
delete "/_ruote/processes/#{@wfid}.json"
|
239
349
|
|
240
|
-
last_response.should
|
350
|
+
last_response.status.should be(200)
|
241
351
|
|
242
|
-
wait_for(
|
352
|
+
wait_for(@wfid)
|
243
353
|
|
244
|
-
engine.process(
|
354
|
+
engine.process(@wfid).should be_nil
|
245
355
|
|
246
356
|
@tracer.to_s.should == "done.\nbailout."
|
247
357
|
end
|
248
358
|
|
249
|
-
it
|
359
|
+
it 'should cancel processes (HMTL)' do
|
360
|
+
|
250
361
|
delete "/_ruote/processes/#{@wfid}"
|
251
362
|
|
252
363
|
last_response.should be_redirect
|
253
|
-
last_response['Location'].should ==
|
364
|
+
last_response['Location'].should == '/_ruote/processes'
|
254
365
|
|
255
|
-
wait_for(
|
366
|
+
wait_for(@wfid)
|
256
367
|
|
257
|
-
engine.process(
|
368
|
+
engine.process(@wfid).should be_nil
|
258
369
|
|
259
370
|
@tracer.to_s.should == "done.\nbailout."
|
260
371
|
end
|
261
372
|
|
262
|
-
it
|
373
|
+
it 'should kill processes (JSON)' do
|
374
|
+
|
263
375
|
delete "/_ruote/processes/#{@wfid}.json?_kill=1"
|
264
376
|
|
265
|
-
last_response.should
|
377
|
+
last_response.status.should be(200)
|
266
378
|
|
267
|
-
wait_for(
|
379
|
+
wait_for(@wfid)
|
268
380
|
|
269
|
-
engine.process(
|
381
|
+
engine.process(@wfid).should be_nil
|
270
382
|
|
271
|
-
@tracer.to_s.should ==
|
383
|
+
@tracer.to_s.should == 'done.'
|
272
384
|
end
|
273
385
|
|
274
|
-
it
|
386
|
+
it 'should kill processes (HTML)' do
|
387
|
+
|
275
388
|
delete "/_ruote/processes/#{@wfid}?_kill=1"
|
276
389
|
|
277
390
|
last_response.should be_redirect
|
278
391
|
last_response['Location'].should == '/_ruote/processes'
|
279
392
|
|
280
|
-
wait_for(
|
393
|
+
wait_for(@wfid)
|
281
394
|
|
282
|
-
engine.process(
|
395
|
+
engine.process(@wfid).should be_nil
|
283
396
|
|
284
|
-
@tracer.to_s.should ==
|
397
|
+
@tracer.to_s.should == 'done.'
|
285
398
|
end
|
286
399
|
end
|
400
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
undef :context if defined?(context)
|
4
|
+
|
5
|
+
|
6
|
+
describe 'GET /_ruote/schedules' do
|
7
|
+
|
8
|
+
it_has_an_engine
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
|
12
|
+
@wfid0 = RuoteKit.engine.launch(Ruote.define do
|
13
|
+
wait :for => '3d'
|
14
|
+
end)
|
15
|
+
@wfid1 = RuoteKit.engine.launch(Ruote.define do
|
16
|
+
sequence do
|
17
|
+
alpha :timeout => '2d'
|
18
|
+
end
|
19
|
+
end)
|
20
|
+
|
21
|
+
RuoteKit.engine.wait_for(:alpha)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should list schedules (HTML)' do
|
25
|
+
|
26
|
+
get '/_ruote/schedules'
|
27
|
+
|
28
|
+
last_response.status.should be(200)
|
29
|
+
|
30
|
+
last_response.should have_selector(
|
31
|
+
'a[rel="http://ruote.rubyforge.org/rels.html#process_schedules"]')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should list schedules (JSON)' do
|
35
|
+
|
36
|
+
get '/_ruote/schedules.json'
|
37
|
+
|
38
|
+
last_response.status.should be(200)
|
39
|
+
|
40
|
+
json = last_response.json_body
|
41
|
+
#puts Rufus::Json.pretty_encode(json)
|
42
|
+
|
43
|
+
schedules = json['schedules']
|
44
|
+
|
45
|
+
schedules.size.should == 2
|
46
|
+
|
47
|
+
schedules.first.keys.sort.should == %w[
|
48
|
+
_id action at flavour links original owner put_at target type wfid
|
49
|
+
]
|
50
|
+
|
51
|
+
schedules.first['target'].should be_kind_of(Hash)
|
52
|
+
schedules.first['owner'].should be_kind_of(Hash)
|
53
|
+
|
54
|
+
wfid = [ @wfid0, @wfid1 ].sort.first
|
55
|
+
|
56
|
+
schedules.first['links'].first['href'].should ==
|
57
|
+
"/_ruote/expressions/0_0!!#{wfid}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'GET /_ruote/schedules/wfid' do
|
62
|
+
|
63
|
+
it_has_an_engine
|
64
|
+
|
65
|
+
before(:each) do
|
66
|
+
|
67
|
+
@wfid0 = RuoteKit.engine.launch(Ruote.define do
|
68
|
+
wait :for => '3d'
|
69
|
+
end)
|
70
|
+
@wfid1 = RuoteKit.engine.launch(Ruote.define do
|
71
|
+
sequence do
|
72
|
+
alpha :timeout => '2d'
|
73
|
+
end
|
74
|
+
end)
|
75
|
+
|
76
|
+
RuoteKit.engine.wait_for(:alpha)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should list schedules (HTML)' do
|
80
|
+
|
81
|
+
get "/_ruote/schedules/#{@wfid1}"
|
82
|
+
|
83
|
+
last_response.status.should be(200)
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should list schedules (JSON)' do
|
87
|
+
|
88
|
+
get "/_ruote/schedules/#{@wfid0}.json"
|
89
|
+
|
90
|
+
last_response.status.should be(200)
|
91
|
+
|
92
|
+
#puts Rufus::Json.pretty_encode(last_response.json_body)
|
93
|
+
|
94
|
+
last_response.json_body['schedules'].size.should == 1
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|