jmettraux / ruote-rest

restful workflow engine based on Rack and ruote (Warning : ruote-rest will be replaced by ruote-kit soon)

ruote-rest / test / st_expressions_yaml.rb
100644 67 lines (40 sloc) 1.633 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require File.dirname(__FILE__) + '/testbase'
 
 
class StExpressionsTest < Test::Unit::TestCase
 
  include TestBase
 
 
  def test_update_and_reget_expression
 
    li = OpenWFE::LaunchItem.new <<-EOS
class TestStExpressions < OpenWFE::ProcessDefinition
sequence do
alpha
bravo
end
end
EOS
 
    #p OpenWFE::Xml.launchitem_to_xml(li)
 
    post(
      "/processes",
      OpenWFE::Xml.launchitem_to_xml(li),
      { "CONTENT_TYPE" => "application/xml" })
 
    fei = OpenWFE::Xml.fei_from_xml @response.body
 
    sleep 0.350
 
 
    ## workitem flowexpression yaml update
 
    get "/expressions/#{fei.wfid}/0_0_0?format=yaml"
 
    assert_equal 200, @response.status
 
    exp = YAML.load @response.body
    exp.attributes = { :toto => :surf }
 
    put(
      "/expressions/#{fei.wfid}/0_0_0",
      exp.to_yaml,
      { 'CONTENT_TYPE' => 'application/yaml' })
 
    assert_equal 200, @response.status
 
 
    ## now, asking for the workitem flowexpression and process flowexpression fails with errors:
 
    ## "undefined method `ctime' for "2009-06-08 11:07:48.030196 +02:00":String" ('ACCEPT' => 'application/xml')
    ## "undefined method `httpdate' for "2009-06-08 11:44:04.057000 +02:00":String" ('ACCEPT' => 'text/html')
 
 
    get "/expressions/#{fei.wfid}", nil, {'HTTP_ACCEPT' => 'application/json'}
    assert_equal 200, @response.status
 
    get "/expressions/#{fei.wfid}", nil, {'HTTP_ACCEPT' => 'application/xml'}
    assert_equal 200, @response.status
 
    get "/expressions/#{fei.wfid}", nil, {'HTTP_ACCEPT' => 'text/html'}
    assert_equal 200, @response.status
  end
 
end