Created
March 24, 2009 16:19
-
-
Save lifo/84190 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/actionpack/test/activerecord/polymorphic_routes_test.rb b/actionpack/test/activerecord/polymorphic_routes_test.rb | |
new file mode 100644 | |
index 0000000..24eb16d | |
--- /dev/null | |
+++ b/actionpack/test/activerecord/polymorphic_routes_test.rb | |
@@ -0,0 +1,48 @@ | |
+require 'active_record_unit' | |
+ | |
+class PolymorphicRoutesTest < ActionController::TestCase | |
+ include ActionController::UrlWriter | |
+ self.default_url_options[:host] = "lifo.com" | |
+ | |
+ def setup | |
+ @developer = Developer.new | |
+ @topic = Topic.new | |
+ @company = Company.new | |
+ end | |
+ | |
+ def test_with_record | |
+ with_test_routes do | |
+ @developer.save | |
+ assert_equal "http://lifo.com/developers/#{@developer.id}", polymorphic_url(@developer) | |
+ end | |
+ end | |
+ | |
+ def test_uncountable_resource | |
+ with_test_routes do | |
+ @topic.save | |
+ assert_equal "http://lifo.com/topics/#{@topic.id}", polymorphic_url(@topic) | |
+ end | |
+ end | |
+ | |
+ def test_uncountable_resource_with_singular_option | |
+ with_test_routes do | |
+ @company.save | |
+ assert_equal "http://lifo.com/companies/#{@company.id}", polymorphic_url(@company) | |
+ end | |
+ end | |
+ | |
+ private | |
+ | |
+ def with_test_routes | |
+ with_routing do |set| | |
+ set.draw do |map| | |
+ map.resources :developers | |
+ map.resources :topics | |
+ map.resources :companies, :singular => :company_instance | |
+ end | |
+ | |
+ ActionController::Routing::Routes.install_helpers(self.class) | |
+ yield | |
+ end | |
+ end | |
+end | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment