ruote-kit 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +0 -0
- data/.gitignore +8 -0
- data/Gemfile +10 -0
- data/README.rdoc +132 -0
- data/Rakefile +57 -0
- data/config.ru +21 -0
- data/lib/ruote-kit/application.rb +50 -0
- data/lib/ruote-kit/configuration.rb +52 -0
- data/lib/ruote-kit/helpers/engine_helpers.rb +24 -0
- data/lib/ruote-kit/helpers/form_helpers.rb +11 -0
- data/lib/ruote-kit/helpers/launch_item_parser.rb +59 -0
- data/lib/ruote-kit/helpers/navigation_helpers.rb +54 -0
- data/lib/ruote-kit/helpers/render_helpers.rb +103 -0
- data/lib/ruote-kit/helpers.rb +9 -0
- 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 +191 -0
- data/lib/ruote-kit/public/_ruote/javascripts/fluo-can.js +1111 -0
- data/lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js +149 -0
- data/lib/ruote-kit/public/_ruote/javascripts/fluo-json.js +183 -0
- data/lib/ruote-kit/public/_ruote/javascripts/fluo-tred.js +515 -0
- data/lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css +226 -0
- data/lib/ruote-kit/public/_ruote/stylesheets/base.css +336 -0
- data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +30 -0
- data/lib/ruote-kit/public/_ruote/stylesheets/style.css +393 -0
- data/lib/ruote-kit/resources/expressions.rb +55 -0
- data/lib/ruote-kit/resources/processes.rb +52 -0
- data/lib/ruote-kit/resources/workitems.rb +64 -0
- data/lib/ruote-kit/spec/ruote_helpers.rb +47 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/LICENSE +21 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/README.markdown +102 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/Rakefile +30 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/VERSION.yml +4 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/lib/sinatra/respond_to.rb +206 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/sinatra-respond_to.gemspec +56 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static folder/.keep +0 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static.txt +1 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/test_app.rb +53 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/unreachable_static.txt +1 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/layout.html.haml +2 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.html.haml +1 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.js.erb +3 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.xml.builder +3 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/extension_spec.rb +403 -0
- data/lib/ruote-kit/vendor/sinatra-respond_to/spec/spec_helper.rb +18 -0
- data/lib/ruote-kit/views/expression.html.haml +38 -0
- data/lib/ruote-kit/views/expressions.html.haml +30 -0
- data/lib/ruote-kit/views/index.html.haml +1 -0
- data/lib/ruote-kit/views/launch_process.html.haml +19 -0
- data/lib/ruote-kit/views/layout.html.haml +46 -0
- data/lib/ruote-kit/views/process.html.haml +55 -0
- data/lib/ruote-kit/views/processes.html.haml +27 -0
- data/lib/ruote-kit/views/resource_not_found.html.haml +7 -0
- data/lib/ruote-kit/views/workitem.html.haml +39 -0
- data/lib/ruote-kit/views/workitems.html.haml +23 -0
- data/lib/ruote-kit.rb +105 -0
- data/ruote-kit.gemspec +136 -0
- data/spec/helpers/render_helpers_spec.rb +211 -0
- data/spec/resources/expressions_spec.rb +179 -0
- data/spec/resources/index_spec.rb +46 -0
- data/spec/resources/processes_spec.rb +259 -0
- data/spec/resources/workitems_spec.rb +308 -0
- data/spec/ruote-kit_spec.rb +4 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +152 -0
- data/spec/views/launch_process.html.haml_spec.rb +21 -0
- data/spec/views/process.html.haml_spec.rb +16 -0
- data/spec/views/processes.html.haml_spec.rb +30 -0
- data/spec/views/workitems.html.haml_spec.rb +68 -0
- metadata +185 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "GET /" do
|
4
|
+
it "should return a welcome message in HTML be default" do
|
5
|
+
get "/_ruote"
|
6
|
+
|
7
|
+
last_response.should be_ok
|
8
|
+
last_response.content_type.should match("text/html")
|
9
|
+
|
10
|
+
last_response.should match(/Hello world/)
|
11
|
+
last_response.should match(/<title>/)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return a version string if JSON is requested" do
|
15
|
+
header "Accept", "application/json"
|
16
|
+
|
17
|
+
get "/_ruote"
|
18
|
+
|
19
|
+
last_response.should be_ok
|
20
|
+
last_response.content_type.should match("application/json")
|
21
|
+
body = last_response.json_body
|
22
|
+
|
23
|
+
body["misc"].should == { "ruote-kit" => "welcome", "version" => RuoteKit::VERSION.to_s }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "Generic error handling" do
|
28
|
+
it "should give our own 404 page (HTML)" do
|
29
|
+
get "/kenneth"
|
30
|
+
|
31
|
+
last_response.should_not be_ok
|
32
|
+
last_response.status.should be(404)
|
33
|
+
|
34
|
+
last_response.should be_html
|
35
|
+
last_response.should match(/Resource not found/)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should give our own 404 data (JSON)" do
|
39
|
+
get "/kenneth.json"
|
40
|
+
|
41
|
+
last_response.should_not be_ok
|
42
|
+
last_response.status.should be(404)
|
43
|
+
|
44
|
+
last_response.should be_json
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,259 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "GET /_ruote/processes" do
|
4
|
+
describe "without any running processes" do
|
5
|
+
it "should give no processes back (HTML)" do
|
6
|
+
get "/_ruote/processes"
|
7
|
+
|
8
|
+
last_response.should be_ok
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should give an empty array (JSON)" do
|
12
|
+
get "/_ruote/processes.json"
|
13
|
+
|
14
|
+
last_response.should be_ok
|
15
|
+
|
16
|
+
body = last_response.json_body
|
17
|
+
body.should have_key("processes")
|
18
|
+
|
19
|
+
body["processes"].should be_empty
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "with running processes" do
|
24
|
+
before(:each) do
|
25
|
+
@wfid = launch_test_process
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should give process information back (HTML)" do
|
29
|
+
get "/_ruote/processes"
|
30
|
+
|
31
|
+
last_response.should be_ok
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should give process information back (JSON)" do
|
35
|
+
get "/_ruote/processes.json"
|
36
|
+
|
37
|
+
last_response.should be_ok
|
38
|
+
|
39
|
+
body = last_response.json_body
|
40
|
+
|
41
|
+
body["processes"].should_not be_empty
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "GET /_ruote/processes/X-Y" do
|
47
|
+
describe "with a running process" do
|
48
|
+
before(:each) do
|
49
|
+
@wfid = launch_test_process
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should give process information back (HTML)" do
|
53
|
+
get "/_ruote/processes/#{@wfid}"
|
54
|
+
|
55
|
+
last_response.should be_ok
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should give process information back (JSON)" do
|
59
|
+
get "/_ruote/processes/#{@wfid}.json"
|
60
|
+
|
61
|
+
last_response.should be_ok
|
62
|
+
|
63
|
+
body = last_response.json_body
|
64
|
+
|
65
|
+
body.should have_key('process')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "without a running process" do
|
70
|
+
it "should 404 correctly (HTML)" do
|
71
|
+
get "/_ruote/processes/foo"
|
72
|
+
|
73
|
+
last_response.should_not be_ok
|
74
|
+
last_response.status.should be(404)
|
75
|
+
|
76
|
+
last_response.should match(/Resource not found/)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should 404 correctly (JSON)" do
|
80
|
+
get "/_ruote/processes/foo.json"
|
81
|
+
|
82
|
+
last_response.should_not be_ok
|
83
|
+
last_response.status.should be(404)
|
84
|
+
|
85
|
+
last_response.json_body.keys.should include("error")
|
86
|
+
last_response.json_body['error'].should == { "code" => "404", "message" => "Resource not found" }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "GET /_ruote/processes/new" do
|
92
|
+
it "should return a launch form" do
|
93
|
+
get "/_ruote/processes/new"
|
94
|
+
|
95
|
+
last_response.should be_ok
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe "POST /_ruote/processes" do
|
100
|
+
before(:each) do
|
101
|
+
engine.processes.should be_empty
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should launch a valid process definition (JSON)" do
|
105
|
+
params = {
|
106
|
+
:definition => %q{Ruote.process_definition :name => 'test' do
|
107
|
+
_sleep '1m'
|
108
|
+
end}
|
109
|
+
}
|
110
|
+
|
111
|
+
post '/_ruote/processes.json', params.to_json, { 'CONTENT_TYPE' => 'application/json' }
|
112
|
+
|
113
|
+
last_response.should be_ok
|
114
|
+
|
115
|
+
last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
|
116
|
+
|
117
|
+
sleep 0.4
|
118
|
+
|
119
|
+
engine.processes.should_not be_empty
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should launch a valid process definition with fields (JSON)" do
|
123
|
+
params = {
|
124
|
+
:definition => %q{Ruote.process_definition :name => 'test' do
|
125
|
+
echo '${f:foo}'
|
126
|
+
end},
|
127
|
+
:fields => { :foo => 'bar' }
|
128
|
+
}
|
129
|
+
|
130
|
+
post '/_ruote/processes.json', params.to_json, { 'CONTENT_TYPE' => 'application/json' }
|
131
|
+
|
132
|
+
last_response.should be_ok
|
133
|
+
last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
|
134
|
+
|
135
|
+
sleep 0.5
|
136
|
+
|
137
|
+
@tracer.to_s.should == "bar"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should launch a valid process definition (HTML)" do
|
141
|
+
params = {
|
142
|
+
:process_definition => %q{Ruote.process_definition :name => "test" do
|
143
|
+
_sleep '1m'
|
144
|
+
end
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
post "/_ruote/processes", params
|
149
|
+
|
150
|
+
last_response.should be_redirect
|
151
|
+
last_response['Location'].should match( /^\/_ruote\/processes\/[0-9a-z\-]+$/ )
|
152
|
+
|
153
|
+
sleep 0.4
|
154
|
+
|
155
|
+
engine.processes.should_not be_empty
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should launch a process definition with fields (HTML)" do
|
159
|
+
params = {
|
160
|
+
:process_definition => %q{Ruote.process_definition :name => 'test' do
|
161
|
+
echo '${f:foo}'
|
162
|
+
end},
|
163
|
+
:process_fields => %q{ { "foo": "bar" } }
|
164
|
+
}
|
165
|
+
|
166
|
+
post '/_ruote/processes', params
|
167
|
+
|
168
|
+
last_response.should be_redirect
|
169
|
+
last_response['Location'].should match( /^\/_ruote\/processes\/([0-9a-z\-]+)$/ )
|
170
|
+
|
171
|
+
sleep 0.5
|
172
|
+
|
173
|
+
@tracer.to_s.should == "bar"
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should correct for empty fields sent by browsers" do
|
177
|
+
params = {
|
178
|
+
:process_definition => %q{Ruote.process_definition :name => 'test' do
|
179
|
+
wait '5m'
|
180
|
+
end},
|
181
|
+
:process_fields => ''
|
182
|
+
}
|
183
|
+
|
184
|
+
post '/_ruote/processes', params
|
185
|
+
|
186
|
+
last_response.should be_redirect
|
187
|
+
|
188
|
+
sleep 0.4
|
189
|
+
|
190
|
+
engine.processes.should_not be_empty
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
describe "DELETE /_ruote/processes/X-Y" do
|
195
|
+
before(:each) do
|
196
|
+
@wfid = launch_test_process do
|
197
|
+
Ruote.process_definition :name => 'test' do
|
198
|
+
sequence :on_cancel => 'bail_out' do
|
199
|
+
echo "done."
|
200
|
+
wait '1d'
|
201
|
+
end
|
202
|
+
|
203
|
+
define :name => 'bail_out' do
|
204
|
+
echo "bailout."
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
it "should cancel processes (JSON)" do
|
211
|
+
delete "/_ruote/processes/#{@wfid}.json"
|
212
|
+
|
213
|
+
last_response.should be_ok
|
214
|
+
|
215
|
+
wait_for( @wfid )
|
216
|
+
|
217
|
+
engine.process( @wfid ).should be_nil
|
218
|
+
|
219
|
+
@tracer.to_s.should == "done.\nbailout."
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should cancel processes (HMTL)" do
|
223
|
+
delete "/_ruote/processes/#{@wfid}"
|
224
|
+
|
225
|
+
last_response.should be_redirect
|
226
|
+
last_response['Location'].should == "/_ruote/processes"
|
227
|
+
|
228
|
+
wait_for( @wfid )
|
229
|
+
|
230
|
+
engine.process( @wfid ).should be_nil
|
231
|
+
|
232
|
+
@tracer.to_s.should == "done.\nbailout."
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should kill processes (JSON)" do
|
236
|
+
delete "/_ruote/processes/#{@wfid}.json?_kill=1"
|
237
|
+
|
238
|
+
last_response.should be_ok
|
239
|
+
|
240
|
+
wait_for( @wfid )
|
241
|
+
|
242
|
+
engine.process( @wfid ).should be_nil
|
243
|
+
|
244
|
+
@tracer.to_s.should == "done."
|
245
|
+
end
|
246
|
+
|
247
|
+
it "should kill processes (HTML)" do
|
248
|
+
delete "/_ruote/processes/#{@wfid}?_kill=1"
|
249
|
+
|
250
|
+
last_response.should be_redirect
|
251
|
+
last_response['Location'].should == '/_ruote/processes'
|
252
|
+
|
253
|
+
wait_for( @wfid )
|
254
|
+
|
255
|
+
engine.process( @wfid ).should be_nil
|
256
|
+
|
257
|
+
@tracer.to_s.should == "done."
|
258
|
+
end
|
259
|
+
end
|
@@ -0,0 +1,308 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "GET /_ruote/workitems" do
|
4
|
+
describe "without any workitems" do
|
5
|
+
it "should report no workitems (HTML)" do
|
6
|
+
get "/_ruote/workitems"
|
7
|
+
|
8
|
+
last_response.should be_ok
|
9
|
+
last_response.should match(/No workitems are currently available/)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should report no workitems (JSON)" do
|
13
|
+
get "/_ruote/workitems.json"
|
14
|
+
|
15
|
+
last_response.should be_ok
|
16
|
+
json = last_response.json_body
|
17
|
+
|
18
|
+
json.should have_key('workitems')
|
19
|
+
json['workitems'].should be_empty
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "with workitems" do
|
24
|
+
before(:each) do
|
25
|
+
@wfid = launch_test_process do
|
26
|
+
Ruote.process_definition :name => 'test' do
|
27
|
+
sequence do
|
28
|
+
nada :activity => 'Work your magic'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should have a list of workitems (HTML)" do
|
35
|
+
get "/_ruote/workitems"
|
36
|
+
|
37
|
+
last_response.should be_ok
|
38
|
+
last_response.should match(/1 workitem available/)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have a list of workitems (JSON)" do
|
42
|
+
get "/_ruote/workitems.json"
|
43
|
+
|
44
|
+
last_response.should be_ok
|
45
|
+
json = last_response.json_body
|
46
|
+
|
47
|
+
json['workitems'].size.should be(1)
|
48
|
+
|
49
|
+
wi = json['workitems'][0]
|
50
|
+
|
51
|
+
wi.keys.should include('fei', 'participant_name', 'fields')
|
52
|
+
wi['fei']['wfid'].should == @wfid
|
53
|
+
wi['participant_name'].should == 'nada'
|
54
|
+
wi['fields']['params']['activity'].should == 'Work your magic'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "GET /_ruote/workitems/wfid" do
|
60
|
+
describe "with workitems" do
|
61
|
+
before(:each) do
|
62
|
+
@wfid = launch_test_process do
|
63
|
+
Ruote.process_definition :name => 'foo' do
|
64
|
+
concurrence do
|
65
|
+
nada :activity => 'This'
|
66
|
+
nada :activity => 'Or that'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should list the workitems (HTML)" do
|
73
|
+
get "/_ruote/workitems/#{@wfid}"
|
74
|
+
|
75
|
+
last_response.should be_ok
|
76
|
+
last_response.should match(/2 workitems available for #{@wfid}/)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should list the workitems (JSON)" do
|
80
|
+
get "/_ruote/workitems/#{@wfid}.json"
|
81
|
+
|
82
|
+
last_response.should be_ok
|
83
|
+
|
84
|
+
json = last_response.json_body
|
85
|
+
|
86
|
+
json.should have_key('workitems')
|
87
|
+
json['workitems'].should_not be_empty
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "without workitems" do
|
92
|
+
it "should report no workitems (HTML)" do
|
93
|
+
get "/_ruote/workitems/foo"
|
94
|
+
|
95
|
+
last_response.should be_ok
|
96
|
+
last_response.should match(/No workitems are currently available for foo/)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should report an empty list (JSON)" do
|
100
|
+
get "/_ruote/workitems/foo.json"
|
101
|
+
|
102
|
+
last_response.should be_ok
|
103
|
+
|
104
|
+
json = last_response.json_body
|
105
|
+
|
106
|
+
json.should have_key('workitems')
|
107
|
+
json['workitems'].should be_empty
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe "GET /_ruote/workitems/wfid/expid" do
|
113
|
+
describe "with a workitem" do
|
114
|
+
before(:each) do
|
115
|
+
@wfid = launch_test_process do
|
116
|
+
Ruote.process_definition :name => 'foo' do
|
117
|
+
sequence do
|
118
|
+
nada :activity => 'Work your magic'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
process = engine.process( @wfid )
|
124
|
+
@nada_exp_id = "0_0_0" #process.expressions.last.fei.expid
|
125
|
+
|
126
|
+
@nada_exp_id.should_not be_nil
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should return it (HTML)" do
|
130
|
+
get "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}"
|
131
|
+
|
132
|
+
last_response.should be_ok
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should return it (JSON)" do
|
136
|
+
get "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}.json"
|
137
|
+
|
138
|
+
last_response.should be_ok
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "without a workitem" do
|
143
|
+
it "should return a 404 (HTML)" do
|
144
|
+
get "/_ruote/workitems/foo/bar"
|
145
|
+
|
146
|
+
last_response.should_not be_ok
|
147
|
+
last_response.status.should be(404)
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should return a 404 (JSON)" do
|
151
|
+
get "/_ruote/workitems/foo/bar.json"
|
152
|
+
|
153
|
+
last_response.should_not be_ok
|
154
|
+
last_response.status.should be(404)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "PUT /_ruote/workitems/X-Y" do
|
160
|
+
before(:each) do
|
161
|
+
@wfid = launch_test_process do
|
162
|
+
Ruote.process_definition :name => 'foo' do
|
163
|
+
sequence do
|
164
|
+
nada :activity => 'Work your magic'
|
165
|
+
echo "${f:foo}"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
process = engine.process( @wfid )
|
171
|
+
@nada_exp_id = "0_0_0" #process.expressions.last.fei.expid
|
172
|
+
|
173
|
+
@nada_exp_id.should_not be_nil
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should update the workitem fields (HTML)" do
|
177
|
+
fields = {
|
178
|
+
"params" => {
|
179
|
+
"activity" => "Work your magic",
|
180
|
+
},
|
181
|
+
"foo" => "bar"
|
182
|
+
}
|
183
|
+
|
184
|
+
put "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}", :fields => fields.to_json
|
185
|
+
|
186
|
+
last_response.should be_redirect
|
187
|
+
last_response['Location'].should == "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}"
|
188
|
+
|
189
|
+
find_workitem( @wfid, @nada_exp_id ).fields.should == fields
|
190
|
+
|
191
|
+
sleep 0.4
|
192
|
+
|
193
|
+
@tracer.to_s.should == ""
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should update the workitem fields (JSON)" do
|
197
|
+
fields = {
|
198
|
+
"params" => {
|
199
|
+
"activity" => "Work your magic",
|
200
|
+
},
|
201
|
+
"foo" => "bar"
|
202
|
+
}
|
203
|
+
params = {
|
204
|
+
"fields" => fields
|
205
|
+
}
|
206
|
+
|
207
|
+
put "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}.json", params.to_json, { 'CONTENT_TYPE' => 'application/json' }
|
208
|
+
|
209
|
+
last_response.should be_ok
|
210
|
+
|
211
|
+
find_workitem( @wfid, @nada_exp_id ).fields.should == fields
|
212
|
+
|
213
|
+
sleep 0.4
|
214
|
+
|
215
|
+
@tracer.to_s.should == ""
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should reply to the engine (HTML)" do
|
219
|
+
fields = {
|
220
|
+
"params" => {
|
221
|
+
"activity" => "Work your magic",
|
222
|
+
},
|
223
|
+
"foo" => "bar"
|
224
|
+
}.to_json
|
225
|
+
|
226
|
+
put "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}", :fields => fields, :_proceed => '1'
|
227
|
+
|
228
|
+
last_response.should be_redirect
|
229
|
+
last_response['Location'].should == "/_ruote/workitems/#{@wfid}"
|
230
|
+
|
231
|
+
#engine.context[:s_logger].wait_for([
|
232
|
+
# [ :processes, :terminated, { :wfid => @wfid } ],
|
233
|
+
# [ :errors, nil, { :wfid => @wfid } ]
|
234
|
+
#])
|
235
|
+
sleep 0.5
|
236
|
+
|
237
|
+
@tracer.to_s.should == "bar"
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should reply to the engine (JSON)" do
|
241
|
+
fields = {
|
242
|
+
"params" => {
|
243
|
+
"activity" => "Work your magic",
|
244
|
+
},
|
245
|
+
"foo" => "bar"
|
246
|
+
}
|
247
|
+
params = {
|
248
|
+
"fields" => fields,
|
249
|
+
"_proceed" => "1"
|
250
|
+
}
|
251
|
+
|
252
|
+
put "/_ruote/workitems/#{@wfid}/#{@nada_exp_id}.json", params.to_json, { 'CONTENT_TYPE' => 'application/json' }
|
253
|
+
|
254
|
+
last_response.should be_ok
|
255
|
+
|
256
|
+
#engine.context[:s_logger].wait_for([
|
257
|
+
# [ :processes, :terminated, { :wfid => @wfid } ],
|
258
|
+
# [ :errors, nil, { :wfid => @wfid } ]
|
259
|
+
#])
|
260
|
+
sleep 0.5
|
261
|
+
|
262
|
+
@tracer.to_s.should == "bar"
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
describe "Filtering workitems" do
|
267
|
+
describe "on participants" do
|
268
|
+
before(:each) do
|
269
|
+
@wfid = launch_test_process do
|
270
|
+
Ruote.process_definition :name => 'test' do
|
271
|
+
concurrence do
|
272
|
+
jack :activity => 'Fetch a pale'
|
273
|
+
jill :activity => 'Chase Jack'
|
274
|
+
well :activity => 'Ready water'
|
275
|
+
end
|
276
|
+
end
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
it "should narrow results down to a single participant (JSON)" do
|
281
|
+
get '/_ruote/workitems.json', :participant => 'jack'
|
282
|
+
|
283
|
+
last_response.should be_ok
|
284
|
+
|
285
|
+
last_response.json_body['workitems'].size.should be(1)
|
286
|
+
end
|
287
|
+
|
288
|
+
it "should narrow results down to a single participant (HTML)" do
|
289
|
+
get '/_ruote/workitems', :participant => 'jack'
|
290
|
+
|
291
|
+
last_response.should be_ok
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should narrow results down to multiple participants (JSON)" do
|
295
|
+
get "/_ruote/workitems.json", :participant => 'jack,jill'
|
296
|
+
|
297
|
+
last_response.should be_ok
|
298
|
+
|
299
|
+
last_response.json_body['workitems'].size.should be(2)
|
300
|
+
end
|
301
|
+
|
302
|
+
it "should narrow results down to multiple participants (HTML)" do
|
303
|
+
get "/_ruote/workitems", :participant => 'jack,jill'
|
304
|
+
|
305
|
+
last_response.should be_ok
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
data/spec/spec.opts
ADDED