ruote-kit 2.1.11 → 2.2.0.3

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.
Files changed (40) hide show
  1. data/CHANGELOG.txt +6 -1
  2. data/CREDITS.txt +23 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.rdoc +44 -7
  5. data/Rakefile +78 -45
  6. data/TODO.txt +8 -0
  7. data/lib/ruote-kit/helpers/json_helpers.rb +1 -1
  8. data/lib/ruote-kit/helpers/misc_helpers.rb +1 -1
  9. data/lib/ruote-kit/helpers/render_helpers.rb +18 -1
  10. data/lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css +1 -1
  11. data/lib/ruote-kit/resources/expressions.rb +6 -0
  12. data/lib/ruote-kit/resources/participants.rb +3 -1
  13. data/lib/ruote-kit/resources/schedules.rb +1 -1
  14. data/lib/ruote-kit/resources/workitems.rb +4 -0
  15. data/lib/ruote-kit/version.rb +1 -1
  16. data/lib/ruote-kit/views/expression.html.haml +2 -2
  17. data/lib/ruote-kit/views/layout.html.haml +1 -1
  18. data/lib/ruote-kit/views/participants.html.haml +19 -18
  19. data/lib/ruote-kit.rb +13 -3
  20. data/ruote-kit.gemspec +34 -133
  21. data/spec/resources/errors_spec.rb +20 -8
  22. data/spec/resources/expressions_spec.rb +211 -45
  23. data/spec/resources/index_spec.rb +1 -5
  24. data/spec/resources/participants_spec.rb +26 -9
  25. data/spec/resources/processes_spec.rb +77 -41
  26. data/spec/resources/schedules_spec.rb +33 -9
  27. data/spec/resources/workitems_spec.rb +174 -83
  28. data/spec/spec_helper.rb +11 -56
  29. data/spec/support/engine_helper.rb +97 -0
  30. data/spec/support/rack_helper.rb +21 -0
  31. data/spec/support/render_helper.rb +16 -0
  32. data/spec/webapp_helpers_spec.rb +1 -0
  33. metadata +121 -121
  34. data/.document +0 -0
  35. data/.gitignore +0 -10
  36. data/Gemfile +0 -51
  37. data/config.ru +0 -60
  38. data/lib/ruote-kit/spec/ruote_helpers.rb +0 -56
  39. data/spec/it_has_an_engine.rb +0 -69
  40. data/spec/spec.opts +0 -1
data/ruote-kit.gemspec CHANGED
@@ -1,140 +1,41 @@
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 -*-
1
+ # encoding: utf-8
5
2
 
6
3
  Gem::Specification.new do |s|
