diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-04-06 02:52:01 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-04-06 02:52:01 +0000 |
commit | f2790d03905c275e8eff3927429bdb77f6c75d3a (patch) | |
tree | aff4c64f458c444be487736144fcf18ec1dcdd71 | |
parent | a86e594997a333e343936ca18c0f294058aeb083 (diff) | |
download | rails-f2790d03905c275e8eff3927429bdb77f6c75d3a.tar.gz rails-f2790d03905c275e8eff3927429bdb77f6c75d3a.tar.bz2 rails-f2790d03905c275e8eff3927429bdb77f6c75d3a.zip |
invoke / invoke_delegated / invoke_layered check for correct number of args (closes #4610) [jerrett@bravenet.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4173 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | actionwebservice/lib/action_web_service/test_invoke.rb | 1 | ||||
-rw-r--r-- | actionwebservice/test/test_invoke_test.rb | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/actionwebservice/lib/action_web_service/test_invoke.rb b/actionwebservice/lib/action_web_service/test_invoke.rb index ee15070851..e4469851eb 100644 --- a/actionwebservice/lib/action_web_service/test_invoke.rb +++ b/actionwebservice/lib/action_web_service/test_invoke.rb @@ -52,6 +52,7 @@ module Test # :nodoc: 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 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 611a0ac215..46f9ddb2d2 100644 --- a/actionwebservice/test/test_invoke_test.rb +++ b/actionwebservice/test/test_invoke_test.rb @@ -76,4 +76,25 @@ class TestInvokeTest < Test::Unit::TestCase end end end + + def test_layered_fail_with_wrong_number_of_arguments + [:soap, :xmlrpc].each do |protocol| + @protocol = protocol + [:one, :two].each do |service| + @controller = TestInvokeLayeredController.new + assert_raise(ArgumentError) { invoke_layered service, :add, 1 } + end + end + end + + def test_delegated_fail_with_wrong_number_of_arguments + @controller = TestInvokeDelegatedController.new + assert_raise(ArgumentError) { invoke_delegated :service, :add, 1 } + end + + def test_direct_fail_with_wrong_number_of_arguments + @controller = TestInvokeDirectController.new + assert_raise(ArgumentError) { invoke :add, 1 } + end + end |