aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeon Breedt <bitserf@gmail.com>2005-03-26 00:20:19 +0000
committerLeon Breedt <bitserf@gmail.com>2005-03-26 00:20:19 +0000
commit8032c4ffd47ba4deb5cbd88a462b837240eb593c (patch)
tree644884307c403b47c883a4c699ea0c8472fd75ac
parent771244a58ce812198e7171e4ee0ae5b27032ead0 (diff)
downloadrails-8032c4ffd47ba4deb5cbd88a462b837240eb593c.tar.gz
rails-8032c4ffd47ba4deb5cbd88a462b837240eb593c.tar.bz2
rails-8032c4ffd47ba4deb5cbd88a462b837240eb593c.zip
allow direct dispatching methods to declare their parameters as well, for brevity's sake, it seems
to be counter-intuitive not to do so (closes #939). update gem require versions. fix unit tests for exception de-shallowing changes. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@992 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionwebservice/CHANGELOG4
-rw-r--r--actionwebservice/lib/action_web_service.rb6
-rw-r--r--actionwebservice/lib/action_web_service/dispatcher/abstract.rb7
-rw-r--r--actionwebservice/test/abstract_dispatcher.rb8
-rw-r--r--actionwebservice/test/dispatcher_action_controller_soap_test.rb14
5 files changed, 34 insertions, 5 deletions
diff --git a/actionwebservice/CHANGELOG b/actionwebservice/CHANGELOG
index 29edcd517e..7e062fb682 100644
--- a/actionwebservice/CHANGELOG
+++ b/actionwebservice/CHANGELOG
@@ -1,3 +1,7 @@
+*0.7.0* (Unreleased)
+
+* Allow method declarations for direct dispatching to declare parameters as well. We treat an arity of < 0 or > 0 as an indication that we should send through parameters. Closes #939.
+
*0.6.1* (22th March, 2005)
* Fix that method response QNames mismatched with that declared in the WSDL, makes SOAP::WSDLDriverFactory work against AWS again
diff --git a/actionwebservice/lib/action_web_service.rb b/actionwebservice/lib/action_web_service.rb
index 2865dff633..61e451b704 100644
--- a/actionwebservice/lib/action_web_service.rb
+++ b/actionwebservice/lib/action_web_service.rb
@@ -27,9 +27,9 @@ begin
require 'active_record'
rescue LoadError
require 'rubygems'
- require_gem 'activesupport', '>= 0.9.0'
- require_gem 'actionpack', '>= 1.4.0'
- require_gem 'activerecord', '>= 1.6.0'
+ require_gem 'activesupport', '>= 1.0.2'
+ require_gem 'actionpack', '>= 1.6.0'
+ require_gem 'activerecord', '>= 1.9.0'
end
$:.unshift(File.dirname(__FILE__) + "/action_web_service/vendor/")
diff --git a/actionwebservice/lib/action_web_service/dispatcher/abstract.rb b/actionwebservice/lib/action_web_service/dispatcher/abstract.rb
index 1df03d1777..b63fe65ce1 100644
--- a/actionwebservice/lib/action_web_service/dispatcher/abstract.rb
+++ b/actionwebservice/lib/action_web_service/dispatcher/abstract.rb
@@ -34,7 +34,12 @@ module ActionWebService # :nodoc:
def web_service_direct_invoke(invocation)
@method_params = invocation.method_ordered_params
- return_value = self.__send__(invocation.api_method_name)
+ arity = method(invocation.api_method_name).arity rescue 0
+ if arity < 0 || arity > 0
+ return_value = self.__send__(invocation.api_method_name, *@method_params)
+ else
+ return_value = self.__send__(invocation.api_method_name)
+ end
if invocation.api.has_api_method?(invocation.api_method_name)
returns = invocation.returns ? invocation.returns[0] : nil
else
diff --git a/actionwebservice/test/abstract_dispatcher.rb b/actionwebservice/test/abstract_dispatcher.rb
index da07d2cf8c..3657f8a5ee 100644
--- a/actionwebservice/test/abstract_dispatcher.rb
+++ b/actionwebservice/test/abstract_dispatcher.rb
@@ -40,6 +40,7 @@ module DispatcherTest
class DirectAPI < ActionWebService::API::Base
api_method :add, :expects => [{:a=>:int}, {:b=>:int}], :returns => [:int]
+ api_method :add2, :expects => [{:a=>:int}, {:b=>:int}], :returns => [:int]
api_method :before_filtered
api_method :after_filtered, :returns => [[:int]]
api_method :struct_return, :returns => [[Node]]
@@ -141,6 +142,7 @@ module DispatcherTest
after_filter :alwaysok, :only => [:after_filtered]
attr :added
+ attr :added2
attr :before_filter_called
attr :before_filter_target_called
attr :after_filter_called
@@ -159,6 +161,10 @@ module DispatcherTest
@added = @params['a'] + @params['b']
end
+ def add2(a, b)
+ @added2 = a + b
+ end
+
def before_filtered
@before_filter_target_called = true
end
@@ -212,6 +218,8 @@ module DispatcherCommonTests
def test_direct_dispatching
assert_equal(70, do_method_call(@direct_controller, 'Add', 20, 50))
assert_equal(70, @direct_controller.added)
+ assert_equal(50, do_method_call(@direct_controller, 'Add2', 25, 25))
+ assert_equal(50, @direct_controller.added2)
assert(@direct_controller.void_called == false)
case @encoder
when WS::Encoding::SoapRpcEncoding
diff --git a/actionwebservice/test/dispatcher_action_controller_soap_test.rb b/actionwebservice/test/dispatcher_action_controller_soap_test.rb
index dd945972d6..400ab40dd6 100644
--- a/actionwebservice/test/dispatcher_action_controller_soap_test.rb
+++ b/actionwebservice/test/dispatcher_action_controller_soap_test.rb
@@ -2,6 +2,18 @@ $:.unshift(File.dirname(__FILE__) + '/apis')
require File.dirname(__FILE__) + '/abstract_dispatcher'
require 'wsdl/parser'
+class ActionController::Base
+ class << self
+ alias :inherited_without_name_error :inherited
+ def inherited(child)
+ begin
+ inherited_without_name_error(child)
+ rescue NameError => e
+ end
+ end
+ end
+end
+
class AutoLoadController < ActionController::Base; end
class FailingAutoLoadController < ActionController::Base; end
class BrokenAutoLoadController < ActionController::Base; end
@@ -39,7 +51,7 @@ class TC_DispatcherActionControllerSoap < Test::Unit::TestCase
assert(!AutoLoadController.web_service_api.nil?)
assert(AutoLoadController.web_service_api.has_public_api_method?('Void'))
assert(FailingAutoLoadController.web_service_api.nil?)
- assert_raises(LoadError, NameError) do
+ assert_raises(MissingSourceFile) do
FailingAutoLoadController.require_web_service_api :blah
end
assert_raises(ArgumentError) do