7
- s.name = %q{ruote-kit}
8
- s.version = "2.1.11"
9
4
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["kenneth.kalmer@gmail.com", "Torsten Schoenebaum", "John Mettraux"]
12
- s.date = %q{2010-10-01}
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
- "CHANGELOG.txt",
17
- "LICENSE.txt",
18
- "README.rdoc",
19
- "TODO.txt"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".gitignore",
24
- "CHANGELOG.txt",
25
- "Gemfile",
26
- "LICENSE.txt",
27
- "README.rdoc",
28
- "Rakefile",
29
- "TODO.txt",
30
- "config.ru",
31
- "lib/ruote-kit.rb",
32
- "lib/ruote-kit/application.rb",
33
- "lib/ruote-kit/helpers/json_helpers.rb",
34
- "lib/ruote-kit/helpers/link_helpers.rb",
35
- "lib/ruote-kit/helpers/misc_helpers.rb",
36
- "lib/ruote-kit/helpers/pagination_helpers.rb",
37
- "lib/ruote-kit/helpers/render_helpers.rb",
38
- "lib/ruote-kit/public/_ruote/images/favicon.ico",
39
- "lib/ruote-kit/public/_ruote/images/ruote.png",
40
- "lib/ruote-kit/public/_ruote/images/ruote_buttons.png",
41
- "lib/ruote-kit/public/_ruote/javascripts/jquery-1.4.2.min.js",
42
- "lib/ruote-kit/public/_ruote/javascripts/rk.js",
43
- "lib/ruote-kit/public/_ruote/javascripts/ruote-fluo-editor.js",
44
- "lib/ruote-kit/public/_ruote/javascripts/ruote-fluo.js",
45
- "lib/ruote-kit/public/_ruote/stylesheets/reset.css",
46
- "lib/ruote-kit/public/_ruote/stylesheets/rk.css",
47
- "lib/ruote-kit/public/_ruote/stylesheets/ruote-fluo-editor.css",
48
- "lib/ruote-kit/resources/errors.rb",
49
- "lib/ruote-kit/resources/expressions.rb",
50
- "lib/ruote-kit/resources/participants.rb",
51
- "lib/ruote-kit/resources/processes.rb",
52
- "lib/ruote-kit/resources/schedules.rb",
53
- "lib/ruote-kit/resources/workitems.rb",
54
- "lib/ruote-kit/spec/ruote_helpers.rb",
55
- "lib/ruote-kit/version.rb",
56
- "lib/ruote-kit/views/_pagination.html.haml",
57
- "lib/ruote-kit/views/_tree_editor.html.haml",
58
- "lib/ruote-kit/views/error.html.haml",
59
- "lib/ruote-kit/views/errors.html.haml",
60
- "lib/ruote-kit/views/expression.html.haml",
61
- "lib/ruote-kit/views/expressions.html.haml",
62
- "lib/ruote-kit/views/http_error.html.haml",
63
- "lib/ruote-kit/views/index.html.haml",
64
- "lib/ruote-kit/views/layout.html.haml",
65
- "lib/ruote-kit/views/participants.html.haml",
66
- "lib/ruote-kit/views/process.html.haml",
67
- "lib/ruote-kit/views/process_launched.html.haml",
68
- "lib/ruote-kit/views/processes.html.haml",
69
- "lib/ruote-kit/views/processes_new.html.haml",
70
- "lib/ruote-kit/views/schedules.html.haml",
71
- "lib/ruote-kit/views/workitem.html.haml",
72
- "lib/ruote-kit/views/workitems.html.haml",
73
- "ruote-kit.gemspec",
74
- "spec/it_has_an_engine.rb",
75
- "spec/resources/errors_spec.rb",
76
- "spec/resources/expressions_spec.rb",
77
- "spec/resources/index_spec.rb",
78
- "spec/resources/participants_spec.rb",
79
- "spec/resources/processes_spec.rb",
80
- "spec/resources/schedules_spec.rb",
81
- "spec/resources/workitems_spec.rb",
82
- "spec/ruote-kit_configure_spec.rb",
83
- "spec/spec.opts",
84
- "spec/spec_helper.rb",
85
- "spec/webapp_helpers_spec.rb"
86
- ]
87
- s.homepage = %q{http://github.com/tosch/ruote-kit}
88
- s.rdoc_options = ["--charset=UTF-8"]
89
- s.require_paths = ["lib"]
90
- s.rubygems_version = %q{1.3.7}
91
- s.summary = %q{ruote workflow engine, wrapped in a loving rack embrace}
92
- s.test_files = [
93
- "spec/webapp_helpers_spec.rb",
94
- "spec/resources/participants_spec.rb",
95
- "spec/resources/index_spec.rb",
96
- "spec/resources/errors_spec.rb",
97
- "spec/resources/processes_spec.rb",
98
- "spec/resources/workitems_spec.rb",
99
- "spec/resources/schedules_spec.rb",
100
- "spec/resources/expressions_spec.rb",
101
- "spec/it_has_an_engine.rb",
102
- "spec/spec_helper.rb",
103
- "spec/ruote-kit_configure_spec.rb"
104
- ]
5
+ s.name = 'ruote-kit'
6
+ #s.version = File.read('lib/ruote-kit/version.rb').match(/VERSION = '([^']+)'/)[1]
7
+ s.version = '2.2.0.3'
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = [ 'Kenneth Kalmer', 'Torsten Schoenebaum', 'John Mettraux' ]
10
+ s.email = [ 'kenneth.kalmer@gmail.com' ]
11
+ s.homepage = 'http://github.com/tosch/ruote-kit'
12
+ s.rubyforge_project = 'ruote'
13
+ s.summary = 'ruote workflow engine, wrapped in a loving rack embrace'
14
+ s.description = %q{
15
+ ruote workflow engine, wrapped in a loving rack embrace
16
+ }
105
17
 
106
- if s.respond_to? :specification_version then
107
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
108
- s.specification_version = 3
18
+ #s.files = `git ls-files`.split("\n")
19
+ s.files = Dir[
20
+ 'Rakefile',
21
+ 'lib/**/*.rb', 'spec/**/*.rb', 'test/**/*.rb',
22
+ '*.gemspec', '*.txt', '*.rdoc', '*.md',
23
+ 'lib/ruote-kit/public/**/*', 'lib/ruote-kit/views/**/*'
24
+ ] - [ 'rails-template.rb' ]
109
25
 
110
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
111
- s.add_runtime_dependency(%q<bundler>, [">= 0"])
112
- s.add_runtime_dependency(%q<sinatra>, [">= 0"])
113
- s.add_runtime_dependency(%q<sinatra-respond_to>, [">= 0"])
114
- s.add_runtime_dependency(%q<haml>, [">= 0"])
115
- s.add_runtime_dependency(%q<thin>, [">= 0"])
116
- s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
117
- s.add_runtime_dependency(%q<rufus-json>, [">= 0.2.5"])
118
- s.add_runtime_dependency(%q<ruote>, ["~> 2.1.11"])
119
- else
120
- s.add_dependency(%q<bundler>, [">= 0"])
121
- s.add_dependency(%q<sinatra>, [">= 0"])
122
- s.add_dependency(%q<sinatra-respond_to>, [">= 0"])
123
- s.add_dependency(%q<haml>, [">= 0"])
124
- s.add_dependency(%q<thin>, [">= 0"])
125
- s.add_dependency(%q<yajl-ruby>, [">= 0"])
126
- s.add_dependency(%q<rufus-json>, [">= 0.2.5"])
127
- s.add_dependency(%q<ruote>, ["~> 2.1.11"])
128
- end
129
- else
130
- s.add_dependency(%q<bundler>, [">= 0"])
131
- s.add_dependency(%q<sinatra>, [">= 0"])
132
- s.add_dependency(%q<sinatra-respond_to>, [">= 0"])
133
- s.add_dependency(%q<haml>, [">= 0"])
134
- s.add_dependency(%q<thin>, [">= 0"])
135
- s.add_dependency(%q<yajl-ruby>, [">= 0"])
136
- s.add_dependency(%q<rufus-json>, [">= 0.2.5"])
137
- s.add_dependency(%q<ruote>, ["~> 2.1.11"])
138
- end
26
+ s.add_runtime_dependency 'sinatra', '1.0'
27
+ s.add_runtime_dependency 'sinatra-respond_to', '0.5.0'
28
+ s.add_runtime_dependency 'haml', '3.0.25'
29
+
30
+ s.add_runtime_dependency 'rufus-json', '>= 0.2.5'
31
+ #s.add_runtime_dependency('ruote', s.version) unless defined?(Bundler)
32
+ s.add_runtime_dependency('ruote', '>= 2.2.0') unless defined?(Bundler)
33
+ # see Gemfile
34
+
35
+ s.add_development_dependency 'rspec', '2.4.0'
36
+ s.add_development_dependency 'rack-test', '0.5.7'
37
+ s.add_development_dependency 'webrat', '0.7.3'
38
+
39
+ s.require_path = 'lib'
139
40
  end
140
41
 
@@ -1,12 +1,18 @@
1
1
 
2
- require 'spec_helper'
3
-
4
- undef :context if defined?(context)
2
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
5
3
 
6
4
 
7
5
  describe 'without any running processes' do
8
6
 
9
- it_has_an_engine_with_no_participants
7
+ before(:each) do
8
+
9
+ prepare_engine
10
+ end
11
+
12
+ after(:each) do
13
+
14
+ shutdown_and_purge_engine
15
+ end
10
16
 
11
17
  describe 'GET /_ruote/errors' do
12
18
 
@@ -33,10 +39,10 @@ end
33
39
 
34
40
  describe 'with a running process that has an error' do
35
41
 
36
- it_has_an_engine_with_no_participants
37
-
38
42
  before(:each) do
39
43
 
44
+ prepare_engine
45
+
40
46
  RuoteKit.engine.register_participant :alice, Ruote::StorageParticipant
41
47
 
42
48
  @wfid = RuoteKit.engine.launch(
@@ -51,6 +57,12 @@ describe 'with a running process that has an error' do
51
57
  RuoteKit.engine.wait_for(@wfid)
52
58
 
53
59
  @error = RuoteKit.engine.process(@wfid).errors.first
60
+ @fei = @error.fei
61
+ end
62
+
63
+ after(:each) do
64
+
65
+ shutdown_and_purge_engine
54
66
  end
55
67
 
56
68
  describe 'GET /_ruote/errors' do
@@ -109,7 +121,7 @@ describe 'with a running process that has an error' do
109
121
  # the links for the error itself
110
122
 
111
123
  json['errors'].first['links'].should == [
112
- { 'href' => "/_ruote/errors/0_0_0!!#{@wfid}",
124
+ { 'href' => "/_ruote/errors/#{@fei.expid}!#{@fei.subid}!#{@wfid}",
113
125
  'rel' => 'self' },
114
126
  { 'href' => "/_ruote/errors/#{@wfid}",
115
127
  'rel' => 'http://ruote.rubyforge.org/rels.html#process_errors' },
@@ -143,7 +155,7 @@ describe 'with a running process that has an error' do
143
155
  json['errors'].first['message'].should == "#<RuntimeError: unknown participant or subprocess 'nemo'>"
144
156
 
145
157
  json['errors'].first['links'].should == [
146
- { 'href' => "/_ruote/errors/0_0_0!!#{@wfid}",
158
+ { 'href' => "/_ruote/errors/#{@fei.expid}!#{@fei.subid}!#{@wfid}",
147
159
  'rel' => 'self' },
148
160
  { 'href' => "/_ruote/errors/#{@wfid}",
149
161
  'rel' => 'http://ruote.rubyforge.org/rels.html#process_errors' },
@@ -1,12 +1,18 @@
1
1
 
2
- require 'spec_helper'
3
-
4
- undef :context if defined?(context)
2
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
5
3
 
6
4
 
7
5
  describe 'GET /_ruote/expressions' do
8
6
 
9
- it_has_an_engine
7
+ before(:each) do
8
+
9
+ prepare_engine
10
+ end
11
+
12
+ after(:each) do
13
+
14
+ shutdown_and_purge_engine
15
+ end
10
16
 
11
17
  it 'should 404 (HTML)' do
12
18
 
@@ -18,12 +24,20 @@ end
18
24
 
19
25
  describe 'GET /_ruote/expressions/wfid' do
20
26
 
21
- it_has_an_engine
27
+ before(:each) do
28
+
29
+ prepare_engine_with_participants
30
+ end
31
+
32
+ after(:each) do
33
+
34
+ shutdown_and_purge_engine
35
+ end
22
36
 
23
37
  describe 'with running processes' do
24
38
 
25
39
  before(:each) do
26
- @wfid = launch_test_process
40
+ @wfid = launch_nada_process
27
41
  end
28
42
 
29
43
  it 'should render the expressions (HTML)' do
@@ -67,39 +81,67 @@ end
67
81
 
68
82
  describe 'GET /_ruote/expressions/fei' do
69
83
 
70
- it_has_an_engine
84
+ before(:each) do
85
+
86
+ prepare_engine_with_participants
87
+ end
88
+
89
+ after(:each) do
90
+
91
+ shutdown_and_purge_engine
92
+ end
71
93
 
72
94
  describe 'with running processes' do
73
95
 
74
96
  before(:each) do
75
97
 
76
- @wfid = launch_test_process
77
- process = engine.process(@wfid)
78
- @nada_exp_id = process.expressions.last.fei.expid
98
+ @wfid = launch_nada_process
99
+ @nada_fexp = RuoteKit.engine.process(@wfid).expressions.last
100
+ @nada_fei = @nada_fexp.fei
79
101
  end
80
102
 
81
103
  it 'should render the expression (HTML)' do
82
104
 
83
- get "/_ruote/expressions/#{@nada_exp_id}!!#{@wfid}"
105
+ get "/_ruote/expressions/#{@nada_fei.sid}"
84
106
 
85
107
  last_response.should be_ok
86
108
  end
87
109
 
88
110
  it 'should render the expression (JSON)' do
89
111
 
90
- get "/_ruote/expressions/#{@nada_exp_id}!!#{@wfid}.json"
112
+ get "/_ruote/expressions/#{@nada_fei.sid}.json"
91
113
 
92
114
  last_response.should be_ok
93
115
 
94
116
  #puts Rufus::Json.pretty_encode(last_response.json_body)
95
117
 
96
- last_response.json_body['expression']['links'].size.should be(4)
118
+ last_response.json_body['expression']['links'].size.should == 4
97
119
 
98
120
  last_response.json_body['expression'].keys.sort.should == %w[
99
121
  applied_workitem class fei links name original_tree parent
100
122
  timeout_schedule_id tree variables
101
123
  ]
102
124
  end
125
+
126
+ it 'should include an etag header (HTML)' do
127
+
128
+ get "/_ruote/expressions/#{@nada_fei.sid}"
129
+
130
+ last_response.headers.should include('ETag')
131
+
132
+ last_response.headers['ETag'].should ==
133
+ "\"#{@nada_fexp.to_h['_rev'].to_s}\""
134
+ end
135
+
136
+ it 'should include an etag header (JSON)' do
137
+
138
+ get "/_ruote/expressions/#{@nada_fei.sid}.json"
139
+
140
+ last_response.headers.should include('ETag')
141
+
142
+ last_response.headers['ETag'].should ==
143
+ "\"#{@nada_fexp.to_h['_rev'].to_s}\""
144
+ end
103
145
  end
104
146
 
105
147
  describe 'without running processes' do
@@ -125,16 +167,20 @@ describe 'GET /_ruote/expressions/fei' do
125
167
 
126
168
  before(:each) do
127
169
 
170
+ register_participants
171
+
128
172
  @wfid = RuoteKit.engine.launch(Ruote.define do
129
173
  alpha :timeout => '2y'
130
174
  end)
131
175
 
132
176
  RuoteKit.engine.wait_for(:alpha)
177
+
178
+ @fei = RuoteKit.engine.process(@wfid).expressions.last.fei
133
179
  end
134
180
 
135
181
  it 'should render the expression (HTML)' do
136
182
 
137
- get "/_ruote/expressions/0_0!!#{@wfid}"
183
+ get "/_ruote/expressions/#{@fei.expid}!#{@fei.subid}!#{@wfid}"
138
184
 
139
185
  last_response.status.should be(200)
140
186
 
@@ -144,7 +190,7 @@ describe 'GET /_ruote/expressions/fei' do
144
190
 
145
191
  it 'should render the expression (JSON)' do
146
192
 
147
- get "/_ruote/expressions/0_0!!#{@wfid}.json"
193
+ get "/_ruote/expressions/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json"
148
194
 
149
195
  last_response.status.should be(200)
150
196
 
@@ -158,39 +204,43 @@ end
158
204
 
159
205
  describe 'DELETE /_ruote/expressions/fei' do
160
206
 
161
- it_has_an_engine
207
+ before(:each) do
208
+
209
+ prepare_engine_with_participants
210
+ end
211
+
212
+ after(:each) do
213
+
214
+ shutdown_and_purge_engine
215
+ end
162
216
 
163
217
  describe 'with running processes' do
164
218
 
165
219
  before(:each) do
166
220
 
167
- @wfid = launch_test_process do
168
- Ruote.process_definition :name => 'delete' do
169
- sequence do
170
- wait '1d', :on_cancel => 'bail_out'
171
- echo 'done'
172
- end
173
-
174
- define 'bail_out' do
175
- sequence do
176
- echo 'bailed'
177
- end
178
- end
221
+ @wfid = RuoteKit.engine.launch(Ruote.process_definition do
222
+ sequence do
223
+ alfred :on_cancel => 'bail_out'
224
+ echo 'done'
179
225
  end
180
- end
181
226
 
182
- wait_exp = engine.process(@wfid).expressions.last
183
- @expid = "0_1_0" #wait_exp.fei.expid
227
+ define 'bail_out' do
228
+ echo 'bailed'
229
+ end
230
+ end)
231
+
232
+ RuoteKit.engine.wait_for(:alfred)
233
+
234
+ @fei = engine.process(@wfid).expressions.last.fei
184
235
  end
185
236
 
186
237
  it 'should cancel the expressions (HTML)' do
187
238
 
188
- delete "/_ruote/expressions/#{@expid}!!#{@wfid}"
239
+ delete "/_ruote/expressions/#{@fei.sid}"
189
240
 
190
241
  last_response.should be_redirect
191
242
  last_response['Location'].should == "/_ruote/expressions/#{@wfid}"
192
243
 
193
- #sleep 0.4
194
244
  wait_for(@wfid)
195
245
 
196
246
  @tracer.to_s.should == "bailed\ndone"
@@ -198,12 +248,11 @@ describe 'DELETE /_ruote/expressions/fei' do
198
248
 
199
249
  it 'should cancel the expressions (JSON)' do
200
250
 
201
- delete "/_ruote/expressions/#{@expid}!!#{@wfid}.json"
251
+ delete "/_ruote/expressions/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json"
202
252
 
203
253
  last_response.should be_ok
204
254
  last_response.json_body['status'].should == 'ok'
205
255
 
206
- #sleep 0.4
207
256
  wait_for(@wfid)
208
257
 
209
258
  @tracer.to_s.should == "bailed\ndone"
@@ -211,7 +260,7 @@ describe 'DELETE /_ruote/expressions/fei' do
211
260
 
212
261
  it 'should kill the expression (HTML)' do
213
262
 
214
- delete "/_ruote/expressions/#{@expid}!!#{@wfid}?_kill=1"
263
+ delete "/_ruote/expressions/#{@fei.expid}!#{@fei.subid}!#{@wfid}?_kill=1"
215
264
 
216
265
  last_response.should be_redirect
217
266
  last_response['Location'].should == "/_ruote/expressions/#{@wfid}"
@@ -224,7 +273,7 @@ describe 'DELETE /_ruote/expressions/fei' do
224
273
 
225
274
  it 'should kill the expression (JSON)' do
226
275
 
227
- delete "/_ruote/expressions/#{@expid}!!#{@wfid}.json?_kill=1"
276
+ delete "/_ruote/expressions/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json?_kill=1"
228
277
 
229
278
  last_response.should be_ok
230
279
  last_response.json_body['status'].should == 'ok'
@@ -234,6 +283,62 @@ describe 'DELETE /_ruote/expressions/fei' do
234
283
 
235
284
  @tracer.to_s.should == 'done'
236
285
  end
286
+
287
+ it 'should 412 when the etags do not match (HTML)' do
288
+
289
+ delete(
290
+ "/_ruote/expressions/#{@fei.expid}!#{@fei.subid}!#{@wfid}",
291
+ nil,
292
+ { 'HTTP_IF_MATCH' => '"foo"' }
293
+ )
294
+
295
+ last_response.status.should == 412
296
+ end
297
+
298
+ it 'should 412 when the etags do not match (JSON)' do
299
+
300
+ delete(
301
+ "/_ruote/expressions/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json",
302
+ nil,
303
+ {
304
+ 'HTTP_IF_MATCH' => '"foo"',
305
+ 'CONTENT_TYPE' => 'application/json',
306
+ }
307
+ )
308
+
309
+ last_response.status.should == 412
310
+ end
311
+
312
+ it 'should not 412 when the etags do match (HTML)' do
313
+ exp = RuoteKit.engine.process(@wfid).expressions.find { |e|
314
+ e.fei.expid == @fei.expid
315
+ }
316
+
317
+ delete(
318
+ "/_ruote/expressions/#{@fei.expid}!#{@fei.subid}!#{@wfid}",
319
+ nil,
320
+ { 'HTTP_IF_MATCH' => ('"%s"' % exp.to_h['_rev'] ) }
321
+ )
322
+
323
+ last_response.status.should_not == 412
324
+ end
325
+
326
+ it 'should not 412 when the etags do match (JSON)' do
327
+ exp = RuoteKit.engine.process(@wfid).expressions.find { |e|
328
+ e.fei.expid == @fei.expid
329
+ }
330
+
331
+ delete(
332
+ "/_ruote/expressions/#{@fei.expid}!#{@fei.subid}!#{@wfid}.json",
333
+ nil,
334
+ {
335
+ 'HTTP_IF_MATCH' => ('"%s"' % exp.to_h['_rev'] ),
336
+ 'CONTENT_TYPE' => 'application/json',
337
+ }
338
+ )
339
+
340
+ last_response.status.should_not == 412
341
+ end
237
342
  end
238
343
 
239
344
  describe 'without running processes' do
@@ -258,19 +363,26 @@ end
258
363
 
259
364
  describe 'PUT /_ruote/expressions/fei' do
260
365
 
261
- it_has_an_engine
262
-
263
366
  before(:each) do
264
367
 
265
- @wfid = launch_test_process do
368
+ prepare_engine_with_participants
369
+
370
+ @wfid = RuoteKit.engine.launch(
371
+
266
372
  Ruote.process_definition do
267
373
  alpha
268
374
  end
269
- end
375
+ )
376
+
377
+ RuoteKit.engine.wait_for(:alpha)
378
+ RuoteKit.engine.wait_for(1)
379
+
380
+ @exp = RuoteKit.engine.process(@wfid).expressions.last
381
+ end
382
+
383
+ after(:each) do
270
384
 
271
- @exp = RuoteKit.engine.process(@wfid).expressions.find { |e|
272
- e.fei.expid == '0_0'
273
- }
385
+ shutdown_and_purge_engine
274
386
  end
275
387
 
276
388
  it 'should re-apply (HTML)' do
@@ -421,7 +533,7 @@ describe 'PUT /_ruote/expressions/fei' do
421
533
  "/_ruote/expressions/#{@exp.fei.sid}",
422
534
  :fields => "{bogus}")
423
535
 
424
- last_response.status.should be(400)
536
+ last_response.status.should == 400
425
537
  end
426
538
 
427
539
  it 'should 400 when passed bogus JSON (JSON)' do
@@ -435,5 +547,59 @@ describe 'PUT /_ruote/expressions/fei' do
435
547
  last_response.json_body['http_error']['code'].should == 400
436
548
  last_response.json_body['http_error']['message'].should == 'bad request'
437
549
  end
550
+
551
+ it 'should 412 when the etags do not match (HTML)' do
552
+
553
+ put(
554
+ "/_ruote/expressions/#{@exp.fei.sid}",
555
+ { :fields => '{}' },
556
+ { 'HTTP_IF_MATCH' => '"foo"' }
557
+ )
558
+
559
+ last_response.status.should == 412
560
+ end
561
+
562
+ it 'should 412 when the etags do not match (JSON)' do
563
+
564
+ put(
565
+ "/_ruote/expressions/#{@exp.fei.sid}",
566
+ Rufus::Json.encode({}),
567
+ {
568
+ 'CONTENT_TYPE' => 'application/json',
569
+ 'HTTP_IF_MATCH' => '"foo"'
570
+ }
571
+ )
572
+
573
+ last_response.status.should == 412
574
+ end
575
+
576
+ it 'should not 412 when the etags match (HTML)' do
577
+
578
+ rev = @exp.to_h['_rev']
579
+
580
+ put(
581
+ "/_ruote/expressions/#{@exp.fei.sid}",
582
+ { :fields => '{}' },
583
+ { 'HTTP_IF_MATCH' => ('"%s"' % rev) }
584
+ )
585
+
586
+ last_response.status.should_not == 412
587
+ end
588
+
589
+ it 'should not 412 when the etags match (JSON)' do
590
+
591
+ rev = @exp.to_h['_rev']
592
+
593
+ put(
594
+ "/_ruote/expressions/#{@exp.fei.sid}",
595
+ Rufus::Json.encode({}),
596
+ {
597
+ 'CONTENT_TYPE' => 'application/json',
598
+ 'HTTP_IF_MATCH' => ('"%s"' % rev )
599
+ }
600
+ )
601
+
602
+ last_response.status.should_not == 412
603
+ end
438
604
  end
439
605
 
@@ -1,11 +1,9 @@
1
1
 
2
- require 'spec_helper'
2
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper.rb')
3
3
 
4
4
 
5
5
  describe 'GET /' do
6
6
 
7
- it_has_an_engine
8
-
9
7
  it 'should return a welcome message in HTML be default' do
10
8
 
11
9
  get '/_ruote'
@@ -34,8 +32,6 @@ end
34
32
 
35
33
  describe 'Generic error handling' do
36
34
 
37
- it_has_an_engine
38
-
39
35
  it 'should give our own 404 page (HTML)' do
40
36
 
41
37
  get '/kenneth'