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.
- 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,52 +1,63 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
require 'spec_helper'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
get "/_ruote/expressions"
|
|
4
|
+
undef :context if defined?(context)
|
|
7
5
|
|
|
8
|
-
last_response.should be_ok
|
|
9
|
-
end
|
|
10
6
|
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
describe 'GET /_ruote/expressions' do
|
|
8
|
+
|
|
9
|
+
it_has_an_engine
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
it 'should 404 (HTML)' do
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
get '/_ruote/expressions'
|
|
14
|
+
|
|
15
|
+
last_response.status.should be(404)
|
|
17
16
|
end
|
|
18
17
|
end
|
|
19
18
|
|
|
20
|
-
describe
|
|
19
|
+
describe 'GET /_ruote/expressions/wfid' do
|
|
20
|
+
|
|
21
|
+
it_has_an_engine
|
|
22
|
+
|
|
23
|
+
describe 'with running processes' do
|
|
21
24
|
|
|
22
|
-
describe "with running processes" do
|
|
23
25
|
before(:each) do
|
|
24
26
|
@wfid = launch_test_process
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
it
|
|
29
|
+
it 'should render the expressions (HTML)' do
|
|
30
|
+
|
|
28
31
|
get "/_ruote/expressions/#{@wfid}"
|
|
29
32
|
|
|
30
33
|
last_response.should be_ok
|
|
31
34
|
end
|
|
32
35
|
|
|
33
|
-
it
|
|
36
|
+
it 'should render the expressions (JSON)' do
|
|
37
|
+
|
|
34
38
|
get "/_ruote/expressions/#{@wfid}.json"
|
|
35
39
|
|
|
36
40
|
last_response.should be_ok
|
|
41
|
+
|
|
42
|
+
last_response.json_body['expressions'].first.keys.sort.should == %w[
|
|
43
|
+
class fei links name parent
|
|
44
|
+
]
|
|
37
45
|
end
|
|
38
46
|
end
|
|
39
47
|
|
|
40
|
-
describe
|
|
41
|
-
|
|
48
|
+
describe 'without running processes' do
|
|
49
|
+
|
|
50
|
+
it 'should 404 correctly (HTML)' do
|
|
51
|
+
|
|
42
52
|
get "/_ruote/expressions/foo"
|
|
43
53
|
|
|
44
54
|
last_response.should_not be_ok
|
|
45
55
|
last_response.status.should be(404)
|
|
46
56
|
end
|
|
47
57
|
|
|
48
|
-
it
|
|
49
|
-
|
|
58
|
+
it 'should 404 correctly (JSON)' do
|
|
59
|
+
|
|
60
|
+
get '/_ruote/expressions/foo.json'
|
|
50
61
|
|
|
51
62
|
last_response.should_not be_ok
|
|
52
63
|
last_response.status.should be(404)
|
|
@@ -54,49 +65,105 @@ describe "GET /_ruote/expressions/wfid", :type => :with_engine do
|
|
|
54
65
|
end
|
|
55
66
|
end
|
|
56
67
|
|
|
57
|
-
describe
|
|
68
|
+
describe 'GET /_ruote/expressions/fei' do
|
|
69
|
+
|
|
70
|
+
it_has_an_engine
|
|
71
|
+
|
|
72
|
+
describe 'with running processes' do
|
|
58
73
|
|
|
59
|
-
describe "with running processes" do
|
|
60
74
|
before(:each) do
|
|
75
|
+
|
|
61
76
|
@wfid = launch_test_process
|
|
62
|
-
process = engine.process(
|
|
77
|
+
process = engine.process(@wfid)
|
|
63
78
|
@nada_exp_id = process.expressions.last.fei.expid
|
|
64
79
|
end
|
|
65
80
|
|
|
66
|
-
it
|
|
67
|
-
|
|
81
|
+
it 'should render the expression (HTML)' do
|
|
82
|
+
|
|
83
|
+
get "/_ruote/expressions/#{@nada_exp_id}!!#{@wfid}"
|
|
68
84
|
|
|
69
85
|
last_response.should be_ok
|
|
70
86
|
end
|
|
71
87
|
|
|
72
|
-
it
|
|
73
|
-
|
|
88
|
+
it 'should render the expression (JSON)' do
|
|
89
|
+
|
|
90
|
+
get "/_ruote/expressions/#{@nada_exp_id}!!#{@wfid}.json"
|
|
74
91
|
|
|
75
92
|
last_response.should be_ok
|
|
93
|
+
|
|
94
|
+
#puts Rufus::Json.pretty_encode(last_response.json_body)
|
|
95
|
+
|
|
96
|
+
last_response.json_body['expression']['links'].size.should be(4)
|
|
97
|
+
|
|
98
|
+
last_response.json_body['expression'].keys.sort.should == %w[
|
|
99
|
+
applied_workitem class fei links name original_tree parent
|
|
100
|
+
timeout_schedule_id tree variables
|
|
101
|
+
]
|
|
76
102
|
end
|
|
77
103
|
end
|
|
78
104
|
|
|
79
|
-
describe
|
|
80
|
-
|
|
81
|
-
|
|
105
|
+
describe 'without running processes' do
|
|
106
|
+
|
|
107
|
+
it 'should 404 correctly (HTML)' do
|
|
108
|
+
|
|
109
|
+
get '/workitems/foo/bar'
|
|
82
110
|
|
|
83
111
|
last_response.should_not be_ok
|
|
84
112
|
last_response.status.should be(404)
|
|
85
113
|
end
|
|
86
114
|
|
|
87
|
-
it
|
|
88
|
-
|
|
115
|
+
it 'should 404 correctly (JSON)' do
|
|
116
|
+
|
|
117
|
+
get '/workitems/foo/bar.json'
|
|
89
118
|
|
|
90
119
|
last_response.should_not be_ok
|
|
91
120
|
last_response.status.should be(404)
|
|
92
121
|
end
|
|
93
122
|
end
|
|
123
|
+
|
|
124
|
+
describe 'with an expression that has a schedule' do
|
|
125
|
+
|
|
126
|
+
before(:each) do
|
|
127
|
+
|
|
128
|
+
@wfid = RuoteKit.engine.launch(Ruote.define do
|
|
129
|
+
alpha :timeout => '2y'
|
|
130
|
+
end)
|
|
131
|
+
|
|
132
|
+
RuoteKit.engine.wait_for(:alpha)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it 'should render the expression (HTML)' do
|
|
136
|
+
|
|
137
|
+
get "/_ruote/expressions/0_0!!#{@wfid}"
|
|
138
|
+
|
|
139
|
+
last_response.status.should be(200)
|
|
140
|
+
|
|
141
|
+
last_response.should have_selector(
|
|
142
|
+
'table.details tr td', :content => 'timeout')
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it 'should render the expression (JSON)' do
|
|
146
|
+
|
|
147
|
+
get "/_ruote/expressions/0_0!!#{@wfid}.json"
|
|
148
|
+
|
|
149
|
+
last_response.status.should be(200)
|
|
150
|
+
|
|
151
|
+
#puts Rufus::Json.pretty_encode(last_response.json_body)
|
|
152
|
+
|
|
153
|
+
last_response.json_body['expression'].keys.should include(
|
|
154
|
+
'timeout_schedule_id')
|
|
155
|
+
end
|
|
156
|
+
end
|
|
94
157
|
end
|
|
95
158
|
|
|
96
|
-
describe
|
|
159
|
+
describe 'DELETE /_ruote/expressions/fei' do
|
|
160
|
+
|
|
161
|
+
it_has_an_engine
|
|
162
|
+
|
|
163
|
+
describe 'with running processes' do
|
|
97
164
|
|
|
98
|
-
describe "with running processes" do
|
|
99
165
|
before(:each) do
|
|
166
|
+
|
|
100
167
|
@wfid = launch_test_process do
|
|
101
168
|
Ruote.process_definition :name => 'delete' do
|
|
102
169
|
sequence do
|
|
@@ -112,72 +179,261 @@ describe "DELETE /_ruote/expressions/wfid/expid", :type => :with_engine do
|
|
|
112
179
|
end
|
|
113
180
|
end
|
|
114
181
|
|
|
115
|
-
wait_exp = engine.process(
|
|
182
|
+
wait_exp = engine.process(@wfid).expressions.last
|
|
116
183
|
@expid = "0_1_0" #wait_exp.fei.expid
|
|
117
184
|
end
|
|
118
185
|
|
|
119
|
-
it
|
|
120
|
-
|
|
186
|
+
it 'should cancel the expressions (HTML)' do
|
|
187
|
+
|
|
188
|
+
delete "/_ruote/expressions/#{@expid}!!#{@wfid}"
|
|
121
189
|
|
|
122
190
|
last_response.should be_redirect
|
|
123
191
|
last_response['Location'].should == "/_ruote/expressions/#{@wfid}"
|
|
124
192
|
|
|
125
193
|
#sleep 0.4
|
|
126
|
-
wait_for(
|
|
194
|
+
wait_for(@wfid)
|
|
127
195
|
|
|
128
196
|
@tracer.to_s.should == "bailed\ndone"
|
|
129
197
|
end
|
|
130
198
|
|
|
131
|
-
it
|
|
132
|
-
|
|
199
|
+
it 'should cancel the expressions (JSON)' do
|
|
200
|
+
|
|
201
|
+
delete "/_ruote/expressions/#{@expid}!!#{@wfid}.json"
|
|
133
202
|
|
|
134
203
|
last_response.should be_ok
|
|
135
204
|
last_response.json_body['status'].should == 'ok'
|
|
136
205
|
|
|
137
206
|
#sleep 0.4
|
|
138
|
-
wait_for(
|
|
207
|
+
wait_for(@wfid)
|
|
139
208
|
|
|
140
209
|
@tracer.to_s.should == "bailed\ndone"
|
|
141
210
|
end
|
|
142
211
|
|
|
143
|
-
it
|
|
144
|
-
|
|
212
|
+
it 'should kill the expression (HTML)' do
|
|
213
|
+
|
|
214
|
+
delete "/_ruote/expressions/#{@expid}!!#{@wfid}?_kill=1"
|
|
145
215
|
|
|
146
216
|
last_response.should be_redirect
|
|
147
217
|
last_response['Location'].should == "/_ruote/expressions/#{@wfid}"
|
|
148
218
|
|
|
149
219
|
#sleep 0.4
|
|
150
|
-
wait_for(
|
|
220
|
+
wait_for(@wfid)
|
|
151
221
|
|
|
152
|
-
@tracer.to_s.should ==
|
|
222
|
+
@tracer.to_s.should == 'done'
|
|
153
223
|
end
|
|
154
224
|
|
|
155
|
-
it
|
|
156
|
-
|
|
225
|
+
it 'should kill the expression (JSON)' do
|
|
226
|
+
|
|
227
|
+
delete "/_ruote/expressions/#{@expid}!!#{@wfid}.json?_kill=1"
|
|
157
228
|
|
|
158
229
|
last_response.should be_ok
|
|
159
230
|
last_response.json_body['status'].should == 'ok'
|
|
160
231
|
|
|
161
232
|
#sleep 0.4
|
|
162
|
-
wait_for(
|
|
233
|
+
wait_for(@wfid)
|
|
163
234
|
|
|
164
|
-
@tracer.to_s.should ==
|
|
235
|
+
@tracer.to_s.should == 'done'
|
|
165
236
|
end
|
|
166
237
|
end
|
|
167
238
|
|
|
168
|
-
describe
|
|
169
|
-
|
|
170
|
-
|
|
239
|
+
describe 'without running processes' do
|
|
240
|
+
|
|
241
|
+
it 'should 404 correctly (HTML)' do
|
|
242
|
+
|
|
243
|
+
delete '/_ruote/expressions/foo/bar'
|
|
171
244
|
|
|
172
245
|
last_response.should_not be_ok
|
|
173
246
|
last_response.status.should be(404)
|
|
174
247
|
end
|
|
175
248
|
|
|
176
|
-
it
|
|
177
|
-
|
|
249
|
+
it 'should 404 correctly (JSON)' do
|
|
250
|
+
|
|
251
|
+
delete '/_ruote/expressions/foo/bar.json'
|
|
178
252
|
|
|
179
253
|
last_response.should_not be_ok
|
|
180
254
|
last_response.status.should be(404)
|
|
181
255
|
end
|
|
182
256
|
end
|
|
183
257
|
end
|
|
258
|
+
|
|
259
|
+
describe 'PUT /_ruote/expressions/fei' do
|
|
260
|
+
|
|
261
|
+
it_has_an_engine
|
|
262
|
+
|
|
263
|
+
before(:each) do
|
|
264
|
+
|
|
265
|
+
@wfid = launch_test_process do
|
|
266
|
+
Ruote.process_definition do
|
|
267
|
+
alpha
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
@exp = RuoteKit.engine.process(@wfid).expressions.find { |e|
|
|
272
|
+
e.fei.expid == '0_0'
|
|
273
|
+
}
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
it 'should re-apply (HTML)' do
|
|
277
|
+
|
|
278
|
+
at0 = RuoteKit.engine.storage_participant.first.dispatched_at
|
|
279
|
+
|
|
280
|
+
put(
|
|
281
|
+
"/_ruote/expressions/#{@exp.fei.sid}",
|
|
282
|
+
:fields => '{}')
|
|
283
|
+
|
|
284
|
+
last_response.status.should be(302)
|
|
285
|
+
last_response.location.should == "/_ruote/expressions/#{@wfid}"
|
|
286
|
+
|
|
287
|
+
#RuoteKit.engine.wait_for(:alpha)
|
|
288
|
+
sleep 0.500
|
|
289
|
+
|
|
290
|
+
at1 = RuoteKit.engine.storage_participant.first.dispatched_at
|
|
291
|
+
|
|
292
|
+
at1.should_not == at0
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
it 'should re-apply (JSON)' do
|
|
296
|
+
|
|
297
|
+
#RuoteKit.engine.noisy = true
|
|
298
|
+
|
|
299
|
+
at0 = RuoteKit.engine.storage_participant.first.dispatched_at
|
|
300
|
+
|
|
301
|
+
put(
|
|
302
|
+
"/_ruote/expressions/#{@exp.fei.sid}.json",
|
|
303
|
+
Rufus::Json.encode({}),
|
|
304
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
|
305
|
+
|
|
306
|
+
last_response.status.should be(200)
|
|
307
|
+
|
|
308
|
+
#RuoteKit.engine.wait_for(:alpha)
|
|
309
|
+
sleep 0.500
|
|
310
|
+
|
|
311
|
+
at1 = RuoteKit.engine.storage_participant.first.dispatched_at
|
|
312
|
+
|
|
313
|
+
at1.should_not == at0
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
it 'should re-apply with different fields (HTML)' do
|
|
317
|
+
|
|
318
|
+
wi = RuoteKit.engine.storage_participant.first
|
|
319
|
+
wi.fields['car'].should be(nil)
|
|
320
|
+
|
|
321
|
+
put(
|
|
322
|
+
"/_ruote/expressions/#{@exp.fei.sid}",
|
|
323
|
+
:fields => '{"car":"daimler-benz"}')
|
|
324
|
+
|
|
325
|
+
last_response.status.should be(302)
|
|
326
|
+
last_response.location.should == "/_ruote/expressions/#{@wfid}"
|
|
327
|
+
|
|
328
|
+
#RuoteKit.engine.wait_for(:alpha)
|
|
329
|
+
sleep 0.500
|
|
330
|
+
|
|
331
|
+
wi = RuoteKit.engine.storage_participant.first
|
|
332
|
+
|
|
333
|
+
wi.fields['car'].should == 'daimler-benz'
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
it 'should re-apply with different fields (JSON)' do
|
|
337
|
+
|
|
338
|
+
wi = RuoteKit.engine.storage_participant.first
|
|
339
|
+
wi.fields['car'].should be(nil)
|
|
340
|
+
|
|
341
|
+
put(
|
|
342
|
+
"/_ruote/expressions/#{@exp.fei.sid}.json",
|
|
343
|
+
Rufus::Json.encode({ 'fields' => { 'car' => 'bentley' } }),
|
|
344
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
|
345
|
+
|
|
346
|
+
last_response.status.should be(200)
|
|
347
|
+
|
|
348
|
+
#RuoteKit.engine.wait_for(:alpha)
|
|
349
|
+
sleep 0.500
|
|
350
|
+
|
|
351
|
+
wi = RuoteKit.engine.storage_participant.first
|
|
352
|
+
|
|
353
|
+
wi.fields['car'].should == 'bentley'
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
it 'should re-apply when passed {"expression":{"fields":...}} (JSON)' do
|
|
357
|
+
|
|
358
|
+
exp = { 'expression' => { 'fields' => { 'car' => 'BMW' } } }
|
|
359
|
+
|
|
360
|
+
put(
|
|
361
|
+
"/_ruote/expressions/#{@exp.fei.sid}.json",
|
|
362
|
+
Rufus::Json.encode(exp),
|
|
363
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
|
364
|
+
|
|
365
|
+
last_response.status.should be(200)
|
|
366
|
+
|
|
367
|
+
#RuoteKit.engine.wait_for(:alpha)
|
|
368
|
+
sleep 0.500
|
|
369
|
+
|
|
370
|
+
wi = RuoteKit.engine.storage_participant.first
|
|
371
|
+
|
|
372
|
+
wi.fields['car'].should == 'BMW'
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
it 'should re-apply with a different tree (HTML)' do
|
|
376
|
+
|
|
377
|
+
put(
|
|
378
|
+
"/_ruote/expressions/#{@exp.fei.sid}",
|
|
379
|
+
:tree => '["charly", {}, []]')
|
|
380
|
+
|
|
381
|
+
last_response.status.should be(302)
|
|
382
|
+
last_response.location.should == "/_ruote/expressions/#{@wfid}"
|
|
383
|
+
|
|
384
|
+
#RuoteKit.engine.wait_for(:alpha)
|
|
385
|
+
sleep 0.500
|
|
386
|
+
|
|
387
|
+
wi = RuoteKit.engine.storage_participant.first
|
|
388
|
+
|
|
389
|
+
wi.participant_name.should == 'charly'
|
|
390
|
+
|
|
391
|
+
RuoteKit.engine.process(@wfid).current_tree.should == [ 'define', {}, [
|
|
392
|
+
[ 'participant', { '_triggered' => 'on_re_apply', 'ref' => 'charly' }, [] ] ] ]
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
it 'should re-apply with a different tree (JSON)' do
|
|
396
|
+
|
|
397
|
+
wi = RuoteKit.engine.storage_participant.first
|
|
398
|
+
wi.participant_name.should == 'alpha'
|
|
399
|
+
|
|
400
|
+
put(
|
|
401
|
+
"/_ruote/expressions/#{@exp.fei.sid}.json",
|
|
402
|
+
Rufus::Json.encode({ 'tree' => [ 'bravo', {}, [] ] }),
|
|
403
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
|
404
|
+
|
|
405
|
+
last_response.status.should be(200)
|
|
406
|
+
|
|
407
|
+
#RuoteKit.engine.wait_for(:alpha)
|
|
408
|
+
sleep 0.500
|
|
409
|
+
|
|
410
|
+
wi = RuoteKit.engine.storage_participant.first
|
|
411
|
+
|
|
412
|
+
wi.participant_name.should == 'bravo'
|
|
413
|
+
|
|
414
|
+
RuoteKit.engine.process(@wfid).current_tree.should == [ 'define', {}, [
|
|
415
|
+
[ 'participant', { '_triggered' => 'on_re_apply', 'ref' => 'bravo' }, [] ] ] ]
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
it 'should 400 when passed bogus JSON (HTML)' do
|
|
419
|
+
|
|
420
|
+
put(
|
|
421
|
+
"/_ruote/expressions/#{@exp.fei.sid}",
|
|
422
|
+
:fields => "{bogus}")
|
|
423
|
+
|
|
424
|
+
last_response.status.should be(400)
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
it 'should 400 when passed bogus JSON (JSON)' do
|
|
428
|
+
|
|
429
|
+
put(
|
|
430
|
+
"/_ruote/expressions/#{@exp.fei.sid}.json",
|
|
431
|
+
'{"fields":{bogus}}',
|
|
432
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
|
433
|
+
|
|
434
|
+
last_response.status.should be(400)
|
|
435
|
+
last_response.json_body['http_error']['code'].should == 400
|
|
436
|
+
last_response.json_body['http_error']['message'].should == 'bad request'
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
|
|
@@ -1,44 +1,55 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
require 'spec_helper'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
|
|
5
|
+
describe 'GET /' do
|
|
6
|
+
|
|
7
|
+
it_has_an_engine
|
|
8
|
+
|
|
9
|
+
it 'should return a welcome message in HTML be default' do
|
|
10
|
+
|
|
11
|
+
get '/_ruote'
|
|
7
12
|
|
|
8
13
|
last_response.should be_ok
|
|
9
|
-
last_response.content_type.should match(
|
|
14
|
+
last_response.content_type.should match('text/html')
|
|
10
15
|
|
|
11
16
|
last_response.should match(/Hello world/)
|
|
12
17
|
last_response.should match(/<title>/)
|
|
13
18
|
end
|
|
14
19
|
|
|
15
|
-
it
|
|
16
|
-
|
|
20
|
+
it 'should return a version string if JSON is requested' do
|
|
21
|
+
|
|
22
|
+
header 'Accept', 'application/json'
|
|
17
23
|
|
|
18
|
-
get
|
|
24
|
+
get '/_ruote'
|
|
19
25
|
|
|
20
26
|
last_response.should be_ok
|
|
21
|
-
last_response.content_type.should match(
|
|
27
|
+
last_response.content_type.should match('application/json')
|
|
22
28
|
body = last_response.json_body
|
|
23
29
|
|
|
24
|
-
body[
|
|
30
|
+
body['misc'].should == {
|
|
31
|
+
'ruote-kit' => 'welcome', 'version' => RuoteKit::VERSION.to_s }
|
|
25
32
|
end
|
|
26
33
|
end
|
|
27
34
|
|
|
28
|
-
describe
|
|
35
|
+
describe 'Generic error handling' do
|
|
29
36
|
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
it_has_an_engine
|
|
38
|
+
|
|
39
|
+
it 'should give our own 404 page (HTML)' do
|
|
40
|
+
|
|
41
|
+
get '/kenneth'
|
|
32
42
|
|
|
33
43
|
last_response.should_not be_ok
|
|
34
44
|
last_response.status.should be(404)
|
|
35
45
|
|
|
36
46
|
last_response.should be_html
|
|
37
|
-
last_response.should match(/
|
|
47
|
+
last_response.should match(/resource not found/)
|
|
38
48
|
end
|
|
39
49
|
|
|
40
|
-
it
|
|
41
|
-
|
|
50
|
+
it 'should give our own 404 data (JSON)' do
|
|
51
|
+
|
|
52
|
+
get '/kenneth.json'
|
|
42
53
|
|
|
43
54
|
last_response.should_not be_ok
|
|
44
55
|
last_response.status.should be(404)
|
|
@@ -46,3 +57,4 @@ describe "Generic error handling", :type => :with_engine do
|
|
|
46
57
|
last_response.should be_json
|
|
47
58
|
end
|
|
48
59
|
end
|
|
60
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
|
|
2
|
+
require 'spec_helper'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
describe 'GET /_ruote/participants' do
|
|
6
|
+
|
|
7
|
+
describe 'without any participant' do
|
|
8
|
+
|
|
9
|
+
it_has_an_engine_with_no_participants
|
|
10
|
+
|
|
11
|
+
it 'should give an empty list (HTML)' do
|
|
12
|
+
get '/_ruote/participants'
|
|
13
|
+
|
|
14
|
+
last_response.status.should be(200)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'should give an empty array (JSON)' do
|
|
18
|
+
|
|
19
|
+
get '/_ruote/participants.json'
|
|
20
|
+
|
|
21
|
+
last_response.status.should be(200)
|
|
22
|
+
|
|
23
|
+
body = last_response.json_body
|
|
24
|
+
body.should have_key('participants')
|
|
25
|
+
|
|
26
|
+
body['participants'].should be_empty
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe 'with participant' do
|
|
31
|
+
|
|
32
|
+
it_has_an_engine
|
|
33
|
+
|
|
34
|
+
it 'should give participant information back (HTML)' do
|
|
35
|
+
|
|
36
|
+
get '/_ruote/participants'
|
|
37
|
+
|
|
38
|
+
last_response.status.should be(200)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'should give participant information back (JSON)' do
|
|
42
|
+
|
|
43
|
+
get '/_ruote/participants.json'
|
|
44
|
+
|
|
45
|
+
last_response.status.should be(200)
|
|
46
|
+
|
|
47
|
+
body = last_response.json_body
|
|
48
|
+
|
|
49
|
+
body['participants'].should_not be_empty
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe 'PUT /_ruote/participants' do
|
|
55
|
+
|
|
56
|
+
it_has_an_engine
|
|
57
|
+
|
|
58
|
+
it 'should update the list (HTML)' do
|
|
59
|
+
|
|
60
|
+
put(
|
|
61
|
+
'/_ruote/participants',
|
|
62
|
+
'regex_0' => '^alice$',
|
|
63
|
+
'classname_0' => 'Ruote::StorageParticipant',
|
|
64
|
+
'options_0' => '{}',
|
|
65
|
+
'regex_1' => '^bravo$',
|
|
66
|
+
'classname_1' => 'Ruote::StorageParticipant',
|
|
67
|
+
'options_1' => '{}')
|
|
68
|
+
|
|
69
|
+
last_response.should be_redirect
|
|
70
|
+
last_response['Location'].should == '/_ruote/participants'
|
|
71
|
+
|
|
72
|
+
RuoteKit.engine.participant_list.collect { |pe| pe.regex }.should == [
|
|
73
|
+
'^alice$', '^bravo$'
|
|
74
|
+
]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'should update the list (JSON)' do
|
|
78
|
+
|
|
79
|
+
list = {
|
|
80
|
+
'participants' => [
|
|
81
|
+
{ 'regex' => '^alice$',
|
|
82
|
+
'classname' => 'Ruote::StorageParticipant',
|
|
83
|
+
'options' => {} },
|
|
84
|
+
{ 'regex' => '^bravo$',
|
|
85
|
+
'classname' => 'Ruote::StorageParticipant',
|
|
86
|
+
'options' => {} }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
put(
|
|
91
|
+
'/_ruote/participants.json',
|
|
92
|
+
Rufus::Json.encode(list),
|
|
93
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
|
94
|
+
|
|
95
|
+
last_response.status.should be(200)
|
|
96
|
+
|
|
97
|
+
RuoteKit.engine.participant_list.collect { |pe| pe.regex }.should == [
|
|
98
|
+
'^alice$', '^bravo$'
|
|
99
|
+
]
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|