aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-09-01 01:37:02 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:15 +0200
commit6f3119d3c298c007e7a4eed8375d9fc30b961d06 (patch)
tree053d9d33dd711f52c3767a4f4b07ea356a6f2fe2 /actionpack/test
parent2607def8621c41d5b0bee09e379ae26890b27f7d (diff)
downloadrails-6f3119d3c298c007e7a4eed8375d9fc30b961d06.tar.gz
rails-6f3119d3c298c007e7a4eed8375d9fc30b961d06.tar.bz2
rails-6f3119d3c298c007e7a4eed8375d9fc30b961d06.zip
Remove namespace for isolated namespaced models in forms
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/lib/controller/fake_models.rb15
-rw-r--r--actionpack/test/template/form_helper_test.rb17
2 files changed, 32 insertions, 0 deletions
diff --git a/actionpack/test/lib/controller/fake_models.rb b/actionpack/test/lib/controller/fake_models.rb
index 37b200d57a..c4127ee699 100644
--- a/actionpack/test/lib/controller/fake_models.rb
+++ b/actionpack/test/lib/controller/fake_models.rb
@@ -149,3 +149,18 @@ class Author < Comment
attr_accessor :post
def post_attributes=(attributes); end
end
+
+module Blog
+ def self._railtie
+ self
+ end
+
+ class Post < Struct.new(:title, :id)
+ extend ActiveModel::Naming
+ include ActiveModel::Conversion
+
+ def persisted?
+ id.present?
+ end
+ end
+end
diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb
index ec57b6a2ab..97a08d45ba 100644
--- a/actionpack/test/template/form_helper_test.rb
+++ b/actionpack/test/template/form_helper_test.rb
@@ -75,6 +75,8 @@ class FormHelperTest < ActionView::TestCase
@post.body = "Back to the hill and over it again!"
@post.secret = 1
@post.written_on = Date.new(2004, 6, 15)
+
+ @blog_post = Blog::Post.new("And his name will be forty and four.", 44)
end
Routes = ActionDispatch::Routing::RouteSet.new
@@ -675,6 +677,21 @@ class FormHelperTest < ActionView::TestCase
assert_dom_equal expected, output_buffer
end
+ def test_form_for_with_isolated_namespaced_model
+ form_for(@blog_post) do |f|
+ concat f.text_field :title
+ concat f.submit('Edit post')
+ end
+
+ expected =
+ "<form accept-charset='UTF-8' action='/posts/44' method='post'>" +
+ snowman +
+ "<label for='post_title'>The Title</label>" +
+ "<input name='post[title]' size='30' type='text' id='post_title' value='And his name will be forty and four.' />" +
+ "<input name='commit' id='post_submit' type='submit' value='Edit post' />" +
+ "</form>"
+ end
+
def test_form_for_with_symbol_object_name
form_for(@post, :as => "other_name", :html => { :id => 'create-post' }) do |f|
concat f.label(:title, :class => 'post_title')