diff options
author | rick <rick@spacemonkey.local> | 2008-05-10 17:46:55 -0700 |
---|---|---|
committer | rick <rick@spacemonkey.local> | 2008-05-10 17:46:55 -0700 |
commit | d09a8446d5606a5a0b5c024224b09a1318e9cf4d (patch) | |
tree | 199ef3554f731c980ea5726e67e34af4ea057c2e /actionpack/test/controller | |
parent | c8451aeeea200043d8a3e6eae9c49def3a154ddb (diff) | |
parent | a7ea06b4ebe252e258f83e7de945b4baa30ec3bc (diff) | |
download | rails-d09a8446d5606a5a0b5c024224b09a1318e9cf4d.tar.gz rails-d09a8446d5606a5a0b5c024224b09a1318e9cf4d.tar.bz2 rails-d09a8446d5606a5a0b5c024224b09a1318e9cf4d.zip |
fix merge conflict with actionpack changelog
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/new_render_test.rb | 9 | ||||
-rw-r--r-- | actionpack/test/controller/record_identifier_test.rb | 36 | ||||
-rw-r--r-- | actionpack/test/controller/resources_test.rb | 30 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 12 |
4 files changed, 78 insertions, 9 deletions
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb index 8e39057f55..6e2c6d90c6 100644 --- a/actionpack/test/controller/new_render_test.rb +++ b/actionpack/test/controller/new_render_test.rb @@ -246,6 +246,10 @@ class NewRenderTestController < ActionController::Base def accessing_logger_in_template render :inline => "<%= logger.class %>" end + + def accessing_action_name_in_template + render :inline => "<%= action_name %>" + end def accessing_params_in_template_with_layout render :layout => nil, :inline => "Hello: <%= params[:name] %>" @@ -545,6 +549,11 @@ class NewRenderTest < Test::Unit::TestCase get :accessing_logger_in_template assert_equal "Logger", @response.body end + + def test_access_to_action_name_in_view + get :accessing_action_name_in_template + assert_equal "accessing_action_name_in_template", @response.body + end def test_render_xml get :render_xml_hello diff --git a/actionpack/test/controller/record_identifier_test.rb b/actionpack/test/controller/record_identifier_test.rb index def8613215..12c1eaea69 100644 --- a/actionpack/test/controller/record_identifier_test.rb +++ b/actionpack/test/controller/record_identifier_test.rb @@ -57,6 +57,18 @@ class RecordIdentifierTest < Test::Unit::TestCase assert_equal expected, partial_path(Comment) end + def test_partial_path_with_namespaced_controller_path + expected = "admin/#{@plural}/#{@singular}" + assert_equal expected, partial_path(@record, "admin/posts") + assert_equal expected, partial_path(@klass, "admin/posts") + end + + def test_partial_path_with_not_namespaced_controller_path + expected = "#{@plural}/#{@singular}" + assert_equal expected, partial_path(@record, "posts") + assert_equal expected, partial_path(@klass, "posts") + end + def test_dom_class assert_equal @singular, dom_class(@record) end @@ -100,4 +112,28 @@ class NestedRecordIdentifierTest < RecordIdentifierTest assert_equal expected, partial_path(@record) assert_equal expected, partial_path(Comment::Nested) end + + def test_partial_path_with_namespaced_controller_path + expected = "admin/comment/nesteds/nested" + assert_equal expected, partial_path(@record, "admin/posts") + assert_equal expected, partial_path(@klass, "admin/posts") + end + + def test_partial_path_with_deeper_namespaced_controller_path + expected = "deeper/admin/comment/nesteds/nested" + assert_equal expected, partial_path(@record, "deeper/admin/posts") + assert_equal expected, partial_path(@klass, "deeper/admin/posts") + end + + def test_partial_path_with_even_deeper_namespaced_controller_path + expected = "even/more/deeper/admin/comment/nesteds/nested" + assert_equal expected, partial_path(@record, "even/more/deeper/admin/posts") + assert_equal expected, partial_path(@klass, "even/more/deeper/admin/posts") + end + + def test_partial_path_with_not_namespaced_controller_path + expected = "comment/nesteds/nested" + assert_equal expected, partial_path(@record, "posts") + assert_equal expected, partial_path(@klass, "posts") + end end diff --git a/actionpack/test/controller/resources_test.rb b/actionpack/test/controller/resources_test.rb index b138cee29f..0d089d0f23 100644 --- a/actionpack/test/controller/resources_test.rb +++ b/actionpack/test/controller/resources_test.rb @@ -226,6 +226,28 @@ class ResourcesTest < Test::Unit::TestCase end end + def test_member_when_changed_default_restful_actions_and_path_names_not_specified + default_path_names = ActionController::Base.resources_path_names + ActionController::Base.resources_path_names = {:new => 'nuevo', :edit => 'editar'} + + with_restful_routing :messages do + new_options = { :action => 'new', :controller => 'messages' } + new_path = "/messages/nuevo" + edit_options = { :action => 'edit', :id => '1', :controller => 'messages' } + edit_path = "/messages/1/editar" + + assert_restful_routes_for :messages do |options| + assert_recognizes(options.merge(new_options), :path => new_path, :method => :get) + end + + assert_restful_routes_for :messages do |options| + assert_recognizes(options.merge(edit_options), :path => edit_path, :method => :get) + end + end + ensure + ActionController::Base.resources_path_names = default_path_names + end + def test_with_two_member_actions_with_same_method [:put, :post].each do |method| with_restful_routing :messages, :member => { :mark => method, :unmark => method } do @@ -691,11 +713,11 @@ class ResourcesTest < Test::Unit::TestCase options[:options] ||= {} options[:options][:controller] = options[:controller] || controller_name.to_s - new_action = "new" - edit_action = "edit" + new_action = ActionController::Base.resources_path_names[:new] || "new" + edit_action = ActionController::Base.resources_path_names[:edit] || "edit" if options[:path_names] - new_action = options[:path_names][:new] || "new" - edit_action = options[:path_names][:edit] || "edit" + new_action = options[:path_names][:new] if options[:path_names][:new] + edit_action = options[:path_names][:edit] if options[:path_names][:edit] end collection_path = "/#{options[:path_prefix]}#{options[:as] || controller_name}" diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index 640afd58f8..b28f7bcdff 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -25,7 +25,7 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase ActionController::Routing.use_controllers! ['controller'] @set = ActionController::Routing::RouteSet.new @set.draw do |map| - map.connect ':controller/:action/:variable' + map.connect ':controller/:action/:variable/*additional' end safe, unsafe = %w(: @ & = + $ , ;), %w(^ / ? # [ ]) @@ -36,17 +36,19 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase end def test_route_generation_escapes_unsafe_path_characters - assert_equal "/contr#{@segment}oller/act#{@escaped}ion/var#{@escaped}iable", + assert_equal "/contr#{@segment}oller/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2", @set.generate(:controller => "contr#{@segment}oller", :action => "act#{@segment}ion", - :variable => "var#{@segment}iable") + :variable => "var#{@segment}iable", + :additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"]) end def test_route_recognition_unescapes_path_components options = { :controller => "controller", :action => "act#{@segment}ion", - :variable => "var#{@segment}iable" } - assert_equal options, @set.recognize_path("/controller/act#{@escaped}ion/var#{@escaped}iable") + :variable => "var#{@segment}iable", + :additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"] } + assert_equal options, @set.recognize_path("/controller/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2") end end |