aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2006-02-26 07:23:42 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2006-02-26 07:23:42 +0000
commit6a83ebfe703e922c4b0e2333521ed23208003f13 (patch)
tree83259ddbb5d8b1c0d9fbdac6b66c2b5c3ece23e9
parent841d596c24f0775d8f6b264b7d8f7ba689157ed9 (diff)
downloadrails-6a83ebfe703e922c4b0e2333521ed23208003f13.tar.gz
rails-6a83ebfe703e922c4b0e2333521ed23208003f13.tar.bz2
rails-6a83ebfe703e922c4b0e2333521ed23208003f13.zip
Fixed form_for regression (closes #3962) [t.lucas@toolmantim.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3666 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb2
-rw-r--r--actionpack/test/template/form_helper_test.rb19
2 files changed, 20 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index ac65529352..72d4e6b475 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -122,7 +122,7 @@ module ActionView
#
def form_for(object_name, object, options = {}, &proc)
raise ArgumentError, "Missing block" unless block_given?
- concat(form_tag(options, options.delete(:html) || {}), proc.binding)
+ concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}), proc.binding)
fields_for(object_name, object, options, &proc)
concat('</form>', proc.binding)
end
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index f0e1522807..cfeff6d7a7 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -30,7 +30,9 @@ class FormHelperTest < Test::Unit::TestCase
@post.written_on = Date.new(2004, 6, 15)
@controller = Class.new do
+ attr_reader :url_for_options
def url_for(options, *parameters_for_method_reference)
+ @url_for_options = options
"http://www.example.com"
end
end
@@ -355,6 +357,23 @@ class FormHelperTest < Test::Unit::TestCase
assert_dom_equal expected, _erbout
end
+ def test_form_for_with_string_url_option
+ _erbout = ''
+
+ form_for(:post, @post, :url => 'http://www.otherdomain.com') do |f| end
+
+ assert_equal 'http://www.otherdomain.com', @controller.url_for_options
+ end
+
+ def test_form_for_with_hash_url_option
+ _erbout = ''
+
+ form_for(:post, @post, :url => {:controller => 'controller', :action => 'action'}) do |f| end
+
+ assert_equal 'controller', @controller.url_for_options[:controller]
+ assert_equal 'action', @controller.url_for_options[:action]
+ end
+
def test_remote_form_for_with_html_options_adds_options_to_form_tag
self.extend ActionView::Helpers::PrototypeHelper
_erbout = ''