From 68a320ad2047c483b4b07cd51c5043cdef562adb Mon Sep 17 00:00:00 2001 From: Marcel Molina Date: Tue, 27 Jun 2006 19:41:14 +0000 Subject: [PATCH] Fix invoke_layered since api_method didn't declare :expects. Closes #4720. [Kevin Ballard , Kent Sibilev] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4497 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionwebservice/CHANGELOG | 2 ++ .../lib/action_web_service/test_invoke.rb | 2 +- actionwebservice/test/test_invoke_test.rb | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/actionwebservice/CHANGELOG b/actionwebservice/CHANGELOG index 22bdd328aa..ee3e8b3746 100644 --- a/actionwebservice/CHANGELOG +++ b/actionwebservice/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix invoke_layered since api_method didn't declare :expects. Closes #4720. [Kevin Ballard , Kent Sibilev] + * Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.] * Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.] diff --git a/actionwebservice/lib/action_web_service/test_invoke.rb b/actionwebservice/lib/action_web_service/test_invoke.rb index e4469851eb..7e714c941c 100644 --- a/actionwebservice/lib/action_web_service/test_invoke.rb +++ b/actionwebservice/lib/action_web_service/test_invoke.rb @@ -52,7 +52,7 @@ def encode_rpc_call(service_name, api_method_name, *args) end protocol.register_api(api) method = api.api_methods[api_method_name.to_sym] - raise ArgumentError, "wrong number of arguments for rpc call (#{args.length} for #{method.expects.length})" unless args.length == method.expects.length + raise ArgumentError, "wrong number of arguments for rpc call (#{args.length} for #{method.expects.length})" if method && method.expects && args.length != method.expects.length protocol.encode_request(public_method_name(service_name, api_method_name), args.dup, method.expects) end diff --git a/actionwebservice/test/test_invoke_test.rb b/actionwebservice/test/test_invoke_test.rb index 46f9ddb2d2..72ebc71925 100644 --- a/actionwebservice/test/test_invoke_test.rb +++ b/actionwebservice/test/test_invoke_test.rb @@ -2,6 +2,7 @@ require 'action_web_service/test_invoke' class TestInvokeAPI < ActionWebService::API::Base + api_method :null api_method :add, :expects => [:int, :int], :returns => [:int] end @@ -14,6 +15,9 @@ def add(a, b) @invoked = true a + b end + + def null + end end class TestController < ActionController::Base @@ -29,6 +33,9 @@ def add @invoked = true @method_params[0] + @method_params[1] end + + def null + end end class TestInvokeDelegatedController < TestController @@ -97,4 +104,9 @@ def test_direct_fail_with_wrong_number_of_arguments assert_raise(ArgumentError) { invoke :add, 1 } end + def test_with_no_parameters_declared + @controller = TestInvokeDirectController.new + assert_nil invoke(:null) + end + end -- GitLab