aboutsummaryrefslogtreecommitdiffstats
path: root/actionwebservice/test
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-03-26 21:26:13 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-03-26 21:26:13 +0000
commitc4f1979db5b69f85b1e51bfa9a3e119bc71a4e24 (patch)
tree9ca497d7946eeb2884ec29474198c1ad6799f2e3 /actionwebservice/test
parent77c8e3a0fd32e736575edce503b2e9f891193f9e (diff)
downloadrails-c4f1979db5b69f85b1e51bfa9a3e119bc71a4e24.tar.gz
rails-c4f1979db5b69f85b1e51bfa9a3e119bc71a4e24.tar.bz2
rails-c4f1979db5b69f85b1e51bfa9a3e119bc71a4e24.zip
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
Diffstat (limited to 'actionwebservice/test')
-rw-r--r--actionwebservice/test/scaffolded_controller_test.rb17
1 files changed, 15 insertions, 2 deletions
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'