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,20 +1,25 @@
1
1
 
2
- require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'spec_helper'
3
3
 
4
- describe "GET /_ruote/errors", :type => :with_engine do
4
+ undef :context if defined?(context)
5
5
 
6
- describe "without any running processes" do
7
6
 
8
- it "should give no processes back (HTML)" do
7
+ describe 'without any running processes' do
9
8
 
10
- get "/_ruote/errors"
9
+ it_has_an_engine_with_no_participants
10
+
11
+ describe 'GET /_ruote/errors' do
12
+
13
+ it 'should give no processes back (HTML)' do
14
+
15
+ get '/_ruote/errors'
11
16
 
12
17
  last_response.status.should be(200)
13
18
  end
14
19
 
15
- it "should give an empty array (JSON)" do
20
+ it 'should give an empty array (JSON)' do
16
21
 
17
- get "/_ruote/errors.json"
22
+ get '/_ruote/errors.json'
18
23
 
19
24
  last_response.status.should be(200)
20
25
 
@@ -24,269 +29,192 @@ describe "GET /_ruote/errors", :type => :with_engine do
24
29
  body['errors'].should be_empty
25
30
  end
26
31
  end
32
+ end
33
+
34
+ describe 'with a running process that has an error' do
35
+
36
+ it_has_an_engine_with_no_participants
37
+
38
+ before(:each) do
39
+
40
+ RuoteKit.engine.register_participant :alice, Ruote::StorageParticipant
41
+
42
+ @wfid = RuoteKit.engine.launch(
43
+ Ruote.process_definition(:name => 'test') do
44
+ sequence do
45
+ nemo
46
+ alice
47
+ end
48
+ end
49
+ )
50
+
51
+ RuoteKit.engine.wait_for(@wfid)
52
+
53
+ @error = RuoteKit.engine.process(@wfid).errors.first
54
+ end
55
+
56
+ describe 'GET /_ruote/errors' do
57
+
58
+ it 'should list errors (HTML)' do
59
+
60
+ get '/_ruote/errors'
61
+
62
+ last_response.status.should be(200)
63
+ last_response.should match(/nemo/)
64
+ end
65
+
66
+ it 'should list errors (JSON)' do
67
+
68
+ get '/_ruote/errors.json'
69
+
70
+ last_response.status.should be(200)
71
+
72
+ json = last_response.json_body
73
+
74
+ # global links
75
+
76
+ json['links'].should == [
77
+ { 'href' => '/_ruote',
78
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#root' },
79
+ { 'href' => '/_ruote/processes',
80
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#processes' },
81
+ { 'href' => '/_ruote/workitems',
82
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#workitems' },
83
+ { 'href' => '/_ruote/errors',
84
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#errors' },
85
+ { 'href' => '/_ruote/participants',
86
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#participants' },
87
+ { 'href' => '/_ruote/schedules',
88
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#schedules' },
89
+ { 'href' => '/_ruote/history',
90
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#history' },
91
+ { 'href' => '/_ruote/errors',
92
+ 'rel' => 'self' },
93
+ { 'href' => '/_ruote/errors',
94
+ 'rel' => 'all' },
95
+ { 'href' => '/_ruote/errors?limit=100&skip=0',
96
+ 'rel' => 'first' },
97
+ { 'href' => '/_ruote/errors?limit=100&skip=0',
98
+ 'rel' => 'last' },
99
+ { 'href' => '/_ruote/errors?limit=100&skip=0',
100
+ 'rel' => 'previous' },
101
+ { 'href' => '/_ruote/errors?limit=100&skip=0',
102
+ 'rel' => 'next' } ]
103
+
104
+ # the error itself
105
+
106
+ json['errors'].size.should == 1
107
+ json['errors'].first['message'].should == "#<RuntimeError: unknown participant or subprocess 'nemo'>"
108
+
109
+ # the links for the error itself
110
+
111
+ json['errors'].first['links'].should == [
112
+ { 'href' => "/_ruote/errors/0_0_0!!#{@wfid}",
113
+ 'rel' => 'self' },
114
+ { 'href' => "/_ruote/errors/#{@wfid}",
115
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#process_errors' },
116
+ { 'href' => "/_ruote/processes/#{@wfid}",
117
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#process' }
118
+ ]
119
+
120
+ #puts Rufus::Json.pretty_encode(json)
121
+ end
122
+ end
123
+
124
+ describe 'GET /_ruote/errors/:wfid' do
125
+
126
+ it 'should list process errors (HTML)' do
127
+
128
+ get "/_ruote/errors/#{@wfid}"
129
+
130
+ last_response.status.should be(200)
131
+ last_response.should match(/nemo/)
132
+ end
133
+
134
+ it 'should list process errors (JSON)' do
135
+
136
+ get "/_ruote/errors/#{@wfid}.json"
137
+
138
+ last_response.status.should be(200)
139
+
140
+ json = last_response.json_body
141
+
142
+ json['errors'].size.should == 1
143
+ json['errors'].first['message'].should == "#<RuntimeError: unknown participant or subprocess 'nemo'>"
144
+
145
+ json['errors'].first['links'].should == [
146
+ { 'href' => "/_ruote/errors/0_0_0!!#{@wfid}",
147
+ 'rel' => 'self' },
148
+ { 'href' => "/_ruote/errors/#{@wfid}",
149
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#process_errors' },
150
+ { 'href' => "/_ruote/processes/#{@wfid}",
151
+ 'rel' => 'http://ruote.rubyforge.org/rels.html#process' } ]
152
+ end
153
+ end
154
+
155
+ describe 'GET /_ruote/errors/:fei' do
156
+
157
+ it 'should show the error (HTML)' do
158
+
159
+ get "/_ruote/errors/0_0_0!!#{@wfid}"
160
+
161
+ last_response.status.should be(200)
162
+ last_response.should match(/nemo/)
163
+ end
164
+
165
+ it 'should show the error (JSON)' do
166
+
167
+ get "/_ruote/errors/0_0_0!!#{@wfid}.json"
168
+
169
+ last_response.status.should be(200)
170
+
171
+ json = last_response.json_body
172
+
173
+ #puts Rufus::Json.pretty_encode(json)
174
+ end
175
+ end
176
+
177
+ describe 'DELETE /_ruote/errors/:fei' do
27
178
 
28
- # describe "with running processes" do
29
- #
30
- # before(:each) do
31
- # @wfid = launch_test_process
32
- # end
33
- #
34
- # it "should give process information back (HTML)" do
35
- #
36
- # get "/_ruote/errors"
37
- #
38
- # last_response.should be_ok
39
- # end
40
- #
41
- # it "should give process information back (JSON)" do
42
- #
43
- # get "/_ruote/processes.json"
44
- #
45
- # last_response.should be_ok
46
- #
47
- # body = last_response.json_body
48
- #
49
- # body['errors'].should_not be_empty
50
- # end
51
- # end
179
+ it 'should replay errors (HTML)' do
180
+
181
+ RuoteKit.engine.register_participant :nemo, Ruote::StorageParticipant
182
+
183
+ delete "/_ruote/errors/#{@error.fei.sid}"
184
+
185
+ last_response.status.should be(302)
186
+ last_response['Location'].should == '/_ruote/errors'
187
+
188
+ RuoteKit.engine.wait_for(:nemo)
189
+
190
+ RuoteKit.engine.storage_participant.size.should == 1
191
+
192
+ wi = RuoteKit.engine.storage_participant.first
193
+ wi.participant_name.should == 'nemo'
194
+
195
+ RuoteKit.engine.process(@wfid).errors.size.should == 0
196
+ end
197
+
198
+ it 'should replay errors (JSON)' do
199
+
200
+ #RuoteKit.engine.noisy = true
201
+
202
+ RuoteKit.engine.register_participant :nemo, Ruote::StorageParticipant
203
+
204
+ delete "/_ruote/errors/#{@error.fei.sid}.json"
205
+
206
+ last_response.status.should be(200)
207
+ last_response.json_body['status'].should == 'ok'
208
+
209
+ RuoteKit.engine.wait_for(:nemo)
210
+
211
+ RuoteKit.engine.storage_participant.size.should == 1
212
+
213
+ wi = RuoteKit.engine.storage_participant.first
214
+ wi.participant_name.should == 'nemo'
215
+
216
+ RuoteKit.engine.process(@wfid).errors.size.should == 0
217
+ end
218
+ end
52
219
  end
53
220
 
54
- #describe "GET /_ruote/processes/X-Y", :type => :with_engine do
55
- #
56
- # describe "with a running process" do
57
- # before(:each) do
58
- # @wfid = launch_test_process
59
- # end
60
- #
61
- # it "should give process information back (HTML)" do
62
- # get "/_ruote/processes/#{@wfid}"
63
- #
64
- # last_response.should be_ok
65
- # end
66
- #
67
- # it "should give process information back (JSON)" do
68
- # get "/_ruote/processes/#{@wfid}.json"
69
- #
70
- # last_response.should be_ok
71
- #
72
- # body = last_response.json_body
73
- #
74
- # body.should have_key('process')
75
- # end
76
- # end
77
- #
78
- # describe "without a running process" do
79
- # it "should 404 correctly (HTML)" do
80
- # get "/_ruote/processes/foo"
81
- #
82
- # last_response.should_not be_ok
83
- # last_response.status.should be(404)
84
- #
85
- # last_response.should match(/Resource not found/)
86
- # end
87
- #
88
- # it "should 404 correctly (JSON)" do
89
- # get "/_ruote/processes/foo.json"
90
- #
91
- # last_response.should_not be_ok
92
- # last_response.status.should be(404)
93
- #
94
- # last_response.json_body.keys.should include("error")
95
- # last_response.json_body['error'].should == { "code" => 404, "message" => "Resource not found" }
96
- # end
97
- # end
98
- #end
99
- #
100
- #describe "GET /_ruote/processes/new", :type => :with_engine do
101
- #
102
- # it "should return a launch form" do
103
- # get "/_ruote/processes/new"
104
- #
105
- # last_response.should be_ok
106
- # end
107
- #end
108
- #
109
- #describe "POST /_ruote/processes", :type => :with_engine do
110
- #
111
- # before(:each) do
112
- # engine.processes.should be_empty
113
- # end
114
- #
115
- # it "should launch a valid process definition (JSON)" do
116
- # params = {
117
- # :definition => %q{Ruote.process_definition :name => 'test' do
118
- # _sleep '1m'
119
- # end}
120
- # }
121
- #
122
- # post '/_ruote/processes.json', Rufus::Json.encode(params), { 'CONTENT_TYPE' => 'application/json' }
123
- #
124
- # last_response.should be_ok
125
- #
126
- # last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
127
- #
128
- # sleep 0.4
129
- #
130
- # engine.processes.should_not be_empty
131
- # end
132
- #
133
- # it "should launch a valid process definition with fields (JSON)" do
134
- # params = {
135
- # :definition => %q{Ruote.process_definition :name => 'test' do
136
- # echo '${f:foo}'
137
- # end},
138
- # :fields => { :foo => 'bar' }
139
- # }
140
- #
141
- # post '/_ruote/processes.json', Rufus::Json.encode(params), { 'CONTENT_TYPE' => 'application/json' }
142
- #
143
- # last_response.should be_ok
144
- # last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
145
- #
146
- # sleep 0.5
147
- #
148
- # @tracer.to_s.should == "bar"
149
- # end
150
- #
151
- # it "should launch a valid process definition (HTML)" do
152
- # params = {
153
- # :process_definition => %q{Ruote.process_definition :name => "test" do
154
- # _sleep '1m'
155
- # end
156
- # }
157
- # }
158
- #
159
- # post "/_ruote/processes", params
160
- #
161
- # last_response.should be_ok
162
- #
163
- # sleep 0.4
164
- #
165
- # engine.processes.should_not be_empty
166
- # end
167
- #
168
- # it "should launch a process definition with fields (HTML)" do
169
- # params = {
170
- # :process_definition => %q{Ruote.process_definition :name => 'test' do
171
- # echo '${f:foo}'
172
- # end},
173
- # :process_fields => %q{ { "foo": "bar" } }
174
- # }
175
- #
176
- # post '/_ruote/processes', params
177
- #
178
- # last_response.should be_ok
179
- #
180
- # sleep 0.5
181
- #
182
- # @tracer.to_s.should == "bar"
183
- # end
184
- #
185
- # it "should correct for empty fields sent by browsers" do
186
- # params = {
187
- # :process_definition => %q{Ruote.process_definition :name => 'test' do
188
- # wait '5m'
189
- # end},
190
- # :process_fields => ''
191
- # }
192
- #
193
- # post '/_ruote/processes', params
194
- #
195
- # last_response.should be_ok
196
- #
197
- # sleep 0.4
198
- #
199
- # engine.processes.should_not be_empty
200
- # end
201
- #
202
- # it "should return a 422 unprocessable entity error when launching a process fails (JSON)" do
203
- # params = { :definition => 'http://invalid.invalid' }
204
- #
205
- # post '/_ruote/processes.json', Rufus::Json.encode(params), { 'CONTENT_TYPE' => 'application/json' }
206
- #
207
- # last_response.should_not be_ok
208
- # last_response.status.should be(422)
209
- #
210
- # last_response.json_body.keys.should include("error")
211
- # end
212
- #
213
- # it "should return a nice error page when launching a process fails (HTML)" do
214
- # params = { :process_definition => %q{http://invalid.invalid} }
215
- #
216
- # post '/_ruote/processes', params
217
- #
218
- # last_response.should_not be_ok
219
- # last_response.status.should be(422)
220
- #
221
- # last_response.should match(/Process failed to launch/)
222
- # end
223
- #
224
- #end
225
- #
226
- #describe "DELETE /_ruote/processes/X-Y", :type => :with_engine do
227
- #
228
- # before(:each) do
229
- # @wfid = launch_test_process do
230
- # Ruote.process_definition :name => 'test' do
231
- # sequence :on_cancel => 'bail_out' do
232
- # echo "done."
233
- # wait '1d'
234
- # end
235
- #
236
- # define :name => 'bail_out' do
237
- # echo "bailout."
238
- # end
239
- # end
240
- # end
241
- # end
242
- #
243
- # it "should cancel processes (JSON)" do
244
- # delete "/_ruote/processes/#{@wfid}.json"
245
- #
246
- # last_response.should be_ok
247
- #
248
- # wait_for( @wfid )
249
- #
250
- # engine.process( @wfid ).should be_nil
251
- #
252
- # @tracer.to_s.should == "done.\nbailout."
253
- # end
254
- #
255
- # it "should cancel processes (HMTL)" do
256
- # delete "/_ruote/processes/#{@wfid}"
257
- #
258
- # last_response.should be_redirect
259
- # last_response['Location'].should == "/_ruote/processes"
260
- #
261
- # wait_for( @wfid )
262
- #
263
- # engine.process( @wfid ).should be_nil
264
- #
265
- # @tracer.to_s.should == "done.\nbailout."
266
- # end
267
- #
268
- # it "should kill processes (JSON)" do
269
- # delete "/_ruote/processes/#{@wfid}.json?_kill=1"
270
- #
271
- # last_response.should be_ok
272
- #
273
- # wait_for( @wfid )
274
- #
275
- # engine.process( @wfid ).should be_nil
276
- #
277
- # @tracer.to_s.should == "done."
278
- # end
279
- #
280
- # it "should kill processes (HTML)" do
281
- # delete "/_ruote/processes/#{@wfid}?_kill=1"
282
- #
283
- # last_response.should be_redirect
284
- # last_response['Location'].should == '/_ruote/processes'
285
- #
286
- # wait_for( @wfid )
287
- #
288
- # engine.process( @wfid ).should be_nil
289
- #
290
- # @tracer.to_s.should == "done."
291
- # end
292
- #end