backlog 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/Rakefile +2 -1
- data/app/controllers/application.rb +55 -8
- data/app/controllers/groups_controller.rb +62 -0
- data/app/controllers/periods_controller.rb +13 -55
- data/app/controllers/tasks_controller.rb +9 -5
- data/app/controllers/works_controller.rb +43 -6
- data/app/helpers/application_helper.rb +20 -2
- data/app/helpers/groups_helper.rb +2 -0
- data/app/models/backlog.rb +19 -10
- data/app/models/estimate.rb +2 -1
- data/app/models/group.rb +11 -0
- data/app/models/party.rb +3 -0
- data/app/models/period.rb +43 -6
- data/app/models/task.rb +27 -14
- data/app/models/user.rb +37 -8
- data/app/models/work.rb +4 -6
- data/app/views/backlogs/_name_list.rhtml +5 -0
- data/app/views/backlogs/show.rhtml +4 -4
- data/app/views/groups/_form.rhtml +7 -0
- data/app/views/groups/edit.rhtml +31 -0
- data/app/views/groups/list.rhtml +27 -0
- data/app/views/groups/new.rhtml +8 -0
- data/app/views/layouts/wide.rhtml +2 -2
- data/app/views/periods/_burn_down_chart.rhtml +1 -1
- data/app/views/periods/_form.rhtml +13 -9
- data/app/views/periods/_show_active.rhtml +6 -12
- data/app/views/periods/_title.rhtml +4 -5
- data/app/views/periods/edit.rhtml +1 -1
- data/app/views/periods/new.rhtml +1 -1
- data/app/views/periods/show.rhtml +10 -6
- data/app/views/tasks/_backlog_header.rhtml +22 -0
- data/app/views/tasks/_description_list.rhtml +5 -0
- data/app/views/tasks/_form.rhtml +26 -7
- data/app/views/tasks/_task.rhtml +4 -4
- data/app/views/tasks/edit.rhtml +2 -3
- data/app/views/tasks/list_started.rhtml +1 -0
- data/app/views/tasks/new.rhtml +2 -2
- data/app/views/works/_buttons.rhtml +3 -0
- data/app/views/works/_form.rhtml +15 -10
- data/app/views/works/daily_work_sheet.rhtml +30 -18
- data/app/views/works/edit.rhtml +4 -4
- data/app/views/works/list.rhtml +2 -2
- data/app/views/works/new.rhtml +3 -2
- data/app/views/works/weekly_work_sheet.rhtml +2 -2
- data/bin/backlog +2 -0
- data/bin/backlog_init.d_kubosch_production +27 -0
- data/bin/copy_production2development.rb +33 -0
- data/config/database.yml +13 -7
- data/config/deploy_kubosch.rb +1 -0
- data/config/environment.rb +2 -0
- data/config/environments/development_mysql.rb +27 -0
- data/config/environments/kubosch_production_mysql.rb +21 -0
- data/config/routes.rb +1 -1
- data/db/migrate/{001_tasks.rb → 001_create_tasks.rb} +1 -1
- data/db/migrate/{002_backlogs.rb → 002_create_backlogs.rb} +2 -2
- data/db/migrate/003_add_estimation_points.rb +1 -1
- data/db/migrate/004_add_period.rb +2 -2
- data/db/migrate/013_create_estimates.rb +1 -1
- data/db/migrate/015_add_user_option.rb +9 -5
- data/db/migrate/017_insert_datek_projects.rb +13 -10
- data/db/migrate/018_create_groups.rb +115 -0
- data/db/schema.rb +72 -12
- data/lang/en.yaml +7 -0
- data/lang/no.yaml +7 -0
- data/lib/big_decimal_yaml_fix.rb +27 -0
- data/lib/class_table_inheritance.rb +163 -0
- data/lib/tasks/backup.rake +92 -0
- data/public/images/person.org.png +0 -0
- data/public/images/person.png +0 -0
- data/public/stylesheets/backlog.css +3 -1
- data/public/stylesheets/mwrt002.css +1 -1
- data/test/fixtures/groups.yml +6 -0
- data/test/fixtures/parties.yml +31 -0
- data/test/fixtures/periods.yml +2 -2
- data/test/fixtures/tasks.yml +2 -0
- data/test/fixtures/users.yml +6 -6
- data/test/functional/backlogs_controller_test.rb +1 -1
- data/test/functional/groups_controller_test.rb +120 -0
- data/test/functional/periods_controller_test.rb +1 -1
- data/test/functional/tasks_controller_test.rb +16 -1
- data/test/functional/user_controller_test.rb +8 -2
- data/test/test_helper.rb +5 -0
- data/test/unit/big_decimal_yaml_fix_test.rb +14 -0
- data/test/unit/estimate_test.rb +1 -1
- data/test/unit/group_test.rb +10 -0
- data/test/unit/user_test.rb +56 -44
- data/tmp/sessions/ruby_sess.22dec3e9df47fb4e +0 -0
- data/tmp/sessions/ruby_sess.8037e0ab58cbcf1a +0 -0
- data/vendor/plugins/activerecord_foreign_key_extensions/lib/active_record_extensions.rb +35 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.rhtml.bak +1 -0
- data/vendor/rails/{actionwebservice/lib/action_web_service/templates/scaffolds/layout.rhtml → railties/configs/empty.log} +0 -0
- metadata +36 -105
- data/backlog.gemspec +0 -21
- data/vendor/rails/actionwebservice/CHANGELOG +0 -265
- data/vendor/rails/actionwebservice/MIT-LICENSE +0 -21
- data/vendor/rails/actionwebservice/README +0 -364
- data/vendor/rails/actionwebservice/Rakefile +0 -171
- data/vendor/rails/actionwebservice/TODO +0 -32
- data/vendor/rails/actionwebservice/examples/googlesearch/README +0 -143
- data/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_api.rb +0 -50
- data/vendor/rails/actionwebservice/examples/googlesearch/autoloading/google_search_controller.rb +0 -57
- data/vendor/rails/actionwebservice/examples/googlesearch/delegated/google_search_service.rb +0 -108
- data/vendor/rails/actionwebservice/examples/googlesearch/delegated/search_controller.rb +0 -7
- data/vendor/rails/actionwebservice/examples/googlesearch/direct/google_search_api.rb +0 -50
- data/vendor/rails/actionwebservice/examples/googlesearch/direct/search_controller.rb +0 -58
- data/vendor/rails/actionwebservice/examples/metaWeblog/README +0 -17
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_api.rb +0 -60
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/blogger_service.rb +0 -34
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_api.rb +0 -67
- data/vendor/rails/actionwebservice/examples/metaWeblog/apis/meta_weblog_service.rb +0 -48
- data/vendor/rails/actionwebservice/examples/metaWeblog/controllers/xmlrpc_controller.rb +0 -16
- data/vendor/rails/actionwebservice/install.rb +0 -30
- data/vendor/rails/actionwebservice/lib/action_web_service.rb +0 -66
- data/vendor/rails/actionwebservice/lib/action_web_service/api.rb +0 -301
- data/vendor/rails/actionwebservice/lib/action_web_service/base.rb +0 -42
- data/vendor/rails/actionwebservice/lib/action_web_service/casting.rb +0 -138
- data/vendor/rails/actionwebservice/lib/action_web_service/client.rb +0 -3
- data/vendor/rails/actionwebservice/lib/action_web_service/client/base.rb +0 -28
- data/vendor/rails/actionwebservice/lib/action_web_service/client/soap_client.rb +0 -113
- data/vendor/rails/actionwebservice/lib/action_web_service/client/xmlrpc_client.rb +0 -58
- data/vendor/rails/actionwebservice/lib/action_web_service/container.rb +0 -3
- data/vendor/rails/actionwebservice/lib/action_web_service/container/action_controller_container.rb +0 -93
- data/vendor/rails/actionwebservice/lib/action_web_service/container/delegated_container.rb +0 -86
- data/vendor/rails/actionwebservice/lib/action_web_service/container/direct_container.rb +0 -69
- data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher.rb +0 -2
- data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/abstract.rb +0 -207
- data/vendor/rails/actionwebservice/lib/action_web_service/dispatcher/action_controller_dispatcher.rb +0 -379
- data/vendor/rails/actionwebservice/lib/action_web_service/invocation.rb +0 -202
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol.rb +0 -4
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/abstract.rb +0 -112
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/discovery.rb +0 -37
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol.rb +0 -176
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/soap_protocol/marshaler.rb +0 -235
- data/vendor/rails/actionwebservice/lib/action_web_service/protocol/xmlrpc_protocol.rb +0 -122
- data/vendor/rails/actionwebservice/lib/action_web_service/scaffolding.rb +0 -283
- data/vendor/rails/actionwebservice/lib/action_web_service/struct.rb +0 -68
- data/vendor/rails/actionwebservice/lib/action_web_service/support/class_inheritable_options.rb +0 -26
- data/vendor/rails/actionwebservice/lib/action_web_service/support/signature_types.rb +0 -226
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/layout.erb +0 -65
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/methods.erb +0 -6
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/methods.rhtml +0 -0
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.erb +0 -29
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/parameters.rhtml +0 -0
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/result.erb +0 -30
- data/vendor/rails/actionwebservice/lib/action_web_service/templates/scaffolds/result.rhtml +0 -0
- data/vendor/rails/actionwebservice/lib/action_web_service/test_invoke.rb +0 -110
- data/vendor/rails/actionwebservice/lib/action_web_service/version.rb +0 -9
- data/vendor/rails/actionwebservice/setup.rb +0 -1379
- data/vendor/rails/actionwebservice/test/abstract_client.rb +0 -183
- data/vendor/rails/actionwebservice/test/abstract_dispatcher.rb +0 -551
- data/vendor/rails/actionwebservice/test/abstract_unit.rb +0 -45
- data/vendor/rails/actionwebservice/test/api_test.rb +0 -102
- data/vendor/rails/actionwebservice/test/apis/auto_load_api.rb +0 -3
- data/vendor/rails/actionwebservice/test/apis/broken_auto_load_api.rb +0 -2
- data/vendor/rails/actionwebservice/test/base_test.rb +0 -42
- data/vendor/rails/actionwebservice/test/casting_test.rb +0 -86
- data/vendor/rails/actionwebservice/test/client_soap_test.rb +0 -153
- data/vendor/rails/actionwebservice/test/client_xmlrpc_test.rb +0 -152
- data/vendor/rails/actionwebservice/test/container_test.rb +0 -73
- data/vendor/rails/actionwebservice/test/dispatcher_action_controller_soap_test.rb +0 -137
- data/vendor/rails/actionwebservice/test/dispatcher_action_controller_xmlrpc_test.rb +0 -59
- data/vendor/rails/actionwebservice/test/fixtures/db_definitions/mysql.sql +0 -8
- data/vendor/rails/actionwebservice/test/fixtures/users.yml +0 -12
- data/vendor/rails/actionwebservice/test/gencov +0 -3
- data/vendor/rails/actionwebservice/test/invocation_test.rb +0 -185
- data/vendor/rails/actionwebservice/test/run +0 -6
- data/vendor/rails/actionwebservice/test/scaffolded_controller_test.rb +0 -146
- data/vendor/rails/actionwebservice/test/struct_test.rb +0 -52
- data/vendor/rails/actionwebservice/test/test_invoke_test.rb +0 -112
@@ -1,183 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/abstract_unit'
|
2
|
-
require 'webrick'
|
3
|
-
require 'webrick/log'
|
4
|
-
require 'singleton'
|
5
|
-
|
6
|
-
module ClientTest
|
7
|
-
class Person < ActionWebService::Struct
|
8
|
-
member :firstnames, [:string]
|
9
|
-
member :lastname, :string
|
10
|
-
|
11
|
-
def ==(other)
|
12
|
-
firstnames == other.firstnames && lastname == other.lastname
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Inner < ActionWebService::Struct
|
17
|
-
member :name, :string
|
18
|
-
end
|
19
|
-
|
20
|
-
class Outer < ActionWebService::Struct
|
21
|
-
member :name, :string
|
22
|
-
member :inner, Inner
|
23
|
-
end
|
24
|
-
|
25
|
-
class User < ActiveRecord::Base
|
26
|
-
end
|
27
|
-
|
28
|
-
module Accounting
|
29
|
-
class User < ActiveRecord::Base
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class WithModel < ActionWebService::Struct
|
34
|
-
member :user, User
|
35
|
-
member :users, [User]
|
36
|
-
end
|
37
|
-
|
38
|
-
class WithMultiDimArray < ActionWebService::Struct
|
39
|
-
member :pref, [[:string]]
|
40
|
-
end
|
41
|
-
|
42
|
-
class API < ActionWebService::API::Base
|
43
|
-
api_method :void
|
44
|
-
api_method :normal, :expects => [:int, :int], :returns => [:int]
|
45
|
-
api_method :array_return, :returns => [[Person]]
|
46
|
-
api_method :struct_pass, :expects => [[Person]], :returns => [:bool]
|
47
|
-
api_method :nil_struct_return, :returns => [Person]
|
48
|
-
api_method :inner_nil, :returns => [Outer]
|
49
|
-
api_method :client_container, :returns => [:int]
|
50
|
-
api_method :named_parameters, :expects => [{:key=>:string}, {:id=>:int}]
|
51
|
-
api_method :thrower
|
52
|
-
api_method :user_return, :returns => [User]
|
53
|
-
api_method :with_model_return, :returns => [WithModel]
|
54
|
-
api_method :scoped_model_return, :returns => [Accounting::User]
|
55
|
-
api_method :multi_dim_return, :returns => [WithMultiDimArray]
|
56
|
-
end
|
57
|
-
|
58
|
-
class NullLogOut
|
59
|
-
def <<(*args); end
|
60
|
-
end
|
61
|
-
|
62
|
-
class Container < ActionController::Base
|
63
|
-
web_service_api API
|
64
|
-
|
65
|
-
attr_accessor :value_void
|
66
|
-
attr_accessor :value_normal
|
67
|
-
attr_accessor :value_array_return
|
68
|
-
attr_accessor :value_struct_pass
|
69
|
-
attr_accessor :value_named_parameters
|
70
|
-
|
71
|
-
def initialize
|
72
|
-
@value_void = nil
|
73
|
-
@value_normal = nil
|
74
|
-
@value_array_return = nil
|
75
|
-
@value_struct_pass = nil
|
76
|
-
@value_named_parameters = nil
|
77
|
-
end
|
78
|
-
|
79
|
-
def void
|
80
|
-
@value_void = @method_params
|
81
|
-
end
|
82
|
-
|
83
|
-
def normal
|
84
|
-
@value_normal = @method_params
|
85
|
-
5
|
86
|
-
end
|
87
|
-
|
88
|
-
def array_return
|
89
|
-
person = Person.new
|
90
|
-
person.firstnames = ["one", "two"]
|
91
|
-
person.lastname = "last"
|
92
|
-
@value_array_return = [person]
|
93
|
-
end
|
94
|
-
|
95
|
-
def struct_pass
|
96
|
-
@value_struct_pass = @method_params
|
97
|
-
true
|
98
|
-
end
|
99
|
-
|
100
|
-
def nil_struct_return
|
101
|
-
nil
|
102
|
-
end
|
103
|
-
|
104
|
-
def inner_nil
|
105
|
-
Outer.new :name => 'outer', :inner => nil
|
106
|
-
end
|
107
|
-
|
108
|
-
def client_container
|
109
|
-
50
|
110
|
-
end
|
111
|
-
|
112
|
-
def named_parameters
|
113
|
-
@value_named_parameters = @method_params
|
114
|
-
end
|
115
|
-
|
116
|
-
def thrower
|
117
|
-
raise "Hi"
|
118
|
-
end
|
119
|
-
|
120
|
-
def user_return
|
121
|
-
User.find(1)
|
122
|
-
end
|
123
|
-
|
124
|
-
def with_model_return
|
125
|
-
WithModel.new :user => User.find(1), :users => User.find(:all)
|
126
|
-
end
|
127
|
-
|
128
|
-
def scoped_model_return
|
129
|
-
Accounting::User.find(1)
|
130
|
-
end
|
131
|
-
|
132
|
-
def multi_dim_return
|
133
|
-
WithMultiDimArray.new :pref => [%w{pref1 value1}, %w{pref2 value2}]
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
class AbstractClientLet < WEBrick::HTTPServlet::AbstractServlet
|
138
|
-
def initialize(controller)
|
139
|
-
@controller = controller
|
140
|
-
end
|
141
|
-
|
142
|
-
def get_instance(*args)
|
143
|
-
self
|
144
|
-
end
|
145
|
-
|
146
|
-
def require_path_info?
|
147
|
-
false
|
148
|
-
end
|
149
|
-
|
150
|
-
def do_GET(req, res)
|
151
|
-
raise WEBrick::HTTPStatus::MethodNotAllowed, "GET request not allowed."
|
152
|
-
end
|
153
|
-
|
154
|
-
def do_POST(req, res)
|
155
|
-
raise NotImplementedError
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
class AbstractServer
|
160
|
-
include ClientTest
|
161
|
-
include Singleton
|
162
|
-
attr :container
|
163
|
-
def initialize
|
164
|
-
@container = Container.new
|
165
|
-
@clientlet = create_clientlet(@container)
|
166
|
-
log = WEBrick::BasicLog.new(NullLogOut.new)
|
167
|
-
@server = WEBrick::HTTPServer.new(:Port => server_port, :Logger => log, :AccessLog => log)
|
168
|
-
@server.mount('/', @clientlet)
|
169
|
-
@thr = Thread.new { @server.start }
|
170
|
-
until @server.status == :Running; end
|
171
|
-
at_exit { @server.stop; @thr.join }
|
172
|
-
end
|
173
|
-
|
174
|
-
protected
|
175
|
-
def create_clientlet
|
176
|
-
raise NotImplementedError
|
177
|
-
end
|
178
|
-
|
179
|
-
def server_port
|
180
|
-
raise NotImplementedError
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
@@ -1,551 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/abstract_unit'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
class ActionController::Base; def rescue_action(e) raise e end; end
|
5
|
-
|
6
|
-
module DispatcherTest
|
7
|
-
Utf8String = "One World Caf\303\251"
|
8
|
-
WsdlNamespace = 'http://rubyonrails.com/some/namespace'
|
9
|
-
|
10
|
-
class Node < ActiveRecord::Base
|
11
|
-
def initialize(*args)
|
12
|
-
super(*args)
|
13
|
-
@new_record = false
|
14
|
-
end
|
15
|
-
|
16
|
-
class << self
|
17
|
-
def name
|
18
|
-
"DispatcherTest::Node"
|
19
|
-
end
|
20
|
-
|
21
|
-
def columns(*args)
|
22
|
-
[
|
23
|
-
ActiveRecord::ConnectionAdapters::Column.new('id', 0, 'int'),
|
24
|
-
ActiveRecord::ConnectionAdapters::Column.new('name', nil, 'string'),
|
25
|
-
ActiveRecord::ConnectionAdapters::Column.new('description', nil, 'string'),
|
26
|
-
]
|
27
|
-
end
|
28
|
-
|
29
|
-
def connection
|
30
|
-
self
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Person < ActionWebService::Struct
|
36
|
-
member :id, :int
|
37
|
-
member :name, :string
|
38
|
-
|
39
|
-
def ==(other)
|
40
|
-
self.id == other.id && self.name == other.name
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class API < ActionWebService::API::Base
|
45
|
-
api_method :add, :expects => [:int, :int], :returns => [:int]
|
46
|
-
api_method :interceptee
|
47
|
-
api_method :struct_return, :returns => [[Node]]
|
48
|
-
api_method :void
|
49
|
-
end
|
50
|
-
|
51
|
-
class DirectAPI < ActionWebService::API::Base
|
52
|
-
api_method :add, :expects => [{:a=>:int}, {:b=>:int}], :returns => [:int]
|
53
|
-
api_method :add2, :expects => [{:a=>:int}, {:b=>:int}], :returns => [:int]
|
54
|
-
api_method :before_filtered
|
55
|
-
api_method :after_filtered, :returns => [[:int]]
|
56
|
-
api_method :struct_return, :returns => [[Node]]
|
57
|
-
api_method :struct_pass, :expects => [{:person => Person}]
|
58
|
-
api_method :base_struct_return, :returns => [[Person]]
|
59
|
-
api_method :hash_struct_return, :returns => [[Person]]
|
60
|
-
api_method :thrower
|
61
|
-
api_method :void
|
62
|
-
api_method :test_utf8, :returns => [:string]
|
63
|
-
api_method :hex, :expects => [:base64], :returns => [:string]
|
64
|
-
api_method :unhex, :expects => [:string], :returns => [:base64]
|
65
|
-
api_method :time, :expects => [:time], :returns => [:time]
|
66
|
-
end
|
67
|
-
|
68
|
-
class VirtualAPI < ActionWebService::API::Base
|
69
|
-
default_api_method :fallback
|
70
|
-
end
|
71
|
-
|
72
|
-
class Service < ActionWebService::Base
|
73
|
-
web_service_api API
|
74
|
-
|
75
|
-
before_invocation :do_intercept, :only => [:interceptee]
|
76
|
-
|
77
|
-
attr :added
|
78
|
-
attr :intercepted
|
79
|
-
attr :void_called
|
80
|
-
|
81
|
-
def initialize
|
82
|
-
@void_called = false
|
83
|
-
end
|
84
|
-
|
85
|
-
def add(a, b)
|
86
|
-
@added = a + b
|
87
|
-
end
|
88
|
-
|
89
|
-
def interceptee
|
90
|
-
@intercepted = false
|
91
|
-
end
|
92
|
-
|
93
|
-
def struct_return
|
94
|
-
n1 = Node.new('id' => 1, 'name' => 'node1', 'description' => 'Node 1')
|
95
|
-
n2 = Node.new('id' => 2, 'name' => 'node2', 'description' => 'Node 2')
|
96
|
-
[n1, n2]
|
97
|
-
end
|
98
|
-
|
99
|
-
def void(*args)
|
100
|
-
@void_called = args
|
101
|
-
end
|
102
|
-
|
103
|
-
def do_intercept(name, args)
|
104
|
-
[false, "permission denied"]
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
class MTAPI < ActionWebService::API::Base
|
109
|
-
inflect_names false
|
110
|
-
api_method :getCategories, :returns => [[:string]]
|
111
|
-
api_method :bool, :returns => [:bool]
|
112
|
-
api_method :alwaysFail
|
113
|
-
api_method :person, :returns => [Person]
|
114
|
-
end
|
115
|
-
|
116
|
-
class BloggerAPI < ActionWebService::API::Base
|
117
|
-
inflect_names false
|
118
|
-
api_method :getCategories, :returns => [[:string]]
|
119
|
-
api_method :str, :expects => [:int], :returns => [:string]
|
120
|
-
api_method :alwaysFail
|
121
|
-
end
|
122
|
-
|
123
|
-
class MTService < ActionWebService::Base
|
124
|
-
web_service_api MTAPI
|
125
|
-
|
126
|
-
def getCategories
|
127
|
-
["mtCat1", "mtCat2"]
|
128
|
-
end
|
129
|
-
|
130
|
-
def bool
|
131
|
-
'y'
|
132
|
-
end
|
133
|
-
|
134
|
-
def alwaysFail
|
135
|
-
raise "MT AlwaysFail"
|
136
|
-
end
|
137
|
-
|
138
|
-
def person
|
139
|
-
Person.new('id' => 1, 'name' => 'person1')
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
class BloggerService < ActionWebService::Base
|
144
|
-
web_service_api BloggerAPI
|
145
|
-
|
146
|
-
def getCategories
|
147
|
-
["bloggerCat1", "bloggerCat2"]
|
148
|
-
end
|
149
|
-
|
150
|
-
def str(int)
|
151
|
-
unless int.is_a?(Integer)
|
152
|
-
raise "Not an integer!"
|
153
|
-
end
|
154
|
-
500 + int
|
155
|
-
end
|
156
|
-
|
157
|
-
def alwaysFail
|
158
|
-
raise "Blogger AlwaysFail"
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
class AbstractController < ActionController::Base
|
163
|
-
def generate_wsdl
|
164
|
-
self.request ||= ::ActionController::TestRequest.new
|
165
|
-
to_wsdl
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
class DelegatedController < AbstractController
|
170
|
-
web_service_dispatching_mode :delegated
|
171
|
-
wsdl_namespace WsdlNamespace
|
172
|
-
|
173
|
-
web_service(:test_service) { @service ||= Service.new; @service }
|
174
|
-
end
|
175
|
-
|
176
|
-
class LayeredController < AbstractController
|
177
|
-
web_service_dispatching_mode :layered
|
178
|
-
wsdl_namespace WsdlNamespace
|
179
|
-
|
180
|
-
web_service(:mt) { @mt_service ||= MTService.new; @mt_service }
|
181
|
-
web_service(:blogger) { @blogger_service ||= BloggerService.new; @blogger_service }
|
182
|
-
end
|
183
|
-
|
184
|
-
class DirectController < AbstractController
|
185
|
-
web_service_api DirectAPI
|
186
|
-
web_service_dispatching_mode :direct
|
187
|
-
wsdl_namespace WsdlNamespace
|
188
|
-
|
189
|
-
before_invocation :alwaysfail, :only => [:before_filtered]
|
190
|
-
after_invocation :alwaysok, :only => [:after_filtered]
|
191
|
-
|
192
|
-
attr :added
|
193
|
-
attr :added2
|
194
|
-
attr :before_filter_called
|
195
|
-
attr :before_filter_target_called
|
196
|
-
attr :after_filter_called
|
197
|
-
attr :after_filter_target_called
|
198
|
-
attr :void_called
|
199
|
-
attr :struct_pass_value
|
200
|
-
|
201
|
-
def initialize
|
202
|
-
@before_filter_called = false
|
203
|
-
@before_filter_target_called = false
|
204
|
-
@after_filter_called = false
|
205
|
-
@after_filter_target_called = false
|
206
|
-
@void_called = false
|
207
|
-
@struct_pass_value = false
|
208
|
-
end
|
209
|
-
|
210
|
-
def add
|
211
|
-
@added = params['a'] + params['b']
|
212
|
-
end
|
213
|
-
|
214
|
-
def add2(a, b)
|
215
|
-
@added2 = a + b
|
216
|
-
end
|
217
|
-
|
218
|
-
def before_filtered
|
219
|
-
@before_filter_target_called = true
|
220
|
-
end
|
221
|
-
|
222
|
-
def after_filtered
|
223
|
-
@after_filter_target_called = true
|
224
|
-
[5, 6, 7]
|
225
|
-
end
|
226
|
-
|
227
|
-
def thrower
|
228
|
-
raise "Hi, I'm an exception"
|
229
|
-
end
|
230
|
-
|
231
|
-
def struct_return
|
232
|
-
n1 = Node.new('id' => 1, 'name' => 'node1', 'description' => 'Node 1')
|
233
|
-
n2 = Node.new('id' => 2, 'name' => 'node2', 'description' => 'Node 2')
|
234
|
-
[n1, n2]
|
235
|
-
end
|
236
|
-
|
237
|
-
def struct_pass(person)
|
238
|
-
@struct_pass_value = person
|
239
|
-
end
|
240
|
-
|
241
|
-
def base_struct_return
|
242
|
-
p1 = Person.new('id' => 1, 'name' => 'person1')
|
243
|
-
p2 = Person.new('id' => 2, 'name' => 'person2')
|
244
|
-
[p1, p2]
|
245
|
-
end
|
246
|
-
|
247
|
-
def hash_struct_return
|
248
|
-
p1 = { :id => '1', 'name' => 'test' }
|
249
|
-
p2 = { 'id' => '2', :name => 'person2' }
|
250
|
-
[p1, p2]
|
251
|
-
end
|
252
|
-
|
253
|
-
def void
|
254
|
-
@void_called = @method_params
|
255
|
-
end
|
256
|
-
|
257
|
-
def test_utf8
|
258
|
-
Utf8String
|
259
|
-
end
|
260
|
-
|
261
|
-
def hex(s)
|
262
|
-
return s.unpack("H*")[0]
|
263
|
-
end
|
264
|
-
|
265
|
-
def unhex(s)
|
266
|
-
return [s].pack("H*")
|
267
|
-
end
|
268
|
-
|
269
|
-
def time(t)
|
270
|
-
t
|
271
|
-
end
|
272
|
-
|
273
|
-
protected
|
274
|
-
def alwaysfail(method_name, params)
|
275
|
-
@before_filter_called = true
|
276
|
-
false
|
277
|
-
end
|
278
|
-
|
279
|
-
def alwaysok(method_name, params, return_value)
|
280
|
-
@after_filter_called = true
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
class VirtualController < AbstractController
|
285
|
-
web_service_api VirtualAPI
|
286
|
-
wsdl_namespace WsdlNamespace
|
287
|
-
|
288
|
-
def fallback
|
289
|
-
"fallback!"
|
290
|
-
end
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
module DispatcherCommonTests
|
295
|
-
def test_direct_dispatching
|
296
|
-
assert_equal(70, do_method_call(@direct_controller, 'Add', 20, 50))
|
297
|
-
assert_equal(70, @direct_controller.added)
|
298
|
-
assert_equal(50, do_method_call(@direct_controller, 'Add2', 25, 25))
|
299
|
-
assert_equal(50, @direct_controller.added2)
|
300
|
-
assert(@direct_controller.void_called == false)
|
301
|
-
assert(do_method_call(@direct_controller, 'Void', 3, 4, 5).nil?)
|
302
|
-
assert(@direct_controller.void_called == [])
|
303
|
-
result = do_method_call(@direct_controller, 'BaseStructReturn')
|
304
|
-
assert(result[0].is_a?(DispatcherTest::Person))
|
305
|
-
assert(result[1].is_a?(DispatcherTest::Person))
|
306
|
-
assert_equal("cafe", do_method_call(@direct_controller, 'Hex', "\xca\xfe"))
|
307
|
-
assert_equal("\xca\xfe", do_method_call(@direct_controller, 'Unhex', "cafe"))
|
308
|
-
time = Time.gm(1998, "Feb", 02, 15, 12, 01)
|
309
|
-
assert_equal(time, do_method_call(@direct_controller, 'Time', time))
|
310
|
-
end
|
311
|
-
|
312
|
-
def test_direct_entrypoint
|
313
|
-
assert(@direct_controller.respond_to?(:api))
|
314
|
-
end
|
315
|
-
|
316
|
-
def test_virtual_dispatching
|
317
|
-
assert_equal("fallback!", do_method_call(@virtual_controller, 'VirtualOne'))
|
318
|
-
assert_equal("fallback!", do_method_call(@virtual_controller, 'VirtualTwo'))
|
319
|
-
end
|
320
|
-
|
321
|
-
def test_direct_filtering
|
322
|
-
assert_equal(false, @direct_controller.before_filter_called)
|
323
|
-
assert_equal(false, @direct_controller.before_filter_target_called)
|
324
|
-
do_method_call(@direct_controller, 'BeforeFiltered')
|
325
|
-
assert_equal(true, @direct_controller.before_filter_called)
|
326
|
-
assert_equal(false, @direct_controller.before_filter_target_called)
|
327
|
-
assert_equal(false, @direct_controller.after_filter_called)
|
328
|
-
assert_equal(false, @direct_controller.after_filter_target_called)
|
329
|
-
assert_equal([5, 6, 7], do_method_call(@direct_controller, 'AfterFiltered'))
|
330
|
-
assert_equal(true, @direct_controller.after_filter_called)
|
331
|
-
assert_equal(true, @direct_controller.after_filter_target_called)
|
332
|
-
end
|
333
|
-
|
334
|
-
def test_delegated_dispatching
|
335
|
-
assert_equal(130, do_method_call(@delegated_controller, 'Add', 50, 80))
|
336
|
-
service = @delegated_controller.web_service_object(:test_service)
|
337
|
-
assert_equal(130, service.added)
|
338
|
-
@delegated_controller.web_service_exception_reporting = true
|
339
|
-
assert(service.intercepted.nil?)
|
340
|
-
result = do_method_call(@delegated_controller, 'Interceptee')
|
341
|
-
assert(service.intercepted.nil?)
|
342
|
-
assert(is_exception?(result))
|
343
|
-
assert_match(/permission denied/, exception_message(result))
|
344
|
-
result = do_method_call(@delegated_controller, 'NonExistentMethod')
|
345
|
-
assert(is_exception?(result))
|
346
|
-
assert_match(/NonExistentMethod/, exception_message(result))
|
347
|
-
assert(service.void_called == false)
|
348
|
-
assert(do_method_call(@delegated_controller, 'Void', 3, 4, 5).nil?)
|
349
|
-
assert(service.void_called == [])
|
350
|
-
end
|
351
|
-
|
352
|
-
def test_garbage_request
|
353
|
-
[@direct_controller, @delegated_controller].each do |controller|
|
354
|
-
controller.class.web_service_exception_reporting = true
|
355
|
-
send_garbage_request = lambda do
|
356
|
-
service_name = service_name(controller)
|
357
|
-
request = protocol.encode_action_pack_request(service_name, 'broken, method, name!', 'broken request body', :request_class => ActionController::TestRequest)
|
358
|
-
response = ActionController::TestResponse.new
|
359
|
-
controller.process(request, response)
|
360
|
-
# puts response.body
|
361
|
-
assert(response.headers['Status'] =~ /^500/)
|
362
|
-
end
|
363
|
-
send_garbage_request.call
|
364
|
-
controller.class.web_service_exception_reporting = false
|
365
|
-
send_garbage_request.call
|
366
|
-
end
|
367
|
-
end
|
368
|
-
|
369
|
-
def test_exception_marshaling
|
370
|
-
@direct_controller.web_service_exception_reporting = true
|
371
|
-
result = do_method_call(@direct_controller, 'Thrower')
|
372
|
-
assert(is_exception?(result))
|
373
|
-
assert_equal("Hi, I'm an exception", exception_message(result))
|
374
|
-
@direct_controller.web_service_exception_reporting = false
|
375
|
-
result = do_method_call(@direct_controller, 'Thrower')
|
376
|
-
assert(exception_message(result) != "Hi, I'm an exception")
|
377
|
-
end
|
378
|
-
|
379
|
-
def test_ar_struct_return
|
380
|
-
[@direct_controller, @delegated_controller].each do |controller|
|
381
|
-
result = do_method_call(controller, 'StructReturn')
|
382
|
-
assert(result[0].is_a?(DispatcherTest::Node))
|
383
|
-
assert(result[1].is_a?(DispatcherTest::Node))
|
384
|
-
assert_equal('node1', result[0].name)
|
385
|
-
assert_equal('node2', result[1].name)
|
386
|
-
end
|
387
|
-
end
|
388
|
-
|
389
|
-
def test_casting
|
390
|
-
assert_equal 70, do_method_call(@direct_controller, 'Add', "50", "20")
|
391
|
-
assert_equal false, @direct_controller.struct_pass_value
|
392
|
-
person = DispatcherTest::Person.new(:id => 1, :name => 'test')
|
393
|
-
result = do_method_call(@direct_controller, 'StructPass', person)
|
394
|
-
assert(nil == result || true == result)
|
395
|
-
assert_equal person, @direct_controller.struct_pass_value
|
396
|
-
assert !person.equal?(@direct_controller.struct_pass_value)
|
397
|
-
result = do_method_call(@direct_controller, 'StructPass', {'id' => '1', 'name' => 'test'})
|
398
|
-
case
|
399
|
-
when soap?
|
400
|
-
assert_equal(person, @direct_controller.struct_pass_value)
|
401
|
-
assert !person.equal?(@direct_controller.struct_pass_value)
|
402
|
-
when xmlrpc?
|
403
|
-
assert_equal(person, @direct_controller.struct_pass_value)
|
404
|
-
assert !person.equal?(@direct_controller.struct_pass_value)
|
405
|
-
end
|
406
|
-
assert_equal person, do_method_call(@direct_controller, 'HashStructReturn')[0]
|
407
|
-
result = do_method_call(@direct_controller, 'StructPass', {'id' => '1', 'name' => 'test', 'nonexistent_attribute' => 'value'})
|
408
|
-
case
|
409
|
-
when soap?
|
410
|
-
assert_equal(person, @direct_controller.struct_pass_value)
|
411
|
-
assert !person.equal?(@direct_controller.struct_pass_value)
|
412
|
-
when xmlrpc?
|
413
|
-
assert_equal(person, @direct_controller.struct_pass_value)
|
414
|
-
assert !person.equal?(@direct_controller.struct_pass_value)
|
415
|
-
end
|
416
|
-
end
|
417
|
-
|
418
|
-
def test_logging
|
419
|
-
buf = ""
|
420
|
-
ActionController::Base.logger = Logger.new(StringIO.new(buf))
|
421
|
-
test_casting
|
422
|
-
test_garbage_request
|
423
|
-
test_exception_marshaling
|
424
|
-
ActionController::Base.logger = nil
|
425
|
-
assert_match /Web Service Response/, buf
|
426
|
-
assert_match /Web Service Request/, buf
|
427
|
-
end
|
428
|
-
|
429
|
-
def test_allowed_http_methods
|
430
|
-
webservice_api = @direct_controller.class.web_service_api
|
431
|
-
original_allowed_http_methods = webservice_api.allowed_http_methods
|
432
|
-
|
433
|
-
# check defaults
|
434
|
-
assert_equal false, http_method_allowed?(:get)
|
435
|
-
assert_equal false, http_method_allowed?(:head)
|
436
|
-
assert_equal false, http_method_allowed?(:put)
|
437
|
-
assert_equal false, http_method_allowed?(:delete)
|
438
|
-
assert_equal false, http_method_allowed?(:trace)
|
439
|
-
assert_equal false, http_method_allowed?(:connect)
|
440
|
-
assert_equal true, http_method_allowed?(:post)
|
441
|
-
|
442
|
-
# allow get and post
|
443
|
-
webservice_api.allowed_http_methods = [ :get, :post ]
|
444
|
-
assert_equal true, http_method_allowed?(:get)
|
445
|
-
assert_equal true, http_method_allowed?(:post)
|
446
|
-
|
447
|
-
# allow get only
|
448
|
-
webservice_api.allowed_http_methods = [ :get ]
|
449
|
-
assert_equal true, http_method_allowed?(:get)
|
450
|
-
assert_equal false, http_method_allowed?(:post)
|
451
|
-
|
452
|
-
# allow delete only
|
453
|
-
webservice_api.allowed_http_methods = [ 'DELETE' ]
|
454
|
-
assert_equal false, http_method_allowed?(:get)
|
455
|
-
assert_equal false, http_method_allowed?(:head)
|
456
|
-
assert_equal false, http_method_allowed?(:post)
|
457
|
-
assert_equal false, http_method_allowed?(:put)
|
458
|
-
assert_equal false, http_method_allowed?(:trace)
|
459
|
-
assert_equal false, http_method_allowed?(:connect)
|
460
|
-
assert_equal true, http_method_allowed?(:delete)
|
461
|
-
|
462
|
-
ensure
|
463
|
-
webservice_api.allowed_http_methods = original_allowed_http_methods
|
464
|
-
end
|
465
|
-
|
466
|
-
protected
|
467
|
-
def service_name(container)
|
468
|
-
raise NotImplementedError
|
469
|
-
end
|
470
|
-
|
471
|
-
def exception_message(obj)
|
472
|
-
raise NotImplementedError
|
473
|
-
end
|
474
|
-
|
475
|
-
def is_exception?(obj)
|
476
|
-
raise NotImplementedError
|
477
|
-
end
|
478
|
-
|
479
|
-
def protocol
|
480
|
-
@protocol
|
481
|
-
end
|
482
|
-
|
483
|
-
def soap?
|
484
|
-
protocol.is_a? ActionWebService::Protocol::Soap::SoapProtocol
|
485
|
-
end
|
486
|
-
|
487
|
-
def xmlrpc?
|
488
|
-
protocol.is_a? ActionWebService::Protocol::XmlRpc::XmlRpcProtocol
|
489
|
-
end
|
490
|
-
|
491
|
-
def do_method_call(container, public_method_name, *params)
|
492
|
-
request_env = {}
|
493
|
-
mode = container.web_service_dispatching_mode
|
494
|
-
case mode
|
495
|
-
when :direct
|
496
|
-
service_name = service_name(container)
|
497
|
-
api = container.class.web_service_api
|
498
|
-
method = api.public_api_method_instance(public_method_name)
|
499
|
-
when :delegated
|
500
|
-
service_name = service_name(container)
|
501
|
-
api = container.web_service_object(service_name).class.web_service_api
|
502
|
-
method = api.public_api_method_instance(public_method_name)
|
503
|
-
when :layered
|
504
|
-
service_name = nil
|
505
|
-
real_method_name = nil
|
506
|
-
if public_method_name =~ /^([^\.]+)\.(.*)$/
|
507
|
-
service_name = $1
|
508
|
-
real_method_name = $2
|
509
|
-
end
|
510
|
-
if soap?
|
511
|
-
public_method_name = real_method_name
|
512
|
-
request_env['HTTP_SOAPACTION'] = "/soap/#{service_name}/#{real_method_name}"
|
513
|
-
end
|
514
|
-
api = container.web_service_object(service_name.to_sym).class.web_service_api rescue nil
|
515
|
-
method = api.public_api_method_instance(real_method_name) rescue nil
|
516
|
-
service_name = self.service_name(container)
|
517
|
-
end
|
518
|
-
protocol.register_api(api)
|
519
|
-
virtual = false
|
520
|
-
unless method
|
521
|
-
virtual = true
|
522
|
-
method ||= ActionWebService::API::Method.new(public_method_name.underscore.to_sym, public_method_name, nil, nil)
|
523
|
-
end
|
524
|
-
body = protocol.encode_request(public_method_name, params.dup, method.expects)
|
525
|
-
# puts body
|
526
|
-
ap_request = protocol.encode_action_pack_request(service_name, public_method_name, body, :request_class => ActionController::TestRequest)
|
527
|
-
ap_request.env.update(request_env)
|
528
|
-
ap_response = ActionController::TestResponse.new
|
529
|
-
container.process(ap_request, ap_response)
|
530
|
-
# puts ap_response.body
|
531
|
-
@response_body = ap_response.body
|
532
|
-
public_method_name, return_value = protocol.decode_response(ap_response.body)
|
533
|
-
unless is_exception?(return_value) || virtual
|
534
|
-
return_value = method.cast_returns(return_value)
|
535
|
-
end
|
536
|
-
if soap?
|
537
|
-
# http://dev.rubyonrails.com/changeset/920
|
538
|
-
assert_match(/Response$/, public_method_name) unless public_method_name == "fault"
|
539
|
-
end
|
540
|
-
return_value
|
541
|
-
end
|
542
|
-
|
543
|
-
def http_method_allowed?(method)
|
544
|
-
method = method.to_s.upcase
|
545
|
-
test_request = ActionController::TestRequest.new({ 'action' => 'api' })
|
546
|
-
test_response = ActionController::TestResponse.new
|
547
|
-
test_request.env['REQUEST_METHOD'] = method
|
548
|
-
result = @direct_controller.process(test_request, test_response)
|
549
|
-
result.body =~ /(GET|POST|PUT|DELETE|TRACE|CONNECT) not supported/ ? false : true
|
550
|
-
end
|
551
|
-
end
|