ruote-kit 2.1.8.2 → 2.1.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  class RuoteKit::Application
2
2
 
3
- get "/_ruote/expressions" do
3
+ get "/_ruote/expressions/?" do
4
4
  respond_to do |format|
5
5
  format.html { haml :expressions }
6
6
  format.json { json( :status, :ok ) }
@@ -1,6 +1,6 @@
1
1
  class RuoteKit::Application
2
2
 
3
- get "/_ruote/processes" do
3
+ get "/_ruote/processes/?" do
4
4
  @processes = engine.processes
5
5
 
6
6
  respond_to do |format|
@@ -14,6 +14,7 @@ class RuoteKit::Application
14
14
  end
15
15
 
16
16
  get "/_ruote/processes/:wfid" do
17
+
17
18
  @process = engine.process( params[:wfid] )
18
19
 
19
20
  if @process
@@ -1,14 +1,13 @@
1
1
  class RuoteKit::Application
2
2
 
3
- get "/_ruote/workitems" do
4
- if params[:participant]
5
- @participants = params[:participant].split(',')
6
- @workitems = @participants.inject([]) do |memo, part|
7
- memo.concat storage_participant.by_participant( part )
8
- end
9
- else
10
- @workitems = storage_participant.all
11
- end
3
+ get "/_ruote/workitems/?" do
4
+
5
+ query = params.inject({}) { |h, (k, v)|
6
+ h[k] = (Rufus::Json.decode(v) rescue v)
7
+ h
8
+ }
9
+
10
+ @workitems = storage_participant.query(query)
12
11
 
13
12
  respond_to do |format|
14
13
  format.html { haml :workitems }
@@ -39,7 +39,7 @@ module RuoteKit
39
39
  end
40
40
 
41
41
  def wait_for( wfid )
42
- @_spec_worker.context.logger.wait_for( wfid )
42
+ @_spec_worker.context.logger.wait_for( [ wfid ] )
43
43
  end
44
44
 
45
45
  end
@@ -6,6 +6,6 @@
6
6
 
7
7
  module RuoteKit
8
8
 
9
- VERSION = '2.1.8.2'
9
+ VERSION = '2.1.10'
10
10
  end
11
11
 
@@ -0,0 +1,18 @@
1
+
2
+ - @_uses_fluo = true
3
+
4
+ %h2 Errors
5
+
6
+ %ul
7
+ - @errors.each do |error|
8
+ %li #{error.fei.to_storage_id}
9
+
10
+ %p  
11
+
12
+ %canvas#fluo
13
+
14
+ :javascript
15
+ //var proc_rep = #{process_tree( @process )};
16
+ //Fluo.renderFlow( 'fluo', proc_rep );
17
+ //Fluo.crop('fluo');
18
+
@@ -5,8 +5,8 @@
5
5
  %ul.nolist
6
6
  %li fei: #{@workitem.fei.to_s}
7
7
  %li participant: #{@workitem.participant_name}
8
- %li dispatched:
9
- %li last modified:
8
+ %li dispatched: #{@workitem.dispatch_at}
9
+ %li last modified: #{@workitem.h.put_at}
10
10
  %li process: #{link_to engine.process( @workitem.fei.wfid) }
11
11
  %li expressions:
12
12
  %li workitems of this process: #{link_to "GET /_ruote/workitems/#{@workitem.fei.wfid}", "/_ruote/workitems/#{@workitem.fei.wfid}" }
@@ -19,7 +19,7 @@
19
19
  .group
20
20
  %label.label{ :for => "fields" } Fields
21
21
  %textarea.text_area{ :name => "fields", :cols => 80, :rows => 10 }
22
- = @workitem.fields.to_json
22
+ = Rufus::Json.encode(@workitem.fields)
23
23
  %span.description The current workitem fields in JSON format
24
24
  .group
25
25
  %input{ :type => 'checkbox', :name => '_proceed', :value => '1' }
data/ruote-kit.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruote-kit}
8
- s.version = "2.1.8.2"
8
+ s.version = "2.1.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["kenneth.kalmer@gmail.com"]
12
- s.date = %q{2010-03-15}
11
+ s.authors = ["kenneth.kalmer@gmail.com", "John Mettraux"]
12
+ s.date = %q{2010-07-07}
13
13
  s.description = %q{ruote-kit is a RESTful Rack app for the ruote workflow engine}
