mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix invoke_layered since api_method didn't declare :expects. Closes #4720. [Kevin Ballard <kevin@sb.org>, Kent Sibilev]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4497 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
236c7325df
commit
68a320ad20
3 changed files with 15 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Fix invoke_layered since api_method didn't declare :expects. Closes #4720. [Kevin Ballard <kevin@sb.org>, 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.]
|
||||
|
|
|
@ -52,7 +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
|
||||
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
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ require File.dirname(__FILE__) + '/abstract_unit'
|
|||
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 @@ class TestInvokeService < ActionWebService::Base
|
|||
@invoked = true
|
||||
a + b
|
||||
end
|
||||
|
||||
def null
|
||||
end
|
||||
end
|
||||
|
||||
class TestController < ActionController::Base
|
||||
|
@ -29,6 +33,9 @@ class TestInvokeDirectController < TestController
|
|||
@invoked = true
|
||||
@method_params[0] + @method_params[1]
|
||||
end
|
||||
|
||||
def null
|
||||
end
|
||||
end
|
||||
|
||||
class TestInvokeDelegatedController < TestController
|
||||
|
@ -97,4 +104,9 @@ class TestInvokeTest < Test::Unit::TestCase
|
|||
assert_raise(ArgumentError) { invoke :add, 1 }
|
||||
end
|
||||
|
||||
def test_with_no_parameters_declared
|
||||
@controller = TestInvokeDirectController.new
|
||||
assert_nil invoke(:null)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue