ruote-kit 2.2.0.3 → 2.3.0.2
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/CHANGELOG.txt +28 -1
- data/CREDITS.txt +8 -2
- data/LICENSE.txt +1 -1
- data/Rakefile +21 -9
- data/lib/ruote-kit.rb +13 -4
- data/lib/ruote-kit/core_ext.rb +15 -0
- data/lib/ruote-kit/helpers/json_helpers.rb +22 -7
- data/lib/ruote-kit/helpers/link_helpers.rb +9 -7
- data/lib/ruote-kit/helpers/pagination_helpers.rb +1 -2
- data/lib/ruote-kit/helpers/render_helpers.rb +1 -1
- data/lib/ruote-kit/public/_ruote/images/favicon.png +0 -0
- data/lib/ruote-kit/public/_ruote/images/{ruote_buttons.png → ruote-buttons.png} +0 -0
- data/lib/ruote-kit/public/_ruote/images/ruote.png +0 -0
- data/lib/ruote-kit/public/_ruote/javascripts/foolbox-all.min.js +3 -0
- data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.9.1.min.js +5 -0
- data/lib/ruote-kit/public/_ruote/javascripts/rk.js +68 -17
- data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-all.min.js +3 -0
- data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +82 -12
- data/lib/ruote-kit/public/_ruote/stylesheets/ruote-buttons.png +0 -0
- data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +9 -6
- data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo.css +62 -0
- data/lib/ruote-kit/resources/errors.rb +8 -3
- data/lib/ruote-kit/resources/expressions.rb +38 -35
- data/lib/ruote-kit/resources/participants.rb +1 -1
- data/lib/ruote-kit/resources/processes.rb +61 -4
- data/lib/ruote-kit/resources/workitems.rb +4 -4
- data/lib/ruote-kit/version.rb +1 -1
- data/lib/ruote-kit/views/_pagination.html.haml +2 -2
- data/lib/ruote-kit/views/_tree_editor.html.haml +63 -30
- data/lib/ruote-kit/views/error.html.haml +50 -9
- data/lib/ruote-kit/views/errors.html.haml +1 -1
- data/lib/ruote-kit/views/expression.html.haml +83 -33
- data/lib/ruote-kit/views/expressions.html.haml +23 -8
- data/lib/ruote-kit/views/http_error.html.haml +9 -2
- data/lib/ruote-kit/views/layout.html.haml +14 -13
- data/lib/ruote-kit/views/process.html.haml +75 -20
- data/lib/ruote-kit/views/processes.html.haml +9 -3
- data/lib/ruote-kit/views/processes_new.html.haml +19 -2
- data/lib/ruote-kit/views/schedules.html.haml +2 -2
- data/lib/ruote-kit/views/workitem.html.haml +17 -6
- data/ruote-kit.gemspec +9 -7
- data/spec/cases/orphan_workitem_spec.rb +141 -0
- data/spec/core_ext_spec.rb +19 -0
- data/spec/resources/errors_spec.rb +182 -156
- data/spec/resources/expressions_spec.rb +497 -379
- data/spec/resources/index_spec.rb +5 -5
- data/spec/resources/participants_spec.rb +64 -75
- data/spec/resources/processes_spec.rb +396 -277
- data/spec/resources/schedules_spec.rb +92 -76
- data/spec/resources/workitems_spec.rb +352 -343
- data/spec/ruote-kit_configure_spec.rb +41 -13
- data/spec/spec_helper.rb +6 -8
- data/spec/support/link_helper.rb +11 -0
- data/spec/webapp_helpers_spec.rb +29 -23
- metadata +161 -180
- data/README.rdoc +0 -313
- data/lib/ruote-kit/public/_ruote/images/favicon.ico +0 -0
- data/lib/ruote-kit/public/_ruote/javascripts/jquery-1.4.2.min.js +0 -154
- data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-editor.js +0 -548
- data/lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js +0 -1118
@@ -1,10 +1,10 @@
|
|
1
1
|
|
2
|
-
require
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
|
5
5
|
describe 'GET /' do
|
6
6
|
|
7
|
-
it '
|
7
|
+
it 'returns a welcome message in HTML be default' do
|
8
8
|
|
9
9
|
get '/_ruote'
|
10
10
|
|
@@ -15,7 +15,7 @@ describe 'GET /' do
|
|
15
15
|
last_response.should match(/<title>/)
|
16
16
|
end
|
17
17
|
|
18
|
-
it '
|
18
|
+
it 'returns a version string if JSON is requested' do
|
19
19
|
|
20
20
|
header 'Accept', 'application/json'
|
21
21
|
|
@@ -32,7 +32,7 @@ end
|
|
32
32
|
|
33
33
|
describe 'Generic error handling' do
|
34
34
|
|
35
|
-
it '
|
35
|
+
it 'gives our own 404 page (HTML)' do
|
36
36
|
|
37
37
|
get '/kenneth'
|
38
38
|
|
@@ -43,7 +43,7 @@ describe 'Generic error handling' do
|
|
43
43
|
last_response.should match(/resource not found/)
|
44
44
|
end
|
45
45
|
|
46
|
-
it '
|
46
|
+
it 'gives our own 404 data (JSON)' do
|
47
47
|
|
48
48
|
get '/kenneth.json'
|
49
49
|
|
@@ -1,119 +1,108 @@
|
|
1
1
|
|
2
|
-
require
|
2
|
+
require 'spec_helper'
|
3
3
|
|
4
4
|
|
5
|
-
describe '
|
5
|
+
describe '/_ruote/participants' do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
-
|
9
8
|
prepare_engine
|
10
9
|
end
|
11
|
-
|
12
10
|
after(:each) do
|
13
|
-
|
14
11
|
shutdown_and_purge_engine
|
15
12
|
end
|
16
13
|
|
17
|
-
describe '
|
14
|
+
describe 'GET /_ruote/participants' do
|
18
15
|
|
19
|
-
|
16
|
+
context 'without any participant' do
|
20
17
|
|
21
|
-
|
18
|
+
it 'gives an empty list (HTML)' do
|
22
19
|
|
23
|
-
|
24
|
-
end
|
20
|
+
get '/_ruote/participants'
|
25
21
|
|
26
|
-
|
22
|
+
last_response.status.should be(200)
|
23
|
+
end
|
27
24
|
|
28
|
-
|
25
|
+
it 'gives an empty array (JSON)' do
|
29
26
|
|
30
|
-
|
27
|
+
get '/_ruote/participants.json'
|
31
28
|
|
32
|
-
|
33
|
-
body.should have_key('participants')
|
29
|
+
last_response.status.should be(200)
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
31
|
+
body = last_response.json_body
|
32
|
+
body.should have_key('participants')
|
38
33
|
|
39
|
-
|
34
|
+
body['participants'].should be_empty
|
35
|
+
end
|
36
|
+
end
|
40
37
|
|
41
|
-
|
38
|
+
context 'with participant' do
|
42
39
|
|
43
|
-
|
44
|
-
|
40
|
+
before(:each) do
|
41
|
+
register_participants
|
42
|
+
end
|
45
43
|
|
46
|
-
|
44
|
+
it 'gives participant information back (HTML)' do
|
47
45
|
|
48
|
-
|
46
|
+
get '/_ruote/participants'
|
49
47
|
|
50
|
-
|
51
|
-
|
48
|
+
last_response.status.should be(200)
|
49
|
+
end
|
52
50
|
|
53
|
-
|
51
|
+
it 'gives participant information back (JSON)' do
|
54
52
|
|
55
|
-
|
53
|
+
get '/_ruote/participants.json'
|
56
54
|
|
57
|
-
|
58
|
-
|
55
|
+
last_response.status.should be(200)
|
56
|
+
last_response.json_body['participants'].should_not be_empty
|
57
|
+
end
|
59
58
|
end
|
60
59
|
end
|
61
|
-
end
|
62
60
|
|
63
|
-
describe 'PUT /_ruote/participants' do
|
61
|
+
describe 'PUT /_ruote/participants' do
|
64
62
|
|
65
|
-
|
63
|
+
it 'updates the list (HTML)' do
|
66
64
|
|
67
|
-
|
68
|
-
|
65
|
+
put(
|
66
|
+
'/_ruote/participants',
|
67
|
+
'regex_0' => '^alice$',
|
68
|
+
'classname_0' => 'Ruote::StorageParticipant',
|
69
|
+
'options_0' => '{}',
|
70
|
+
'regex_1' => '^bravo$',
|
71
|
+
'classname_1' => 'Ruote::StorageParticipant',
|
72
|
+
'options_1' => '{}')
|
69
73
|
|
70
|
-
|
74
|
+
last_response.should be_redirect
|
75
|
+
last_response['Location'].should == 'http://example.org/_ruote/participants'
|
71
76
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
77
|
+
RuoteKit.engine.participant_list.collect { |pe| pe.regex }.should == [
|
78
|
+
'^alice$', '^bravo$'
|
79
|
+
]
|
80
|
+
end
|
76
81
|
|
77
|
-
|
78
|
-
'/_ruote/participants',
|
79
|
-
'regex_0' => '^alice$',
|
80
|
-
'classname_0' => 'Ruote::StorageParticipant',
|
81
|
-
'options_0' => '{}',
|
82
|
-
'regex_1' => '^bravo$',
|
83
|
-
'classname_1' => 'Ruote::StorageParticipant',
|
84
|
-
'options_1' => '{}')
|
82
|
+
it 'updates the list (JSON)' do
|
85
83
|
|
86
|
-
|
87
|
-
|
84
|
+
list = {
|
85
|
+
'participants' => [
|
86
|
+
{ 'regex' => '^alice$',
|
87
|
+
'classname' => 'Ruote::StorageParticipant',
|
88
|
+
'options' => {} },
|
89
|
+
{ 'regex' => '^bravo$',
|
90
|
+
'classname' => 'Ruote::StorageParticipant',
|
91
|
+
'options' => {} }
|
92
|
+
]
|
93
|
+
}
|
88
94
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
95
|
+
put(
|
96
|
+
'/_ruote/participants.json',
|
97
|
+
Rufus::Json.encode(list),
|
98
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
93
99
|
|
94
|
-
|
100
|
+
last_response.status.should be(200)
|
95
101
|
|
96
|
-
|
97
|
-
|
98
|
-
{ 'regex' => '^alice$',
|
99
|
-
'classname' => 'Ruote::StorageParticipant',
|
100
|
-
'options' => {} },
|
101
|
-
{ 'regex' => '^bravo$',
|
102
|
-
'classname' => 'Ruote::StorageParticipant',
|
103
|
-
'options' => {} }
|
102
|
+
RuoteKit.engine.participant_list.collect { |pe| pe.regex }.should == [
|
103
|
+
'^alice$', '^bravo$'
|
104
104
|
]
|
105
|
-
|
106
|
-
|
107
|
-
put(
|
108
|
-
'/_ruote/participants.json',
|
109
|
-
Rufus::Json.encode(list),
|
110
|
-
{ 'CONTENT_TYPE' => 'application/json' })
|
111
|
-
|
112
|
-
last_response.status.should be(200)
|
113
|
-
|
114
|
-
RuoteKit.engine.participant_list.collect { |pe| pe.regex }.should == [
|
115
|
-
'^alice$', '^bravo$'
|
116
|
-
]
|
105
|
+
end
|
117
106
|
end
|
118
107
|
end
|
119
108
|
|
@@ -1,436 +1,555 @@
|
|
1
1
|
|
2
|
-
require
|
3
|
-
|
4
|
-
|
5
|
-
def process_links(wfid)
|
6
|
-
[
|
7
|
-
{ 'href' => "/_ruote/processes/#{wfid}",
|
8
|
-
'rel' => 'self' },
|
9
|
-
{ 'href' => "/_ruote/processes/#{wfid}",
|
10
|
-
'rel' => 'http://ruote.rubyforge.org/rels.html#process' },
|
11
|
-
{ 'href' => "/_ruote/expressions/#{wfid}",
|
12
|
-
'rel' => 'http://ruote.rubyforge.org/rels.html#process_expressions' },
|
13
|
-
{ 'href' => "/_ruote/workitems/#{wfid}",
|
14
|
-
'rel' => 'http://ruote.rubyforge.org/rels.html#process_workitems' },
|
15
|
-
{ 'href' => "/_ruote/errors/#{wfid}",
|
16
|
-
'rel' => 'http://ruote.rubyforge.org/rels.html#process_errors' },
|
17
|
-
{ 'href' => "/_ruote/schedules/#{wfid}",
|
18
|
-
'rel' => 'http://ruote.rubyforge.org/rels.html#process_schedules' }
|
19
|
-
]
|
20
|
-
end
|
2
|
+
require 'spec_helper'
|
21
3
|
|
22
4
|
|
23
|
-
describe '
|
5
|
+
describe '/_ruote/processes' do
|
24
6
|
|
25
7
|
before(:each) do
|
26
|
-
|
27
8
|
prepare_engine_with_participants
|
28
9
|
end
|
29
|
-
|
30
10
|
after(:each) do
|
31
|
-
|
32
11
|
shutdown_and_purge_engine
|
33
12
|
end
|
34
13
|
|
35
|
-
|
14
|
+
def process_links(wfid)
|
15
|
+
[
|
16
|
+
{ 'href' => "/_ruote/processes/#{wfid}",
|
17
|
+
'rel' => 'self' },
|
18
|
+
{ 'href' => "/_ruote/processes/#{wfid}",
|
19
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process' },
|
20
|
+
{ 'href' => "/_ruote/expressions/#{wfid}",
|
21
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process_expressions' },
|
22
|
+
{ 'href' => "/_ruote/workitems/#{wfid}",
|
23
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process_workitems' },
|
24
|
+
{ 'href' => "/_ruote/errors/#{wfid}",
|
25
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process_errors' },
|
26
|
+
{ 'href' => "/_ruote/schedules/#{wfid}",
|
27
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#process_schedules' }
|
28
|
+
]
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'GET /_ruote/processes' do
|
36
32
|
|
37
|
-
|
33
|
+
context 'without any running processes' do
|
38
34
|
|
39
|
-
|
35
|
+
it 'gives no processes back (HTML)' do
|
40
36
|
|
41
|
-
|
37
|
+
get '/_ruote/processes?limit=100&skip=0'
|
38
|
+
|
39
|
+
last_response.status.should == 200
|
40
|
+
|
41
|
+
last_response.should have_selector(
|
42
|
+
'a', :content => 'as JSON')
|
43
|
+
last_response.should have_selector(
|
44
|
+
'a', :href => '/_ruote/processes.json?limit=100&skip=0')
|
45
|
+
end
|
42
46
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
it 'gives an empty array (JSON)' do
|
48
|
+
|
49
|
+
get '/_ruote/processes.json'
|
50
|
+
|
51
|
+
last_response.status.should == 200
|
52
|
+
|
53
|
+
body = last_response.json_body
|
54
|
+
body.should have_key('processes')
|
55
|
+
|
56
|
+
body['processes'].should be_empty
|
57
|
+
end
|
47
58
|
end
|
48
59
|
|
49
|
-
|
60
|
+
context 'with running processes' do
|
50
61
|
|
51
|
-
|
62
|
+
before(:each) do
|
63
|
+
@wfid = launch_nada_process
|
64
|
+
end
|
52
65
|
|
53
|
-
|
66
|
+
it 'gives process information back (HTML)' do
|
54
67
|
|
55
|
-
|
56
|
-
|
68
|
+
get '/_ruote/processes'
|
69
|
+
|
70
|
+
last_response.status.should == 200
|
71
|
+
end
|
57
72
|
|
58
|
-
|
73
|
+
it 'gives process information back (JSON)' do
|
74
|
+
|
75
|
+
get '/_ruote/processes.json'
|
76
|
+
|
77
|
+
last_response.status.should == 200
|
78
|
+
|
79
|
+
body = last_response.json_body
|
80
|
+
|
81
|
+
body['processes'].should_not be_empty
|
82
|
+
|
83
|
+
body['links'].should == [
|
84
|
+
{ 'href' => '/_ruote',
|
85
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#root' },
|
86
|
+
{ 'href' => '/_ruote/processes',
|
87
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#processes' },
|
88
|
+
{ 'href' => '/_ruote/workitems',
|
89
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#workitems' },
|
90
|
+
{ 'href' => '/_ruote/errors',
|
91
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#errors' },
|
92
|
+
{ 'href' => '/_ruote/participants',
|
93
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#participants' },
|
94
|
+
{ 'href' => '/_ruote/schedules',
|
95
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#schedules' },
|
96
|
+
{ 'href' => '/_ruote/history',
|
97
|
+
'rel' => 'http://ruote.rubyforge.org/rels.html#history' },
|
98
|
+
{ 'href' => '/_ruote/processes',
|
99
|
+
'rel' => 'self' },
|
100
|
+
{ 'href' => '/_ruote/processes',
|
101
|
+
'rel' => 'all' },
|
102
|
+
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
103
|
+
'rel' => 'first' },
|
104
|
+
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
105
|
+
'rel' => 'last' },
|
106
|
+
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
107
|
+
'rel' => 'previous' },
|
108
|
+
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
109
|
+
'rel' => 'next' } ]
|
110
|
+
|
111
|
+
body['processes'].first['links'].should == process_links(@wfid)
|
112
|
+
end
|
59
113
|
end
|
60
114
|
end
|
61
115
|
|
62
|
-
describe '
|
116
|
+
describe 'GET /_ruote/processes/:wfid' do
|
63
117
|
|
64
|
-
|
65
|
-
@wfid = launch_nada_process
|
66
|
-
end
|
118
|
+
context 'with a running process' do
|
67
119
|
|
68
|
-
|
120
|
+
before(:each) do
|
121
|
+
@wfid = launch_nada_process
|
122
|
+
end
|
69
123
|
|
70
|
-
|
124
|
+
it 'gives process information back (HTML)' do
|
71
125
|
|
72
|
-
|
73
|
-
end
|
126
|
+
get "/_ruote/processes/#{@wfid}"
|
74
127
|
|
75
|
-
|
128
|
+
last_response.status.should == 200
|
76
129
|
|
77
|
-
|
130
|
+
last_response.should have_selector(
|
131
|
+
'a[rel="http://ruote.rubyforge.org/rels.html#process_schedules"]')
|
78
132
|
|
79
|
-
|
133
|
+
last_response.should have_selector(
|
134
|
+
'td')
|
135
|
+
last_response.should have_selector(
|
136
|
+
'input[name="_method"][type="hidden"][value="DELETE"]')
|
137
|
+
last_response.should have_selector(
|
138
|
+
'input[name="_method"][type="hidden"][value="PUT"]')
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'gives process information back (JSON)' do
|
80
142
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
{ 'href' => '/_ruote/history',
|
99
|
-
'rel' => 'http://ruote.rubyforge.org/rels.html#history' },
|
100
|
-
{ 'href' => '/_ruote/processes',
|
101
|
-
'rel' => 'self' },
|
102
|
-
{ 'href' => '/_ruote/processes',
|
103
|
-
'rel' => 'all' },
|
104
|
-
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
105
|
-
'rel' => 'first' },
|
106
|
-
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
107
|
-
'rel' => 'last' },
|
108
|
-
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
109
|
-
'rel' => 'previous' },
|
110
|
-
{ 'href' => '/_ruote/processes?limit=100&skip=0',
|
111
|
-
'rel' => 'next' } ]
|
112
|
-
|
113
|
-
body['processes'].first['links'].should == process_links(@wfid)
|
143
|
+
get "/_ruote/processes/#{@wfid}.json"
|
144
|
+
|
145
|
+
last_response.status.should == 200
|
146
|
+
|
147
|
+
body = last_response.json_body
|
148
|
+
|
149
|
+
body.should have_key('process')
|
150
|
+
|
151
|
+
body['process']['links'].should == process_links(@wfid)
|
152
|
+
|
153
|
+
body['process'].keys.sort.should == %w[
|
154
|
+
current_tree definition_name definition_revision detailed errors
|
155
|
+
expressions last_active launched_time links original_tree
|
156
|
+
root_expression_state stored_workitems tags type variables wfid
|
157
|
+
workitems
|
158
|
+
]
|
159
|
+
end
|
114
160
|
end
|
115
|
-
end
|
116
|
-
end
|
117
161
|
|
118
|
-
|
162
|
+
context 'without a running process' do
|
119
163
|
|
120
|
-
|
164
|
+
it 'goes 404 correctly (HTML)' do
|
121
165
|
|
122
|
-
|
123
|
-
end
|
166
|
+
get '/_ruote/processes/foo'
|
124
167
|
|
125
|
-
|
168
|
+
last_response.status.should == 404
|
126
169
|
|
127
|
-
|
128
|
-
|
170
|
+
last_response.should match(/resource not found/)
|
171
|
+
end
|
129
172
|
|
130
|
-
|
173
|
+
it 'goes 404 correctly (JSON)' do
|
131
174
|
|
132
|
-
|
175
|
+
get '/_ruote/processes/foo.json'
|
176
|
+
|
177
|
+
last_response.status.should == 404
|
178
|
+
|
179
|
+
last_response.json_body.keys.should include('http_error')
|
133
180
|
|
134
|
-
|
181
|
+
last_response.json_body['http_error'].should == {
|
182
|
+
'code' => 404, 'message' => 'resource not found', 'cause' => ''
|
183
|
+
}
|
184
|
+
end
|
135
185
|
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe 'GET /_ruote/processes/new' do
|
136
189
|
|
137
|
-
it '
|
190
|
+
it 'returns a launch form' do
|
138
191
|
|
139
|
-
get
|
192
|
+
get '/_ruote/processes/new'
|
140
193
|
|
141
194
|
last_response.status.should == 200
|
142
195
|
|
143
|
-
last_response.
|
144
|
-
'a[rel="http://ruote.rubyforge.org/rels.html#process_schedules"]')
|
196
|
+
last_response.should_not have_selector('a', :content => 'as JSON')
|
145
197
|
end
|
198
|
+
end
|
146
199
|
|
147
|
-
|
200
|
+
describe 'PUT /_ruote/processes/:wfid' do
|
148
201
|
|
149
|
-
|
202
|
+
context 'without a valid process' do
|
150
203
|
|
151
|
-
|
204
|
+
it 'goes 404 (HTML)' do
|
152
205
|
|
153
|
-
|
206
|
+
put('/_ruote/processes/123-nada', :state => 'paused')
|
154
207
|
|
155
|
-
|
208
|
+
last_response.status.should == 404
|
209
|
+
end
|
210
|
+
|
211
|
+
it 'goes 404 (JSON)' do
|
156
212
|
|
157
|
-
|
213
|
+
put(
|
214
|
+
'/_ruote/processes/456-nada.json',
|
215
|
+
Rufus::Json.encode({ 'state' => 'paused' }),
|
216
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
217
|
+
|
218
|
+
last_response.status.should == 404
|
219
|
+
end
|
158
220
|
end
|
159
|
-
end
|
160
221
|
|
161
|
-
|
222
|
+
context 'with a valid process' do
|
162
223
|
|
163
|
-
|
224
|
+
before(:each) do
|
225
|
+
@wfid = launch_nada_process
|
226
|
+
end
|
164
227
|
|
165
|
-
|
228
|
+
it 'pauses the process (HTML)' do
|
166
229
|
|
167
|
-
|
230
|
+
put(
|
231
|
+
"/_ruote/processes/#{@wfid}",
|
232
|
+
:state => 'paused')
|
168
233
|
|
169
|
-
|
170
|
-
|
234
|
+
last_response.status.should == 200
|
235
|
+
last_response.content_type.should match(/^text\/html\b/)
|
171
236
|
|
172
|
-
|
237
|
+
sleep 0.500
|
173
238
|
|
174
|
-
|
239
|
+
RuoteKit.engine.ps(@wfid).root_expression.state.should == 'paused'
|
240
|
+
end
|
175
241
|
|
176
|
-
|
242
|
+
it 'resumes the process if paused (HTML)' do
|
177
243
|
|
178
|
-
|
244
|
+
RuoteKit.engine.pause(@wfid)
|
179
245
|
|
180
|
-
|
181
|
-
'code' => 404, 'message' => 'resource not found', 'cause' => ''
|
182
|
-
}
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
246
|
+
sleep 0.500
|
186
247
|
|
187
|
-
|
248
|
+
RuoteKit.engine.ps(@wfid).root_expression.state.should == 'paused'
|
188
249
|
|
189
|
-
|
250
|
+
put(
|
251
|
+
"/_ruote/processes/#{@wfid}",
|
252
|
+
:state => 'resuming')
|
190
253
|
|
191
|
-
|
192
|
-
|
254
|
+
last_response.status.should == 200
|
255
|
+
last_response.content_type.should match(/^text\/html\b/)
|
193
256
|
|
194
|
-
|
257
|
+
sleep 0.500
|
195
258
|
|
196
|
-
|
197
|
-
|
259
|
+
RuoteKit.engine.ps(@wfid).root_expression.state.should == nil
|
260
|
+
end
|
198
261
|
|
199
|
-
|
262
|
+
it 'pauses the process (JSON)' do
|
200
263
|
|
201
|
-
|
264
|
+
put(
|
265
|
+
"/_ruote/processes/#{@wfid}.json",
|
266
|
+
Rufus::Json.encode({ 'state' => 'paused' }),
|
267
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
202
268
|
|
203
|
-
|
269
|
+
last_response.status.should == 200
|
270
|
+
last_response.json_body['process'].should_not == nil
|
204
271
|
|
205
|
-
|
206
|
-
end
|
207
|
-
end
|
272
|
+
sleep 0.500
|
208
273
|
|
209
|
-
|
274
|
+
RuoteKit.engine.ps(@wfid).root_expression.state.should == 'paused'
|
275
|
+
end
|
210
276
|
|
211
|
-
|
277
|
+
it 'resumes the process if paused (JSON)' do
|
212
278
|
|
213
|
-
|
214
|
-
end
|
279
|
+
RuoteKit.engine.pause(@wfid)
|
215
280
|
|
216
|
-
|
281
|
+
sleep 0.500
|
217
282
|
|
218
|
-
|
283
|
+
RuoteKit.engine.ps(@wfid).root_expression.state.should == 'paused'
|
284
|
+
|
285
|
+
put(
|
286
|
+
"/_ruote/processes/#{@wfid}.json",
|
287
|
+
Rufus::Json.encode({ 'state' => 'resuming' }),
|
288
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
289
|
+
|
290
|
+
last_response.status.should == 200
|
291
|
+
last_response.json_body['process'].should_not == nil
|
292
|
+
|
293
|
+
sleep 0.500
|
294
|
+
|
295
|
+
RuoteKit.engine.ps(@wfid).root_expression.state.should == nil
|
296
|
+
end
|
297
|
+
end
|
219
298
|
end
|
220
299
|
|
221
|
-
|
300
|
+
describe 'POST /_ruote/processes' do
|
222
301
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
302
|
+
it 'launches a valid process definition (JSON)' do
|
303
|
+
|
304
|
+
params = {
|
305
|
+
:definition => %q{
|
306
|
+
Ruote.process_definition :name => 'test' do
|
307
|
+
wait '1m'
|
308
|
+
end
|
309
|
+
}
|
228
310
|
}
|
229
|
-
}
|
230
311
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
312
|
+
post(
|
313
|
+
'/_ruote/processes.json',
|
314
|
+
Rufus::Json.encode(params),
|
315
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
235
316
|
|
236
|
-
|
317
|
+
last_response.status.should == 201
|
237
318
|
|
238
|
-
|
319
|
+
last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
|
239
320
|
|
240
|
-
|
321
|
+
sleep 0.4
|
241
322
|
|
242
|
-
|
243
|
-
|
323
|
+
engine.processes.should_not be_empty
|
324
|
+
end
|
244
325
|
|
245
|
-
|
326
|
+
it 'launches a process definition (radial) (JSON)' do
|
246
327
|
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
}
|
253
|
-
:fields => { :foo => 'bar' }
|
254
|
-
}
|
328
|
+
params = {
|
329
|
+
:definition => %q{
|
330
|
+
define 'my process'
|
331
|
+
wait '1m'
|
332
|
+
}
|
333
|
+
}
|
255
334
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
335
|
+
post(
|
336
|
+
'/_ruote/processes.json',
|
337
|
+
Rufus::Json.encode(params),
|
338
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
260
339
|
|
261
|
-
|
262
|
-
last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
|
340
|
+
last_response.status.should == 201
|
263
341
|
|
264
|
-
|
342
|
+
last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
|
265
343
|
|
266
|
-
|
267
|
-
end
|
344
|
+
sleep 0.4
|
268
345
|
|
269
|
-
|
346
|
+
engine.processes.should_not be_empty
|
270
347
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
348
|
+
engine.processes.first.expressions.last.should be_a(
|
349
|
+
Ruote::Exp::WaitExpression)
|
350
|
+
end
|
351
|
+
|
352
|
+
it 'launches a valid process definition with fields (JSON)' do
|
353
|
+
|
354
|
+
params = {
|
355
|
+
:definition => %q{
|
356
|
+
Ruote.process_definition :name => 'test' do
|
357
|
+
echo '${f:foo}'
|
358
|
+
end
|
359
|
+
},
|
360
|
+
:fields => { :foo => 'bar' }
|
276
361
|
}
|
277
|
-
}
|
278
362
|
|
279
|
-
|
363
|
+
post(
|
364
|
+
'/_ruote/processes.json',
|
365
|
+
Rufus::Json.encode(params),
|
366
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
280
367
|
|
281
|
-
|
368
|
+
last_response.status.should == 201
|
369
|
+
last_response.json_body['launched'].should match(/[0-9a-z\-]+/)
|
282
370
|
|
283
|
-
|
371
|
+
sleep 0.5
|
284
372
|
|
285
|
-
|
286
|
-
|
373
|
+
@tracer.to_s.should == 'bar'
|
374
|
+
end
|
287
375
|
|
288
|
-
|
376
|
+
it 'launches a valid process definition (HTML)' do
|
289
377
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
}
|
378
|
+
params = {
|
379
|
+
:definition => %q{
|
380
|
+
Ruote.process_definition :name => 'test' do
|
381
|
+
wait '1m'
|
382
|
+
end
|
383
|
+
}
|
384
|
+
}
|
298
385
|
|
299
|
-
|
386
|
+
post '/_ruote/processes', params
|
300
387
|
|
301
|
-
|
388
|
+
last_response.status.should == 201
|
302
389
|
|
303
|
-
|
390
|
+
sleep 0.4
|
304
391
|
|
305
|
-
|
306
|
-
end
|
392
|
+
engine.processes.should_not be_empty
|
307
393
|
|
308
|
-
|
394
|
+
engine.processes.first.expressions.last.should be_a(
|
395
|
+
Ruote::Exp::WaitExpression)
|
396
|
+
end
|
309
397
|
|
310
|
-
|
311
|
-
:definition => %q{
|
312
|
-
Ruote.process_definition :name => 'test' do
|
313
|
-
wait '5m'
|
314
|
-
end
|
315
|
-
},
|
316
|
-
:fields => ''
|
317
|
-
}
|
398
|
+
it 'launches a process definition (radial and CRLF) (HTML)' do
|
318
399
|
|
319
|
-
|
400
|
+
params = {
|
401
|
+
:definition => "define 'my process'\r\n wait '1m'\r\n"
|
402
|
+
}
|
320
403
|
|
321
|
-
|
404
|
+
post '/_ruote/processes', params
|
322
405
|
|
323
|
-
|
406
|
+
last_response.status.should == 201
|
324
407
|
|
325
|
-
|
326
|
-
end
|
408
|
+
sleep 0.4
|
327
409
|
|
328
|
-
|
410
|
+
engine.processes.should_not be_empty
|
329
411
|
|
330
|
-
|
412
|
+
engine.processes.first.expressions.last.should be_a(
|
413
|
+
Ruote::Exp::WaitExpression)
|
414
|
+
end
|
331
415
|
|
332
|
-
|
333
|
-
'/_ruote/processes.json',
|
334
|
-
Rufus::Json.encode(params),
|
335
|
-
{ 'CONTENT_TYPE' => 'application/json' })
|
416
|
+
it 'launches a process definition with fields (HTML)' do
|
336
417
|
|
337
|
-
|
338
|
-
|
339
|
-
|
418
|
+
params = {
|
419
|
+
:definition => %{
|
420
|
+
Ruote.process_definition :name => 'test' do
|
421
|
+
echo '${f:foo}'
|
422
|
+
end
|
423
|
+
},
|
424
|
+
:fields => '{ "foo": "bar" }'
|
425
|
+
}
|
340
426
|
|
341
|
-
|
427
|
+
post '/_ruote/processes', params
|
342
428
|
|
343
|
-
|
429
|
+
last_response.status.should == 201
|
344
430
|
|
345
|
-
|
431
|
+
sleep 0.5
|
346
432
|
|
347
|
-
|
348
|
-
|
349
|
-
end
|
433
|
+
@tracer.to_s.should == 'bar'
|
434
|
+
end
|
350
435
|
|
351
|
-
|
436
|
+
it 'corrects empty fields sent by browsers' do
|
352
437
|
|
353
|
-
|
438
|
+
params = {
|
439
|
+
:definition => %q{
|
440
|
+
Ruote.process_definition :name => 'test' do
|
441
|
+
wait '5m'
|
442
|
+
end
|
443
|
+
},
|
444
|
+
:fields => ''
|
445
|
+
}
|
354
446
|
|
355
|
-
|
447
|
+
post '/_ruote/processes', params
|
356
448
|
|
357
|
-
|
358
|
-
end
|
449
|
+
last_response.status.should == 201
|
359
450
|
|
360
|
-
|
451
|
+
sleep 0.4
|
361
452
|
|
362
|
-
|
363
|
-
|
453
|
+
engine.processes.should_not be_empty
|
454
|
+
end
|
364
455
|
|
365
|
-
|
456
|
+
it 'goes 400 code when it fails to determine what to launch (JSON)' do
|
366
457
|
|
367
|
-
|
368
|
-
sequence :on_cancel => 'bail_out' do
|
369
|
-
echo 'in'
|
370
|
-
wait '1d'
|
371
|
-
echo 'done.'
|
372
|
-
end
|
458
|
+
params = { :definition => 'http://invalid.invalid' }
|
373
459
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
460
|
+
post(
|
461
|
+
'/_ruote/processes.json',
|
462
|
+
Rufus::Json.encode(params),
|
463
|
+
{ 'CONTENT_TYPE' => 'application/json' })
|
464
|
+
|
465
|
+
last_response.status.should == 400
|
466
|
+
last_response.json_body.keys.should include('http_error')
|
467
|
+
end
|
468
|
+
|
469
|
+
it 'goes 400 when it fails to determine what to launch (HTML)' do
|
470
|
+
|
471
|
+
params = { :definition => %q{http://invalid.invalid} }
|
472
|
+
|
473
|
+
post '/_ruote/processes', params
|
474
|
+
|
475
|
+
last_response.status.should == 400
|
476
|
+
last_response.should match(/bad request/)
|
477
|
+
end
|
378
478
|
|
379
|
-
RuoteKit.engine.wait_for(3)
|
380
479
|
end
|
381
480
|
|
382
|
-
|
481
|
+
describe 'DELETE /_ruote/processes/:wfid' do
|
383
482
|
|
384
|
-
|
483
|
+
before(:each) do
|
385
484
|
|
386
|
-
|
485
|
+
@wfid = RuoteKit.engine.launch(Ruote.process_definition do
|
486
|
+
sequence :on_cancel => 'bail_out' do
|
487
|
+
echo 'in'
|
488
|
+
wait '1d'
|
489
|
+
echo 'done.'
|
490
|
+
end
|
387
491
|
|
388
|
-
|
492
|
+
define :name => 'bail_out' do
|
493
|
+
echo 'bailout.'
|
494
|
+
end
|
495
|
+
end)
|
389
496
|
|
390
|
-
|
497
|
+
RuoteKit.engine.wait_for(3)
|
498
|
+
end
|
391
499
|
|
392
|
-
|
393
|
-
end
|
500
|
+
it 'cancels processes (JSON)' do
|
394
501
|
|
395
|
-
|
502
|
+
delete "/_ruote/processes/#{@wfid}.json"
|
396
503
|
|
397
|
-
|
504
|
+
last_response.status.should == 200
|
505
|
+
|
506
|
+
wait_for(@wfid)
|
398
507
|
|
399
|
-
|
400
|
-
last_response['Location'].should == '/_ruote/processes'
|
508
|
+
engine.process(@wfid).should be_nil
|
401
509
|
|
402
|
-
|
510
|
+
@tracer.to_s.should == "in\nbailout."
|
511
|
+
end
|
403
512
|
|
404
|
-
|
513
|
+
it 'cancels processes (HMTL)' do
|
405
514
|
|
406
|
-
|
407
|
-
end
|
515
|
+
delete "/_ruote/processes/#{@wfid}"
|
408
516
|
|
409
|
-
|
517
|
+
last_response.should be_redirect
|
518
|
+
last_response['Location'].should == 'http://example.org/_ruote/processes'
|
410
519
|
|
411
|
-
|
520
|
+
wait_for(@wfid)
|
412
521
|
|
413
|
-
|
522
|
+
engine.process(@wfid).should be_nil
|
414
523
|
|
415
|
-
|
524
|
+
@tracer.to_s.should == "in\nbailout."
|
525
|
+
end
|
416
526
|
|
417
|
-
|
527
|
+
it 'kills processes (JSON)' do
|
418
528
|
|
419
|
-
|
420
|
-
end
|
529
|
+
delete "/_ruote/processes/#{@wfid}.json?_kill=1"
|
421
530
|
|
422
|
-
|
531
|
+
last_response.status.should == 200
|
423
532
|
|
424
|
-
|
533
|
+
wait_for(@wfid)
|
425
534
|
|
426
|
-
|
427
|
-
|
535
|
+
engine.process(@wfid).should be_nil
|
536
|
+
|
537
|
+
@tracer.to_s.should == 'in'
|
538
|
+
end
|
428
539
|
|
429
|
-
|
540
|
+
it 'kills processes (HTML)' do
|
430
541
|
|
431
|
-
|
542
|
+
delete "/_ruote/processes/#{@wfid}?_kill=1"
|
432
543
|
|
433
|
-
|
544
|
+
last_response.should be_redirect
|
545
|
+
last_response['Location'].should == 'http://example.org/_ruote/processes'
|
546
|
+
|
547
|
+
wait_for(@wfid)
|
548
|
+
|
549
|
+
engine.process(@wfid).should be_nil
|
550
|
+
|
551
|
+
@tracer.to_s.should == 'in'
|
552
|
+
end
|
434
553
|
end
|
435
554
|
end
|
436
555
|
|