ruote-kit 2.1.10 → 2.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG.txt +10 -0
  3. data/Gemfile +21 -5
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +132 -80
  6. data/Rakefile +4 -15
  7. data/TODO.txt +12 -0
  8. data/config.ru +22 -14
  9. data/lib/ruote-kit/application.rb +46 -22
  10. data/lib/ruote-kit/helpers/json_helpers.rb +280 -0
  11. data/lib/ruote-kit/helpers/link_helpers.rb +117 -0
  12. data/lib/ruote-kit/helpers/misc_helpers.rb +35 -0
  13. data/lib/ruote-kit/helpers/pagination_helpers.rb +30 -0
  14. data/lib/ruote-kit/helpers/render_helpers.rb +39 -92
  15. data/lib/ruote-kit/public/_ruote/images/favicon.ico +0 -0
  16. data/lib/ruote-kit/public/_ruote/images/ruote.png +0 -0
  17. data/lib/ruote-kit/public/_ruote/images/ruote_buttons.png +0 -0
  18. data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.4.2.min.js +154 -0
  19. data/lib/ruote-kit/public/_ruote/javascripts/rk.js +40 -0
  20. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-editor.js +548 -0
  21. data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js +32 -1
  22. data/lib/ruote-kit/public/_ruote/stylesheets/reset.css +53 -0
  23. data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +355 -16
  24. data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +108 -0
  25. data/lib/ruote-kit/resources/errors.rb +46 -43
  26. data/lib/ruote-kit/resources/expressions.rb +92 -35
  27. data/lib/ruote-kit/resources/participants.rb +53 -0
  28. data/lib/ruote-kit/resources/processes.rb +68 -36
  29. data/lib/ruote-kit/resources/schedules.rb +27 -0
  30. data/lib/ruote-kit/resources/workitems.rb +93 -31
  31. data/lib/ruote-kit/spec/ruote_helpers.rb +25 -16
  32. data/lib/ruote-kit/version.rb +3 -1
  33. data/lib/ruote-kit/views/_pagination.html.haml +38 -0
  34. data/lib/ruote-kit/views/_tree_editor.html.haml +52 -0
  35. data/lib/ruote-kit/views/error.html.haml +69 -0
  36. data/lib/ruote-kit/views/errors.html.haml +28 -12
  37. data/lib/ruote-kit/views/expression.html.haml +161 -30
  38. data/lib/ruote-kit/views/expressions.html.haml +26 -21
  39. data/lib/ruote-kit/views/http_error.html.haml +11 -0
  40. data/lib/ruote-kit/views/index.html.haml +4 -0
  41. data/lib/ruote-kit/views/layout.html.haml +52 -32
  42. data/lib/ruote-kit/views/participants.html.haml +79 -0
  43. data/lib/ruote-kit/views/process.html.haml +109 -42
  44. data/lib/ruote-kit/views/process_launched.html.haml +6 -2
  45. data/lib/ruote-kit/views/processes.html.haml +55 -24
  46. data/lib/ruote-kit/views/processes_new.html.haml +36 -0
  47. data/lib/ruote-kit/views/schedules.html.haml +42 -0
  48. data/lib/ruote-kit/views/workitem.html.haml +83 -29
  49. data/lib/ruote-kit/views/workitems.html.haml +42 -19
  50. data/lib/ruote-kit.rb +17 -88
  51. data/ruote-kit.gemspec +68 -80
  52. data/spec/it_has_an_engine.rb +69 -0
  53. data/spec/resources/errors_spec.rb +198 -270
  54. data/spec/resources/expressions_spec.rb +308 -52
  55. data/spec/resources/index_spec.rb +28 -16
  56. data/spec/resources/participants_spec.rb +102 -0
  57. data/spec/resources/processes_spec.rb +218 -104
  58. data/spec/resources/schedules_spec.rb +97 -0
  59. data/spec/resources/workitems_spec.rb +195 -100
  60. data/spec/ruote-kit_configure_spec.rb +32 -75
  61. data/spec/spec.opts +0 -1
  62. data/spec/spec_helper.rb +31 -92
  63. data/spec/webapp_helpers_spec.rb +309 -0
  64. metadata +87 -152
  65. data/lib/ruote-kit/configuration.rb +0 -83
  66. data/lib/ruote-kit/helpers/engine_helpers.rb +0 -24
  67. data/lib/ruote-kit/helpers/form_helpers.rb +0 -11
  68. data/lib/ruote-kit/helpers/launch_item_parser.rb +0 -59
  69. data/lib/ruote-kit/helpers/navigation_helpers.rb +0 -54
  70. data/lib/ruote-kit/helpers.rb +0 -9
  71. data/lib/ruote-kit/public/_ruote/images/bg.gif +0 -0
  72. data/lib/ruote-kit/public/_ruote/images/bg_button_left.gif +0 -0
  73. data/lib/ruote-kit/public/_ruote/images/bg_button_left_cancel.gif +0 -0
  74. data/lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif +0 -0
  75. data/lib/ruote-kit/public/_ruote/images/bg_button_right.gif +0 -0
  76. data/lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js +0 -191
  77. data/lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js +0 -149
  78. data/lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css +0 -226
  79. data/lib/ruote-kit/public/_ruote/stylesheets/base.css +0 -336
  80. data/lib/ruote-kit/public/_ruote/stylesheets/style.css +0 -393
  81. data/lib/ruote-kit/views/launch_process.html.haml +0 -19
  82. data/lib/ruote-kit/views/process_failed_to_launch.html.haml +0 -7
  83. data/lib/ruote-kit/views/resource_not_found.html.haml +0 -7
  84. data/spec/helpers/render_helpers_spec.rb +0 -214
  85. data/spec/ruote-kit_spec.rb +0 -4
  86. data/spec/views/expressions.html.haml_spec.rb +0 -31
  87. data/spec/views/launch_process.html.haml_spec.rb +0 -22
  88. data/spec/views/process.html.haml_spec.rb +0 -17
  89. data/spec/views/process_launched.html.haml_spec.rb +0 -16
  90. data/spec/views/processes.html.haml_spec.rb +0 -31
  91. data/spec/views/workitems.html.haml_spec.rb +0 -69
