aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorNiklas Holmgren <niklas.holmgren@mindset.se>2009-08-08 11:43:24 -0400
committerPratik Naik <pratiknaik@gmail.com>2009-08-08 17:00:29 +0100
commitc284412b149e03f46144ef566bcd6a16750961b1 (patch)
tree3e39cecdf7e7c8454051bd2c79ef7db39c2c6ba9 /actionpack/test
parentad98827a78d0ee13c5d3b8c5caf2fccfa294277c (diff)
downloadrails-c284412b149e03f46144ef566bcd6a16750961b1.tar.gz
rails-c284412b149e03f46144ef566bcd6a16750961b1.tar.bz2
rails-c284412b149e03f46144ef566bcd6a16750961b1.zip
Polymorphic routes generates collection URL from model class [#1089 state:resolved]
Signed-off-by: Dan Pickett <dpickett@enlightsolutions.com> Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/activerecord/polymorphic_routes_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionpack/test/activerecord/polymorphic_routes_test.rb
index f001b0dab8..37f1f6dff8 100644
--- a/actionpack/test/activerecord/polymorphic_routes_test.rb
+++ b/actionpack/test/activerecord/polymorphic_routes_test.rb
@@ -45,6 +45,12 @@ class PolymorphicRoutesTest < ActionController::TestCase
assert_equal "http://example.com/projects/#{@project.id}", polymorphic_url(@project)
end
end
+
+ def test_with_class
+ with_test_routes do
+ assert_equal "http://example.com/projects", polymorphic_url(@project.class)
+ end
+ end
def test_with_new_record
with_test_routes do
@@ -144,6 +150,19 @@ class PolymorphicRoutesTest < ActionController::TestCase
end
end
+ def test_with_nested_class
+ with_test_routes do
+ @project.save
+ assert_equal "http://example.com/projects/#{@project.id}/tasks", polymorphic_url([@project, @task.class])
+ end
+ end
+
+ def test_class_with_array_and_namespace
+ with_admin_test_routes do
+ assert_equal "http://example.com/admin/projects", polymorphic_url([:admin, @project.class])
+ end
+ end
+
def test_new_with_array_and_namespace
with_admin_test_routes do
assert_equal "http://example.com/admin/projects/new", polymorphic_url([:admin, @project], :action => 'new')
@@ -267,6 +286,12 @@ class PolymorphicRoutesTest < ActionController::TestCase
end
end
+ def test_with_irregular_plural_class
+ with_test_routes do
+ assert_equal "http://example.com/taxes", polymorphic_url(@tax.class)
+ end
+ end
+
def test_with_irregular_plural_new_record
with_test_routes do
assert_equal "http://example.com/taxes", polymorphic_url(@tax)
@@ -320,6 +345,12 @@ class PolymorphicRoutesTest < ActionController::TestCase
end
end
+ def test_class_with_irregular_plural_array_and_namespace
+ with_admin_test_routes do
+ assert_equal "http://example.com/admin/taxes", polymorphic_url([:admin, @tax.class])
+ end
+ end
+
def test_unsaved_with_irregular_plural_array_and_namespace
with_admin_test_routes do
assert_equal "http://example.com/admin/taxes", polymorphic_url([:admin, @tax])