ruote-kit 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.document +0 -0
  2. data/.gitignore +8 -0
  3. data/Gemfile +10 -0
  4. data/README.rdoc +132 -0
  5. data/Rakefile +57 -0
  6. data/config.ru +21 -0
  7. data/lib/ruote-kit/application.rb +50 -0
  8. data/lib/ruote-kit/configuration.rb +52 -0
  9. data/lib/ruote-kit/helpers/engine_helpers.rb +24 -0
  10. data/lib/ruote-kit/helpers/form_helpers.rb +11 -0
  11. data/lib/ruote-kit/helpers/launch_item_parser.rb +59 -0
  12. data/lib/ruote-kit/helpers/navigation_helpers.rb +54 -0
  13. data/lib/ruote-kit/helpers/render_helpers.rb +103 -0
  14. data/lib/ruote-kit/helpers.rb +9 -0
  15. data/lib/ruote-kit/public/_ruote/images/bg.gif +0 -0
  16. data/lib/ruote-kit/public/_ruote/images/bg_button_left.gif +0 -0
  17. data/lib/ruote-kit/public/_ruote/images/bg_button_left_cancel.gif +0 -0
  18. data/lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif +0 -0
  19. data/lib/ruote-kit/public/_ruote/images/bg_button_right.gif +0 -0
  20. data/lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js +191 -0
  21. data/lib/ruote-kit/public/_ruote/javascripts/fluo-can.js +1111 -0
  22. data/lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js +149 -0
  23. data/lib/ruote-kit/public/_ruote/javascripts/fluo-json.js +183 -0
  24. data/lib/ruote-kit/public/_ruote/javascripts/fluo-tred.js +515 -0
  25. data/lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css +226 -0
  26. data/lib/ruote-kit/public/_ruote/stylesheets/base.css +336 -0
  27. data/lib/ruote-kit/public/_ruote/stylesheets/rk.css +30 -0
  28. data/lib/ruote-kit/public/_ruote/stylesheets/style.css +393 -0
  29. data/lib/ruote-kit/resources/expressions.rb +55 -0
  30. data/lib/ruote-kit/resources/processes.rb +52 -0
  31. data/lib/ruote-kit/resources/workitems.rb +64 -0
  32. data/lib/ruote-kit/spec/ruote_helpers.rb +47 -0
  33. data/lib/ruote-kit/vendor/sinatra-respond_to/LICENSE +21 -0
  34. data/lib/ruote-kit/vendor/sinatra-respond_to/README.markdown +102 -0
  35. data/lib/ruote-kit/vendor/sinatra-respond_to/Rakefile +30 -0
  36. data/lib/ruote-kit/vendor/sinatra-respond_to/VERSION.yml +4 -0
  37. data/lib/ruote-kit/vendor/sinatra-respond_to/lib/sinatra/respond_to.rb +206 -0
  38. data/lib/ruote-kit/vendor/sinatra-respond_to/sinatra-respond_to.gemspec +56 -0
  39. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static folder/.keep +0 -0
  40. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static.txt +1 -0
  41. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/test_app.rb +53 -0
  42. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/unreachable_static.txt +1 -0
  43. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/layout.html.haml +2 -0
  44. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.html.haml +1 -0
  45. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.js.erb +3 -0
  46. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.xml.builder +3 -0
  47. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/extension_spec.rb +403 -0
  48. data/lib/ruote-kit/vendor/sinatra-respond_to/spec/spec_helper.rb +18 -0
  49. data/lib/ruote-kit/views/expression.html.haml +38 -0
  50. data/lib/ruote-kit/views/expressions.html.haml +30 -0
  51. data/lib/ruote-kit/views/index.html.haml +1 -0
  52. data/lib/ruote-kit/views/launch_process.html.haml +19 -0
  53. data/lib/ruote-kit/views/layout.html.haml +46 -0
  54. data/lib/ruote-kit/views/process.html.haml +55 -0
  55. data/lib/ruote-kit/views/processes.html.haml +27 -0
  56. data/lib/ruote-kit/views/resource_not_found.html.haml +7 -0
  57. data/lib/ruote-kit/views/workitem.html.haml +39 -0
  58. data/lib/ruote-kit/views/workitems.html.haml +23 -0
  59. data/lib/ruote-kit.rb +105 -0
  60. data/ruote-kit.gemspec +136 -0
  61. data/spec/helpers/render_helpers_spec.rb +211 -0
  62. data/spec/resources/expressions_spec.rb +179 -0
  63. data/spec/resources/index_spec.rb +46 -0
  64. data/spec/resources/processes_spec.rb +259 -0
  65. data/spec/resources/workitems_spec.rb +308 -0
  66. data/spec/ruote-kit_spec.rb +4 -0
  67. data/spec/spec.opts +2 -0
  68. data/spec/spec_helper.rb +152 -0
  69. data/spec/views/launch_process.html.haml_spec.rb +21 -0
  70. data/spec/views/process.html.haml_spec.rb +16 -0
  71. data/spec/views/processes.html.haml_spec.rb +30 -0
  72. data/spec/views/workitems.html.haml_spec.rb +68 -0
  73. metadata +185 -0
