From c4f1979db5b69f85b1e51bfa9a3e119bc71a4e24 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 26 Mar 2006 21:26:13 +0000 Subject: Make ActiveWebService::Struct type reloadable. Fix scaffolding action when one of the members of a structural type has date or time type. Remove extra index hash when generating scaffold html for parameters of structural type (closes #4374) [joe@mjg2.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4054 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionwebservice/test/scaffolded_controller_test.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'actionwebservice/test') diff --git a/actionwebservice/test/scaffolded_controller_test.rb b/actionwebservice/test/scaffolded_controller_test.rb index 0aa034c3b4..123a7043eb 100644 --- a/actionwebservice/test/scaffolded_controller_test.rb +++ b/actionwebservice/test/scaffolded_controller_test.rb @@ -8,8 +8,9 @@ end ActionController::Base.template_root = '.' class ScaffoldPerson < ActionWebService::Struct - member :id, :int - member :name, :string + member :id, :int + member :name, :string + member :birth, :date def ==(other) self.id == other.id && self.name == other.name @@ -19,6 +20,7 @@ end class ScaffoldedControllerTestAPI < ActionWebService::API::Base api_method :hello, :expects => [{:integer=>:int}, :string], :returns => [:bool] api_method :hello_struct_param, :expects => [{:person => ScaffoldPerson}], :returns => [:bool] + api_method :date_of_birth, :expects => [ScaffoldPerson], :returns => [:string] api_method :bye, :returns => [[ScaffoldPerson]] api_method :date_diff, :expects => [{:start_date => :date}, {:end_date => :date}], :returns => [:int] api_method :time_diff, :expects => [{:start_time => :time}, {:end_time => :time}], :returns => [:int] @@ -36,6 +38,10 @@ class ScaffoldedController < ActionController::Base def hello_struct_param(person) 0 end + + def date_of_birth(person) + person.birth.to_s + end def bye [ScaffoldPerson.new(:id => 1, :name => "leon"), ScaffoldPerson.new(:id => 2, :name => "paul")] @@ -78,6 +84,7 @@ class ScaffoldedControllerTest < Test::Unit::TestCase def test_scaffold_invoke_method_params_with_struct get :scaffold_invoke_method_params, :service => 'scaffolded', :method => 'HelloStructParam' assert_rendered_file 'parameters.rhtml' + assert_tag :tag => 'input', :attributes => {:name => "method_params[0][name]"} end def test_scaffold_invoke_submit_hello @@ -106,6 +113,12 @@ class ScaffoldedControllerTest < Test::Unit::TestCase :method_params => {'0' => {'1' => '2006', '2' => '2', '3' => '1'}, '1' => {'1' => '2006', '2' => '2', '3' => '2'}} assert_equal 1, @controller.instance_eval{ @method_return_value } end + + def test_scaffold_struct_date_params + post :scaffold_invoke_submit, :service => 'scaffolded', :method => 'DateOfBirth', + :method_params => {'0' => {'birth' => {'1' => '2006', '2' => '2', '3' => '1'}, 'id' => '1', 'name' => 'person'}} + assert_equal '2006-02-01', @controller.instance_eval{ @method_return_value } + end def test_scaffold_time_params get :scaffold_invoke_method_params, :service => 'scaffolded', :method => 'TimeDiff' -- cgit v1.2.3