@@ -1,121 +1,212 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
1
 
3
- describe "GET /_ruote/processes", :type => :with_engine do
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
- describe "without any running processes" do
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 be_ok
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 "should give an empty array (JSON)" do
13
- get "/_ruote/processes.json"
43
+ it 'should give an empty array (JSON)' do
14
44
 
15
- last_response.should be_ok
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("processes")
50
+ body.should have_key('processes')
19
51
 
20
- body["processes"].should be_empty
52
+ body['processes'].should be_empty
21
53
  end
22
54
  end
23
55
 
24
- describe "with running processes" do
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 "should give process information back (HTML)" do
30
- get "/_ruote/processes"
62
+ it 'should give process information back (HTML)' do
63
+
64
+ get '/_ruote/processes'
31
65
 
32
- last_response.should be_ok
66
+ last_response.status.should be(200)
33
67
  end
34
68
 
35
- it "should give process information back (JSON)" do
36
- get "/_ruote/processes.json"
69
+ it 'should give process information back (JSON)' do
37
70
 
38
- last_response.should be_ok
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["processes"].should_not be_empty
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 "GET /_ruote/processes/X-Y", :type => :with_engine do
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 "should give process information back (HTML)" do
122
+ it 'should give process information back (HTML)' do
123
+
55
124
  get "/_ruote/processes/#{@wfid}"
56
125
 
57
- last_response.should be_ok
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 "should give process information back (JSON)" do
132
+ it 'should give process information back (JSON)' do
133
+
61
134
  get "/_ruote/processes/#{@wfid}.json"
62
135
 
63
- last_response.should be_ok
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 "without a running process" do
72
- it "should 404 correctly (HTML)" do
73
- get "/_ruote/processes/foo"
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(/Resource not found/)
154
+ last_response.should match(/resource not found/)
79
155
  end
80
156
 
81
- it "should 404 correctly (JSON)" do
157
+ it 'should 404 correctly (JSON)' do
82
158
 
83
- get "/_ruote/processes/foo.json"
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("error")
89
- last_response.json_body['error'].should == { "code" => 404, "message" => "Resource not found" }
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 "GET /_ruote/processes/new", :type => :with_engine do
172
+ describe 'GET /_ruote/processes/new' do
173
+
174
+ it_has_an_engine
95
175
 
96
- it "should return a launch form" do
97
- get "/_ruote/processes/new"
176
+ it 'should return a launch form' do
98
177
 
99
- last_response.should be_ok
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 "POST /_ruote/processes", :type => :with_engine do
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 "should launch a valid process definition (JSON)" do
194
+ it 'should launch a valid process definition (JSON)' do
195
+
110
196
  params = {
111
- :definition => %q{Ruote.process_definition :name => 'test' do
112
- _sleep '1m'
113
- end}
197
+ :definition => %q{
198
+ Ruote.process_definition :name => 'test' do
199
+ wait '1m'
200
+ end
201
+ }
114
202
  }
115
203
 
116
- post '/_ruote/processes.json', Rufus::Json.encode(params), { 'CONTENT_TYPE' => 'application/json' }
204
+ post(
205
+ '/_ruote/processes.json',
206
+ Rufus::Json.encode(params),
207
+ { 'CONTENT_TYPE' => 'application/json' })
117
208
 