@@ -0,0 +1,23 @@
1
+ %h2 Workitems
2
+
3
+ .flash
4
+ .message
5
+ - if @workitems.empty?
6
+ .warn
7
+ %p No workitems are currently available #{ @wfid ? "for #{@wfid}" : '' }
8
+ - else
9
+ .notice
10
+ %p #{ pluralize(@workitems.size, 'workitem') } available #{ @wfid ? "for #{@wfid}" : '' }
11
+
12
+ - if @participants
13
+ .notice
14
+ %p Filtered for participant(s): #{@participants.join(', ')}
15
+
16
+ %ul.nested_list
17
+ - @workitems.each do |wi|
18
+ %li
19
+ = link_to wi
20
+ %ul.nested_details
21
+ %li fei: #{wi.fei.to_s}
22
+ %li participant: #{wi.participant_name}
23
+ %li dispath time: TODO
data/lib/ruote-kit.rb ADDED
@@ -0,0 +1,105 @@
1
+ require 'json'
2
+ require 'ruote'
3
+
4
+ module RuoteKit
5
+
6
+ VERSION = "2.1.4"
7
+
8
+ autoload :Configuration, "ruote-kit/configuration"
9
+ autoload :Application, "ruote-kit/application"
10
+ autoload :Helpers, "ruote-kit/helpers"
11
+
12
+ class << self
13
+ # The instance of ruote
14
+ attr_accessor :engine
15
+
16
+ # The instance of our worker, if used
17
+ attr_accessor :worker
18
+
19
+ def env
20
+ @env ||= (
21
+ if defined?( Rails )
22
+ Rails.env
23
+ else
24
+ ENV['RACK_ENV'] || 'development'
25
+ end
26
+ )
27
+ end
28
+
29
+ # Yields a RuoteKit::Configuration instance and then immediately starts
30
+ # the engine (unless configuration prohibits it).
31
+ def configure( &block )
32
+ yield configuration
33
+
34
+ run_engine! if configuration.run_engine
35
+ end
36
+
37
+ # Configure and run the engine in a RESTful container
38
+ def run!(&block)
39
+ yield if block_given?
40
+
41
+ run_engine!
42
+ end
43
+
44
+ def shutdown!( purge_engine = false )
45
+ shutdown_engine( purge_engine )
46
+ end
47
+
48
+ def configuration
49
+
50
+ @configuration ||= Configuration.new
51
+ end
52
+
53
+ def configure_participants
54
+ self.engine.register_participant('.*', configuration.catchall_participant)
55
+ end
56
+
57
+ # Ensure the engine is running
58
+ def ensure_engine!
59
+ run_engine! if self.engine.nil?
60
+ end
61
+
62
+ # Runs an engine, and starts a threaded workers if #configuration allows
63
+ # it
64
+ def run_engine!
65
+
66
+ storage = configuration.storage_instance
67
+ self.engine = Ruote::Engine.new( storage )
68
+
69
+ configure_participants
70
+
71
+ run_worker!( true ) unless configuration.run_worker
72
+ end
73
+
74
+ # Run a single worker. By default this method will block indefinitely,
75
+ # unless +run_in_thread+ is set to true
76
+ def run_worker!( run_in_thread = false )
77
+ self.worker = Ruote::Worker.new( configuration.storage_instance )
78
+ run_in_thread ? self.worker.run_in_thread : self.worker.run
79
+ end
80
+
81
+ def shutdown_engine( purge = false )
82
+
83
+ return if self.engine.nil?
84
+
85
+ self.engine.shutdown
86
+
87
+ if purge
88
+ self.engine.context.keys.each do |k|
89
+ s = self.engine.context[k]
90
+ s.purge if s.respond_to?(:purge)
91
+ end
92
+ end
93
+
94
+ self.engine = nil
95
+
96
+ shutdown_worker! if configuration.run_worker
97
+ end
98
+
99
+ def shutdown_worker!
100
+ self.worker.shutdown if self.worker
101
+ self.worker = nil
102
+ end
103
+
104
+ end
105
+ end
data/ruote-kit.gemspec ADDED
@@ -0,0 +1,136 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ruote-kit}
8
+ s.version = "2.1.4"
9
+
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-01-11}
13
+ s.description = %q{ruote-kit is a RESTful Rack app for the ruote workflow engine}
14
+ s.email = %q{kenneth.kalmer@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "Gemfile",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "config.ru",
25
+ "lib/ruote-kit.rb",
26
+ "lib/ruote-kit/application.rb",
27
+ "lib/ruote-kit/configuration.rb",
28
+ "lib/ruote-kit/helpers.rb",
29
+ "lib/ruote-kit/helpers/engine_helpers.rb",
30
+ "lib/ruote-kit/helpers/form_helpers.rb",
31
+ "lib/ruote-kit/helpers/launch_item_parser.rb",
32
+ "lib/ruote-kit/helpers/navigation_helpers.rb",
33
+ "lib/ruote-kit/helpers/render_helpers.rb",
34
+ "lib/ruote-kit/public/_ruote/images/bg.gif",
35
+ "lib/ruote-kit/public/_ruote/images/bg_button_left.gif",
36
+ "lib/ruote-kit/public/_ruote/images/bg_button_left_cancel.gif",
37
+ "lib/ruote-kit/public/_ruote/images/bg_button_left_submit.gif",
38
+ "lib/ruote-kit/public/_ruote/images/bg_button_right.gif",
39
+ "lib/ruote-kit/public/_ruote/javascripts/SimplyButtons.js",
40
+ "lib/ruote-kit/public/_ruote/javascripts/fluo-can.js",
41
+ "lib/ruote-kit/public/_ruote/javascripts/fluo-dial.js",
42
+ "lib/ruote-kit/public/_ruote/javascripts/fluo-json.js",
43
+ "lib/ruote-kit/public/_ruote/javascripts/fluo-tred.js",
44
+ "lib/ruote-kit/public/_ruote/stylesheets/SimplyButtons.css",
45
+ "lib/ruote-kit/public/_ruote/stylesheets/base.css",
46
+ "lib/ruote-kit/public/_ruote/stylesheets/rk.css",
47
+ "lib/ruote-kit/public/_ruote/stylesheets/style.css",
48
+ "lib/ruote-kit/resources/expressions.rb",
49
+ "lib/ruote-kit/resources/processes.rb",
50
+ "lib/ruote-kit/resources/workitems.rb",
51
+ "lib/ruote-kit/spec/ruote_helpers.rb",
52
+ "lib/ruote-kit/vendor/sinatra-respond_to/LICENSE",
53
+ "lib/ruote-kit/vendor/sinatra-respond_to/README.markdown",
54
+ "lib/ruote-kit/vendor/sinatra-respond_to/Rakefile",
55
+ "lib/ruote-kit/vendor/sinatra-respond_to/VERSION.yml",
56
+ "lib/ruote-kit/vendor/sinatra-respond_to/lib/sinatra/respond_to.rb",
57
+ "lib/ruote-kit/vendor/sinatra-respond_to/sinatra-respond_to.gemspec",
58
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static folder/.keep",
59
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/app/public/static.txt",
60
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/app/test_app.rb",
61
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/app/unreachable_static.txt",
62
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/layout.html.haml",
63
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.html.haml",
64
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.js.erb",
65
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/app/views/resource.xml.builder",
66
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/extension_spec.rb",
67
+ "lib/ruote-kit/vendor/sinatra-respond_to/spec/spec_helper.rb",
68
+ "lib/ruote-kit/views/expression.html.haml",
69
+ "lib/ruote-kit/views/expressions.html.haml",
70
+ "lib/ruote-kit/views/index.html.haml",
71
+ "lib/ruote-kit/views/launch_process.html.haml",
72
+ "lib/ruote-kit/views/layout.html.haml",
73
+ "lib/ruote-kit/views/process.html.haml",
74
+ "lib/ruote-kit/views/processes.html.haml",
75
+ "lib/ruote-kit/views/resource_not_found.html.haml",
76
+ "lib/ruote-kit/views/workitem.html.haml",
77
+ "lib/ruote-kit/views/workitems.html.haml",
78
+ "ruote-kit.gemspec",
79
+ "spec/helpers/render_helpers_spec.rb",
80
+ "spec/resources/expressions_spec.rb",
81
+ "spec/resources/index_spec.rb",
82
+ "spec/resources/processes_spec.rb",
83
+ "spec/resources/workitems_spec.rb",
84
+ "spec/ruote-kit_spec.rb",
85
+ "spec/spec.opts",
86
+ "spec/spec_helper.rb",
87
+ "spec/views/launch_process.html.haml_spec.rb",
88
+ "spec/views/process.html.haml_spec.rb",
89
+ "spec/views/processes.html.haml_spec.rb",
90
+ "spec/views/workitems.html.haml_spec.rb"
91
+ ]
92
+ s.homepage = %q{http://github.com/kennethkalmer/ruote-kit}
93
+ s.rdoc_options = ["--charset=UTF-8"]
94
+ s.require_paths = ["lib"]
95
+ s.rubygems_version = %q{1.3.5}
96
+ s.summary = %q{ruote workflow engine, wrapped in a loving rack embrace}
97
+ s.test_files = [
98
+ "spec/helpers/render_helpers_spec.rb",
99
+ "spec/resources/expressions_spec.rb",
100
+ "spec/resources/index_spec.rb",
101
+ "spec/resources/processes_spec.rb",
102
+ "spec/resources/workitems_spec.rb",
103
+ "spec/ruote-kit_spec.rb",
104
+ "spec/spec_helper.rb",
105
+ "spec/views/launch_process.html.haml_spec.rb",
106
+ "spec/views/process.html.haml_spec.rb",
107
+ "spec/views/processes.html.haml_spec.rb",
108
+ "spec/views/workitems.html.haml_spec.rb"
109
+ ]
110
+
111
+ if s.respond_to? :specification_version then
112
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
113
+ s.specification_version = 3
114
+
115
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
116
+ s.add_runtime_dependency(%q<sinatra>, [">= 0.9.4"])
117
+ s.add_runtime_dependency(%q<haml>, [">= 2.2.5"])
118
+ s.add_runtime_dependency(%q<json>, [">= 0"])
119
+ s.add_runtime_dependency(%q<ruote>, ["= 2.1.4"])
120
+ s.add_development_dependency(%q<rspec>, [">= 0"])
121
+ else
122
+ s.add_dependency(%q<sinatra>, [">= 0.9.4"])
123
+ s.add_dependency(%q<haml>, [">= 2.2.5"])
124
+ s.add_dependency(%q<json>, [">= 0"])
125
+ s.add_dependency(%q<ruote>, ["= 2.1.4"])
126
+ s.add_dependency(%q<rspec>, [">= 0"])
127
+ end
128
+ else
129
+ s.add_dependency(%q<sinatra>, [">= 0.9.4"])
130
+ s.add_dependency(%q<haml>, [">= 2.2.5"])
131
+ s.add_dependency(%q<json>, [">= 0"])
132
+ s.add_dependency(%q<ruote>, ["= 2.1.4"])
133
+ s.add_dependency(%q<rspec>, [">= 0"])
134
+ end
135
+ end
136
+
@@ -0,0 +1,211 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "json helper" do
4
+ describe "rendering defaults" do
5
+ before(:each) do
6
+ stub_chain( :request, :fullpath ).and_return('/_ruote')
7
+
8
+ @hash = Rufus::Json.decode( json( :status, :ok ) )
9
+ end
10
+
11
+ it "should have the key & value" do
12
+ @hash.should have_key('status')
13
+ @hash['status'].should == 'ok'
14
+ end
15
+
16
+ it "should have a collection of links" do
17
+ @hash.should have_key('links')
18
+ @hash['links'].should_not be_empty
19
+ end
20
+
21
+ it "should link to 'self'" do
22
+ @hash['links'].detect { |l| l['rel'] == 'self' && l['href'] == '/_ruote' }.should_not be_nil
23
+ end
24
+
25
+ it "should link to the root" do
26
+ @hash['links'].detect { |l| l['rel'] =~ /#root$/ && l['href'] == '/_ruote' }.should_not be_nil
27
+ end
28
+
29
+ it "should link to the processes" do
30
+ @hash['links'].detect { |l| l['rel'] =~ /#processes$/ && l['href'] == '/_ruote/processes' }.should_not be_nil
31
+ end
32
+
33
+ it "should not link to the expressions by default" do
34
+ @hash['links'].detect { |l| l['rel'] =~ /#expressions$/ && l['href'] == '/_ruote/expressions' }.should be_nil
35
+ end
36
+
37
+ it "should link to the workitems" do
38
+ @hash['links'].detect { |l| l['rel'] =~ /#workitems$/ && l['href'] == '/_ruote/workitems' }.should_not be_nil
39
+ end
40
+ end
41
+
42
+ describe "rendering processes" do
43
+ before(:each) do
44
+ stub_chain( :request, :fullpath ).and_return('/_ruote/processes')
45
+
46
+ @wfid = launch_test_process
47
+ process = engine.process( @wfid )
48
+
49
+ @hash = Rufus::Json.decode( json( :processes, [process] ) )
50
+ end
51
+
52
+ it "should have a collection of processes" do
53
+ @hash.should have_key('processes')
54
+ @hash['processes'].should_not be_empty
55
+ end
56
+
57
+ describe "in detail, and" do
58
+ before(:each) do
59
+ @process = @hash['processes'].first
60
+
61
+ @process.should have_key('links')
62
+ end
63
+
64
+ it "should link to the process details" do
65
+
66
+ @process['links'].detect { |l| l['rel'] =~ /#process/ && l['href'] == "/_ruote/processes/#{@wfid}" }.should_not be_nil
67
+ end
68
+
69
+ it "should link to the process expressions" do
70
+
71
+ @process['links'].detect { |l| l['rel'] =~ /#expressions/ && l['href'] == "/_ruote/expressions/#{@wfid}" }.should_not be_nil
72
+ end
73
+
74
+ it "should link to the process workitems" do
75
+
76
+ @process['links'].detect { |l| l['rel'] =~ /#workitems/ && l['href'] == "/_ruote/workitems/#{@wfid}" }.should_not be_nil
77
+ end
78
+ end
79
+
80
+ end
81
+
82
+ describe "rendering a single process" do
83
+ before(:each) do
84
+ @wfid = launch_test_process
85
+
86
+ stub_chain( :request, :fullpath ).and_return("/_ruote/processes/#{@wfid}")
87
+
88
+ process = engine.process( @wfid )
89
+
90
+ @hash = Rufus::Json.decode( json( :process, process ) )
91
+ end
92
+
93
+ it "should have the process details" do
94
+ @hash.should have_key('process')
95
+ end
96
+
97
+ it "should link to the process details" do
98
+
99
+ @hash['process']['links'].detect { |l| l['rel'] =~ /#process/ && l['href'] == "/_ruote/processes/#{@wfid}" }.should_not be_nil
100
+ end
101
+
102
+ it "should link to the process expressions" do
103
+
104
+ @hash['process']['links'].detect { |l| l['rel'] =~ /#expressions/ && l['href'] == "/_ruote/expressions/#{@wfid}" }.should_not be_nil
105
+ end
106
+
107
+ it "should link to the process workitems" do
108
+
109
+ @hash['process']['links'].detect { |l| l['rel'] =~ /#workitems/ && l['href'] == "/_ruote/workitems/#{@wfid}" }.should_not be_nil
110
+ end
111
+ end
112
+
113
+ describe "render a single expression" 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
+ @expid = '0_0_0'
124
+
125
+ stub_chain( :request, :fullpath ).and_return("/_ruote/expressions/#{@wfid}/#{@expid}")
126
+
127
+ process = engine.process( @wfid )
128
+ expression = process.expressions.detect { |exp| exp.fei.expid == @expid }
129
+
130
+ @hash = Rufus::Json.decode( json( :expression, expression ) )
131
+ end
132
+
133
+ it "should contain the expression" do
134
+ @hash.should have_key('expression')
135
+ end
136
+
137
+ it "should link to the process" do
138
+ @hash['expression']['links'].detect { |l| l['rel'] =~ /#process/ && l['href'] == "/_ruote/processes/#{@wfid}" }.should_not be_nil
139
+ end
140
+
141
+ it "should link to the parent expression" do
142
+ @hash['expression']['links'].detect { |l| l['rel'] == 'parent' && l['href'] == "/_ruote/expressions/#{@wfid}/0_0" }.should_not be_nil
143
+ end
144
+ end
145
+
146
+ describe "render an expression tree" do
147
+ before(:each) do
148
+ @wfid = launch_test_process do
149
+ Ruote.process_definition :name => 'foo' do
150
+ sequence do
151
+ nada :activity => 'work your magic'
152
+ end
153
+ end
154
+ end
155
+
156
+ stub_chain( :request, :fullpath ).and_return("/_ruote/expressions/#{@wfid}")
157
+
158
+ process = engine.process( @wfid )
159
+
160
+ @hash = Rufus::Json.decode( json( :expressions, process.expressions ) )
161
+ end
162
+
163
+ it "should have the list of expressions" do
164
+ @hash.should have_key('expressions')
165
+ end
166
+ end
167
+
168
+ describe "rendering a workitem" do
169
+ before(:each) do
170
+ @wfid = launch_test_process do
171
+ Ruote.process_definition :name => 'foo' do
172
+ sequence do
173
+ nada :activity => 'work your magic'
174
+ end
175
+ end
176
+ end
177
+
178
+ stub_chain( :request, :fullpath ).and_return("/_ruote/workitems/#{@wfid}/0_0_0")
179
+
180
+ workitem = find_workitem( @wfid, '0_0_0' )
181
+
182
+ @hash = Rufus::Json.decode( json( :workitem, workitem ) )
183
+ end
184
+
185
+ it "should have the workitem" do
186
+ @hash.should have_key('workitem')
187
+ end
188
+
189
+ end
190
+
191
+ describe "rendering workitems" do
192
+ before(:each) do
193
+ @wfid = launch_test_process do
194
+ Ruote.process_definition :name => 'foo' do
195
+ sequence do
196
+ nada :activity => 'work your magic'
197
+ end
198
+ end
199
+ end
200
+
201
+ stub_chain( :request, :fullpath ).and_return("/_ruote/workitems")
202
+
203
+ @hash = Rufus::Json.decode( json( :workitems, store_participant.all ) )
204
+ end
205
+
206
+ it "should have the workitems" do
207
+ @hash.should have_key('workitems')
208
+ end
209
+
210
+ end
211
+ end
@@ -0,0 +1,179 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "GET /_ruote/expressions" do
4
+ it "should report a friendly message to the user (HTML)" do
5
+ get "/_ruote/expressions"
6
+
7
+ last_response.should be_ok
8
+ end
9
+
10
+ it "should report a friendly message to the client (JSON)" do
11
+ get "/_ruote/expressions.json"
12
+
13
+ last_response.should be_ok
14
+
15
+ last_response.json_body['status'].should == 'ok'
16
+ end
17
+ end
18
+
19
+ describe "GET /_ruote/expressions/wfid" do
20
+ describe "with running processes" do
21
+ before(:each) do
22
+ @wfid = launch_test_process
23
+ end
24
+
25
+ it "should render the expression tree (HTML)" do
26
+ get "/_ruote/expressions/#{@wfid}"
27
+
28
+ last_response.should be_ok
29
+ end
30
+
31
+ it "should render the expression tree (JSON)" do
32
+ get "/_ruote/expressions/#{@wfid}.json"
33
+
34
+ last_response.should be_ok
35
+ end
36
+ end
37
+
38
+ describe "without running processes" do
39
+ it "should 404 correctly (HTML)" do
40
+ get "/_ruote/expressions/foo"
41
+
42
+ last_response.should_not be_ok
43
+ last_response.status.should be(404)
44
+ end
45
+
46
+ it "should 404 correctly (JSON)" do
47
+ get "/_ruote/expressions/foo.json"
48
+
49
+ last_response.should_not be_ok
50
+ last_response.status.should be(404)
51
+ end
52
+ end
53
+ end
54
+
55
+ describe "GET /_ruote/expressions/wfid/expid" do
56
+ describe "with running processes" do
57
+ before(:each) do
58
+ @wfid = launch_test_process
59
+ process = engine.process( @wfid )
60
+ @nada_exp_id = process.expressions.last.fei.expid
61
+ end
62
+
63
+ it "should render the expression details (HTML)" do
64
+ get "/_ruote/expressions/#{@wfid}/#{@nada_exp_id}"
65
+
66
+ last_response.should be_ok
67
+ end
68
+
69
+ it "should render the expression details (JSON)" do
70
+ get "/_ruote/expressions/#{@wfid}/#{@nada_exp_id}.json"
71
+
72
+ last_response.should be_ok
73
+ end
74
+ end
75
+
76
+ describe "without running processes" do
77
+ it "should 404 correctly (HTML)" do
78
+ get "/workitems/foo/bar"
79
+
80
+ last_response.should_not be_ok
81
+ last_response.status.should be(404)
82
+ end
83
+
84
+ it "should 404 correctly (JSON)" do
85
+ get "/workitems/foo/bar.json"
86
+
87
+ last_response.should_not be_ok
88
+ last_response.status.should be(404)
89
+ end
90
+ end
91
+ end
92
+
93
+ describe "DELETE /_ruote/expressions/wfid/expid" do
94
+ describe "with running processes" do
95
+ before(:each) do
96
+ @wfid = launch_test_process do
97
+ Ruote.process_definition :name => 'delete' do
98
+ sequence do
99
+ wait '1d', :on_cancel => 'bail_out'
100
+ echo 'done'
101
+ end
102
+
103
+ define 'bail_out' do
104
+ sequence do
105
+ echo 'bailed'
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ wait_exp = engine.process( @wfid ).expressions.last
112
+ @expid = "0_1_0" #wait_exp.fei.expid
113
+ end
114
+
115
+ it "should cancel the expressions (HTML)" do
116
+ delete "/_ruote/expressions/#{@wfid}/#{@expid}"
117
+
118
+ last_response.should be_redirect
119
+ last_response['Location'].should == "/_ruote/expressions/#{@wfid}"
120
+
121
+ #sleep 0.4
122
+ wait_for( @wfid )
123
+
124
+ @tracer.to_s.should == "bailed\ndone"
125
+ end
126
+
127
+ it "should cancel the expressions (JSON)" do
128
+ delete "/_ruote/expressions/#{@wfid}/#{@expid}.json"
129
+
130
+ last_response.should be_ok
131
+ last_response.json_body['status'].should == 'ok'
132
+
133
+ #sleep 0.4
134
+ wait_for( @wfid )
135
+
136
+ @tracer.to_s.should == "bailed\ndone"
137
+ end
138
+
139
+ it "should kill the expression (HTML)" do
140
+ delete "/_ruote/expressions/#{@wfid}/#{@expid}?_kill=1"
141
+
142
+ last_response.should be_redirect
143
+ last_response['Location'].should == "/_ruote/expressions/#{@wfid}"
144
+
145
+ #sleep 0.4
146
+ wait_for( @wfid )
147
+
148
+ @tracer.to_s.should == "done"
149
+ end
150
+
151
+ it "should kill the expression (JSON)" do
152
+ delete "/_ruote/expressions/#{@wfid}/#{@expid}.json?_kill=1"
153
+
154
+ last_response.should be_ok
155
+ last_response.json_body['status'].should == 'ok'
156
+
157
+ #sleep 0.4
158
+ wait_for( @wfid )
159
+
160
+ @tracer.to_s.should == "done"
161
+ end
162
+ end
163
+
164
+ describe "without running processes" do
165
+ it "should 404 correctly (HTML)" do
166
+ delete "/_ruote/expressions/foo/bar"
167
+
168
+ last_response.should_not be_ok
169
+ last_response.status.should be(404)
170
+ end
171
+
172
+ it "should 404 correctly (JSON)" do
173
+ delete "/_ruote/expressions/foo/bar.json"
174
+
175
+ last_response.should_not be_ok
176
+ last_response.status.should be(404)
177
+ end
178
+ end
179
+ end