14
14
  s.email = %q{kenneth.kalmer@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -43,11 +43,13 @@ Gem::Specification.new do |s|
43
43
  "lib/ruote-kit/public/_ruote/stylesheets/base.css",
44
44
  "lib/ruote-kit/public/_ruote/stylesheets/rk.css",
45
45
  "lib/ruote-kit/public/_ruote/stylesheets/style.css",
46
+ "lib/ruote-kit/resources/errors.rb",
46
47
  "lib/ruote-kit/resources/expressions.rb",
47
48
  "lib/ruote-kit/resources/processes.rb",
48
49
  "lib/ruote-kit/resources/workitems.rb",
49
50
  "lib/ruote-kit/spec/ruote_helpers.rb",
50
51
  "lib/ruote-kit/version.rb",
52
+ "lib/ruote-kit/views/errors.html.haml",
51
53
  "lib/ruote-kit/views/expression.html.haml",
52
54
  "lib/ruote-kit/views/expressions.html.haml",
53
55
  "lib/ruote-kit/views/index.html.haml",
@@ -62,6 +64,7 @@ Gem::Specification.new do |s|
62
64
  "lib/ruote-kit/views/workitems.html.haml",
63
65
  "ruote-kit.gemspec",
64
66
  "spec/helpers/render_helpers_spec.rb",
67
+ "spec/resources/errors_spec.rb",
65
68
  "spec/resources/expressions_spec.rb",
66
69
  "spec/resources/index_spec.rb",
67
70
  "spec/resources/processes_spec.rb",
@@ -80,12 +83,13 @@ Gem::Specification.new do |s|
80
83
  s.homepage = %q{http://github.com/kennethkalmer/ruote-kit}
81
84
  s.rdoc_options = ["--charset=UTF-8"]
82
85
  s.require_paths = ["lib"]
83
- s.rubygems_version = %q{1.3.6}
86
+ s.rubygems_version = %q{1.3.7}
84
87
  s.summary = %q{ruote workflow engine, wrapped in a loving rack embrace}
85
88
  s.test_files = [
86
89
  "spec/resources/expressions_spec.rb",
87
90
  "spec/resources/workitems_spec.rb",
88
91
  "spec/resources/index_spec.rb",
92
+ "spec/resources/errors_spec.rb",
89
93
  "spec/resources/processes_spec.rb",
90
94
  "spec/ruote-kit_configure_spec.rb",
91
95
  "spec/ruote-kit_spec.rb",
@@ -103,37 +107,46 @@ Gem::Specification.new do |s|
103
107
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
104
108
  s.specification_version = 3
105
109
 
106
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
110
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
107
111
  s.add_runtime_dependency(%q<bundler>, [">= 0.9.5"])
108
112
  s.add_runtime_dependency(%q<sinatra>, [">= 0.9.4"])
109
113
  s.add_runtime_dependency(%q<sinatra-respond_to>, [">= 0.4.0"])
110
114
  s.add_runtime_dependency(%q<haml>, [">= 2.2.5"])
111
- s.add_runtime_dependency(%q<json>, [">= 0"])
112
- s.add_runtime_dependency(%q<ruote>, [">= 2.1.8"])
115
+ s.add_runtime_dependency(%q<rufus-json>, [">= 0.2.3"])
116
+ s.add_runtime_dependency(%q<ruote>, [">= 2.1.10"])
113
117
  s.add_development_dependency(%q<rake>, [">= 0"])
114
118
  s.add_development_dependency(%q<rspec>, [">= 0"])
115
119
  s.add_development_dependency(%q<jeweler>, [">= 0"])
120
+ s.add_development_dependency(%q<webrat>, [">= 0"])
121
+ s.add_development_dependency(%q<test-unit>, ["~> 1.2.3"])
122
+ s.add_development_dependency(%q<rack-test>, [">= 0"])
116
123
  else
117
124
  s.add_dependency(%q<bundler>, [">= 0.9.5"])
118
125
  s.add_dependency(%q<sinatra>, [">= 0.9.4"])
119
126
  s.add_dependency(%q<sinatra-respond_to>, [">= 0.4.0"])
120
127
  s.add_dependency(%q<haml>, [">= 2.2.5"])
121
- s.add_dependency(%q<json>, [">= 0"])
122
- s.add_dependency(%q<ruote>, [">= 2.1.8"])
128
+ s.add_dependency(%q<rufus-json>, [">= 0.2.3"])
129
+ s.add_dependency(%q<ruote>, [">= 2.1.10"])
123
130
  s.add_dependency(%q<rake>, [">= 0"])
124
131
  s.add_dependency(%q<rspec>, [">= 0"])
125
132
  s.add_dependency(%q<jeweler>, [">= 0"])
133
+ s.add_dependency(%q<webrat>, [">= 0"])
134
+ s.add_dependency(%q<test-unit>, ["~> 1.2.3"])
135
+ s.add_dependency(%q<rack-test>, [">= 0"])
126
136
  end
127
137
  else
128
138
  s.add_dependency(%q<bundler>, [">= 0.9.5"])
129
139
  s.add_dependency(%q<sinatra>, [">= 0.9.4"])
130
140
  s.add_dependency(%q<sinatra-respond_to>, [">= 0.4.0"])
131
141
  s.add_dependency(%q<haml>, [">= 2.2.5"])
132
- s.add_dependency(%q<json>, [">= 0"])
133
- s.add_dependency(%q<ruote>, [">= 2.1.8"])
142
+ s.add_dependency(%q<rufus-json>, [">= 0.2.3"])
143
+ s.add_dependency(%q<ruote>, [">= 2.1.10"])
134
144
  s.add_dependency(%q<rake>, [">= 0"])
135
145
  s.add_dependency(%q<rspec>, [">= 0"])
136
146
  s.add_dependency(%q<jeweler>, [">= 0"])
147
+ s.add_dependency(%q<webrat>, [">= 0"])
148
+ s.add_dependency(%q<test-unit>, ["~> 1.2.3"])
149
+ s.add_dependency(%q<rack-test>, [">= 0"])
137
150
  end
138
151
  end
139
152
 
@@ -0,0 +1,292 @@
1
+
2
+ require File.dirname(__FILE__) + '/../spec_helper'
3
+
4
+ describe "GET /_ruote/errors", :type => :with_engine do
5
+
6
+ describe "without any running processes" do
7
+
8
+ it "should give no processes back (HTML)" do
9
+
10
+ get "/_ruote/errors"
11
+
12
+ last_response.status.should be(200)
13
+ end
14
+
15
+ it "should give an empty array (JSON)" do
16
+
17
+ get "/_ruote/errors.json"
18
+
19
+ last_response.status.should be(200)
20
+
21
+ body = last_response.json_body
22
+ body.should have_key('errors')
23
+
24
+ body['errors'].should be_empty
25
+ end
26
+ end
27
+
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
52
+ end
53
+
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