aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-12-30 11:15:07 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-12-30 11:23:47 -0300
commit0c070ae568767a2c8e9bdec49ab3a1a24f113382 (patch)
tree7e019d49da88a74d542c121e44313e62325a8ff7 /actionview/test
parent2b12288139f9bad6cf6d058d93af66cdf598dda9 (diff)
parent3efd90ac5b15d376bc5780d08d6e07d5a2b50ff1 (diff)
downloadrails-0c070ae568767a2c8e9bdec49ab3a1a24f113382.tar.gz
rails-0c070ae568767a2c8e9bdec49ab3a1a24f113382.tar.bz2
rails-0c070ae568767a2c8e9bdec49ab3a1a24f113382.zip
Merge pull request #18251 from tjgrathwell/fix-polymorphic-routes-to-model
Fix form_for to work with objects that implement to_model
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/activerecord/polymorphic_routes_test.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/actionview/test/activerecord/polymorphic_routes_test.rb b/actionview/test/activerecord/polymorphic_routes_test.rb
index 5842b775bb..8e1ed2776d 100644
--- a/actionview/test/activerecord/polymorphic_routes_test.rb
+++ b/actionview/test/activerecord/polymorphic_routes_test.rb
@@ -25,15 +25,17 @@ class Series < ActiveRecord::Base
self.table_name = 'projects'
end
-class ModelDelegator < ActiveRecord::Base
- self.table_name = 'projects'
-
+class ModelDelegator
def to_model
ModelDelegate.new
end
end
class ModelDelegate
+ def persisted?
+ true
+ end
+
def model_name
ActiveModel::Name.new(self.class)
end
@@ -605,13 +607,18 @@ class PolymorphicRoutesTest < ActionController::TestCase
end
end
- def test_routing_a_to_model_delegate
+ def test_routing_to_a_model_delegate
with_test_routes do
- @delegator.save
assert_url "http://example.com/model_delegates/overridden", @delegator
end
end
+ def test_nested_routing_to_a_model_delegate
+ with_test_routes do
+ assert_url "http://example.com/foo/model_delegates/overridden", [:foo, @delegator]
+ end
+ end
+
def with_namespaced_routes(name)
with_routing do |set|
set.draw do
@@ -645,6 +652,9 @@ class PolymorphicRoutesTest < ActionController::TestCase
end
resources :series
resources :model_delegates
+ namespace :foo do
+ resources :model_delegates
+ end
end
extend @routes.url_helpers