118
- last_response.should be_ok
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 "should launch a valid process definition with fields (JSON)" do
218
+ it 'should launch a valid process definition with fields (JSON)' do
219
+
128
220
  params = {
129
- :definition => %q{Ruote.process_definition :name => 'test' do
130
- echo '${f:foo}'
131
- end},
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 '/_ruote/processes.json', Rufus::Json.encode(params), { 'CONTENT_TYPE' => 'application/json' }
229
+ post(
230
+ '/_ruote/processes.json',
231
+ Rufus::Json.encode(params),
232
+ { 'CONTENT_TYPE' => 'application/json' })
136
233
 
137
- last_response.should be_ok
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 == "bar"
239
+ @tracer.to_s.should == 'bar'
143
240
  end
144
241
 
145
- it "should launch a valid process definition (HTML)" do
242
+ it 'should launch a valid process definition (HTML)' do
243
+
146
244
  params = {
147
- :process_definition => %q{Ruote.process_definition :name => "test" do
148
- _sleep '1m'
149
- end
245
+ :definition => %q{
246
+ Ruote.process_definition :name => 'test' do
247
+ wait '1m'
248
+ end
150
249
  }
151
250
  }
152
251
 
153
- post "/_ruote/processes", params
252
+ post '/_ruote/processes', params
154
253
 
155
- last_response.should be_ok
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 "should launch a process definition with fields (HTML)" do
261
+ it 'should launch a process definition with fields (HTML)' do
262
+
163
263
  params = {
164
- :process_definition => %q{Ruote.process_definition :name => 'test' do
165
- echo '${f:foo}'
166
- end},
167
- :process_fields => %q{ { "foo": "bar" } }
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 be_ok
274
+ last_response.status.should == 201
173
275
 
174
276
  sleep 0.5
175
277
 
176
- @tracer.to_s.should == "bar"
278
+ @tracer.to_s.should == 'bar'
177
279
  end
178
280
 
179
- it "should correct for empty fields sent by browsers" do
281
+ it 'should correct for empty fields sent by browsers' do
282
+
180
283
  params = {
181
- :process_definition => %q{Ruote.process_definition :name => 'test' do
182
- wait '5m'
183
- end},
184
- :process_fields => ''
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 be_ok
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 "should return a 422 unprocessable entity error when launching a process fails (JSON)" do
197
- params = { :definition => 'http://invalid.invalid' }
301
+ it 'should 400 code when it fails to determine what to launch (JSON)' do
198
302
 
199
- post '/_ruote/processes.json', Rufus::Json.encode(params), { 'CONTENT_TYPE' => 'application/json' }
303
+ params = { :definition => 'http://invalid.invalid' }
200
304
 
201
- last_response.should_not be_ok
202
- last_response.status.should be(422)
305
+ post(
306
+ '/_ruote/processes.json',
307
+ Rufus::Json.encode(params),
308
+ { 'CONTENT_TYPE' => 'application/json' })
203
309
 
204
- last_response.json_body.keys.should include("error")
310
+ last_response.status.should be(400)
311
+ last_response.json_body.keys.should include('http_error')
205
312
  end
206
313
 
207
- it "should return a nice error page when launching a process fails (HTML)" do
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
- post '/_ruote/processes', params
316
+ params = { :definition => %q{http://invalid.invalid} }
211
317
 
212
- last_response.should_not be_ok
213
- last_response.status.should be(422)
318
+ post '/_ruote/processes', params
214
319
 
215
- last_response.should match(/Process failed to launch/)
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 "DELETE /_ruote/processes/X-Y", :type => :with_engine do
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 "done."
335
+ echo 'done.'
227
336
  wait '1d'
228
337
  end
229
338
 
230
339
  define :name => 'bail_out' do
231
- echo "bailout."
340
+ echo 'bailout.'
232
341
  end
233
342
  end
234
343
  end
235
344
  end
236
345
 
237
- it "should cancel processes (JSON)" do
346
+ it 'should cancel processes (JSON)' do
347
+
238
348
  delete "/_ruote/processes/#{@wfid}.json"
239
349
 
240
- last_response.should be_ok
350
+ last_response.status.should be(200)
241
351
 
242
- wait_for( @wfid )
352
+ wait_for(@wfid)
243
353
 
244
- engine.process( @wfid ).should be_nil
354
+ engine.process(@wfid).should be_nil
245
355
 
246
356
  @tracer.to_s.should == "done.\nbailout."
247
357
  end
248
358
 
249
- it "should cancel processes (HMTL)" do
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 == "/_ruote/processes"
364
+ last_response['Location'].should == '/_ruote/processes'
254
365
 
255
- wait_for( @wfid )
366
+ wait_for(@wfid)
256
367
 
257
- engine.process( @wfid ).should be_nil
368
+ engine.process(@wfid).should be_nil
258
369
 
259
370
  @tracer.to_s.should == "done.\nbailout."
260
371
  end
261
372
 
262
- it "should kill processes (JSON)" do
373
+ it 'should kill processes (JSON)' do
374
+
263
375
  delete "/_ruote/processes/#{@wfid}.json?_kill=1"
264
376
 
265
- last_response.should be_ok
377
+ last_response.status.should be(200)
266
378
 
267
- wait_for( @wfid )
379
+ wait_for(@wfid)
268
380
 
269
- engine.process( @wfid ).should be_nil
381
+ engine.process(@wfid).should be_nil
270
382
 
271
- @tracer.to_s.should == "done."
383
+ @tracer.to_s.should == 'done.'
272
384
  end
273
385
 
274
- it "should kill processes (HTML)" do
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( @wfid )
393
+ wait_for(@wfid)
281
394
 
282
- engine.process( @wfid ).should be_nil
395
+ engine.process(@wfid).should be_nil
283
396
 
284
- @tracer.to_s.should == "done."
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
+