Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.

Commit 9d30efa

Browse files
author
Kent Sibilev
committed
applied jkraemer's patch to fix Rails 2.3.2 compatibility
1 parent de158a1 commit 9d30efa

11 files changed

+31
-23
lines changed

lib/action_web_service/protocol/abstract.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def decode_action_pack_request(action_pack_request)
1212

1313
def encode_action_pack_request(service_name, public_method_name, raw_body, options={})
1414
klass = options[:request_class] || SimpleActionPackRequest
15-
request = klass.new
15+
request = klass.new({})
1616
request.request_parameters['action'] = service_name.to_s
1717
request.env['RAW_POST_DATA'] = raw_body
1818
request.env['REQUEST_METHOD'] = 'POST'
@@ -72,8 +72,8 @@ def initialize(body, content_type, return_value)
7272
end
7373

7474
class SimpleActionPackRequest < ActionController::Request # :nodoc:
75-
def initialize
76-
@env = {}
75+
def initialize(env = {})
76+
@env = env
7777
@qparams = {}
7878
@rparams = {}
7979
@cookies = {}

lib/action_web_service/scaffolding.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def #{action_name}_submit
6969
post_params = params['method_params'] ? params['method_params'].dup : nil
7070
params = []
7171
@scaffold_method.expects.each_with_index do |spec, i|
72-
params << post_params[i.to_s]
72+
params << post_params[i.to_s]
7373
end if @scaffold_method.expects
7474
params = @scaffold_method.cast_expects(params)
7575
method_name = public_method_name(@scaffold_service.name, @scaffold_method.public_name)
@@ -106,9 +106,9 @@ def setup_invocation_assigns
106106
def render_invocation_scaffold(action)
107107
customized_template = "\#{self.class.controller_path}/#{action_name}/\#{action}"
108108
default_template = scaffold_path(action)
109-
if template_exists?(customized_template)
109+
begin
110110
content = @template.render(:file => customized_template)
111-
else
111+
rescue ActionView::MissingTemplate
112112
content = @template.render(:file => default_template)
113113
end
114114
@template.instance_variable_set("@content_for_layout", content)
@@ -125,7 +125,7 @@ def scaffold_path(template_name)
125125
126126
def reset_invocation_response
127127
erase_render_results
128-
response.headers = ::ActionController::AbstractResponse::DEFAULT_HEADERS.merge("cookie" => [])
128+
response.instance_variable_set :@header, Rack::Utils::HeaderHash.new(::ActionController::Response::DEFAULT_HEADERS.merge("cookie" => []))
129129
end
130130
131131
def public_method_name(service_name, method_name)

test/abstract_dispatcher.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def test_garbage_request
358358
response = ActionController::TestResponse.new
359359
controller.process(request, response)
360360
# puts response.body
361-
assert(response.headers['Status'] =~ /^500/)
361+
assert(response.status =~ /^500/)
362362
end
363363
send_garbage_request.call
364364
controller.class.web_service_exception_reporting = false
@@ -538,7 +538,8 @@ def do_method_call(container, public_method_name, *params)
538538

539539
def http_method_allowed?(method)
540540
method = method.to_s.upcase
541-
test_request = ActionController::TestRequest.new({ 'action' => 'api' })
541+
test_request = ActionController::TestRequest.new
542+
test_request.action = 'api'
542543
test_response = ActionController::TestResponse.new
543544
test_request.env['REQUEST_METHOD'] = method
544545
result = @direct_controller.process(test_request, test_response)

test/abstract_unit.rb

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
require 'test/unit'
55
require 'action_web_service'
66
require 'action_controller'
7-
require 'action_controller/test_process'
7+
require 'action_controller/test_case'
8+
require 'action_view'
9+
require 'action_view/test_case'
810

911
# Show backtraces for deprecated behavior for quicker cleanup.
1012
ActiveSupport::Deprecation.debug = true
@@ -14,6 +16,7 @@
1416

1517
begin
1618
require 'activerecord'
19+
require "active_record/test_case"
1720
require "active_record/fixtures" unless Object.const_defined?(:Fixtures)
1821
rescue LoadError => e
1922
fail "\nFailed to load activerecord: #{e}"
@@ -30,4 +33,7 @@
3033

3134
ActiveRecord::Base.establish_connection 'mysql'
3235

33-
Test::Unit::TestCase.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
36+
class ActiveSupport::TestCase
37+
include ActiveRecord::TestFixtures
38+
self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
39+
end

test/api_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class API < ActionWebService::API::Base
1212
end
1313
end
1414

15-
class TC_API < Test::Unit::TestCase
15+
class TC_API < ActiveSupport::TestCase
1616
API = APITest::API
1717

1818
def test_api_method_declaration

test/base_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def under_score
3434
end
3535
end
3636

37-
class TC_Base < Test::Unit::TestCase
37+
class TC_Base < ActiveSupport::TestCase
3838
def test_options
3939
assert(BaseTest::PristineService.web_service_api.inflect_names == false)
4040
assert(BaseTest::Service.web_service_api.inflect_names == true)

test/client_soap_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def server_port
4848
end
4949
end
5050

51-
class TC_ClientSoap < Test::Unit::TestCase
51+
class TC_ClientSoap < ActiveSupport::TestCase
5252
include ClientTest
5353
include ClientSoapTest
5454

test/client_xmlrpc_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def server_port
4242
end
4343
end
4444

45-
class TC_ClientXmlRpc < Test::Unit::TestCase
45+
class TC_ClientXmlRpc < ActiveSupport::TestCase
4646
include ClientTest
4747
include ClientXmlRpcTest
4848

test/dispatcher_action_controller_soap_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ def ensure_valid_wsdl(controller, wsdl, expected_namespace)
129129
end
130130

131131
def ensure_valid_wsdl_action(controller)
132-
test_request = ActionController::TestRequest.new({ 'action' => 'wsdl' })
132+
test_request = ActionController::TestRequest.new
133+
test_request.action = 'wsdl'
133134
test_response = ActionController::TestResponse.new
134135
wsdl = controller.process(test_request, test_response).body
135136
ensure_valid_wsdl(controller, wsdl, DispatcherTest::WsdlNamespace)

test/scaffolded_controller_test.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ def base64_upcase(data)
6464
end
6565
end
6666

67-
class ScaffoldedControllerTest < Test::Unit::TestCase
68-
def setup
69-
@controller = ScaffoldedController.new
70-
@request = ActionController::TestRequest.new
71-
@response = ActionController::TestResponse.new
72-
end
67+
class ScaffoldedControllerTest < ActionController::TestCase
68+
# def setup
69+
# @controller = ScaffoldedController.new
70+
# @request = ActionController::TestRequest.new
71+
# @response = ActionController::TestResponse.new
72+
# end
7373

7474
def test_scaffold_invoke
7575
get :scaffold_invoke

test/test_invoke_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class TestInvokeLayeredController < TestController
4949
web_service(:two) { @service_two ||= TestInvokeService.new }
5050
end
5151

52-
class TestInvokeTest < Test::Unit::TestCase
52+
class TestInvokeTest < ActiveSupport::TestCase
5353
def setup
5454
@request = ActionController::TestRequest.new
5555
@response = ActionController::TestResponse.new

0 commit comments

Comments
 (0)