aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/url_for_test.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-07-18 19:49:51 +0200
committerPiotr Sarnacki <drogus@gmail.com>2010-09-03 22:59:07 +0200
commit6c95e0f879aafa5921cd7898d5951b9a926d3c9a (patch)
treed327320b3349b8a3359ca7c16e92f72fce2a92a6 /actionpack/test/dispatch/url_for_test.rb
parente9791bec823e42372eca095b946c93c1712a0613 (diff)
downloadrails-6c95e0f879aafa5921cd7898d5951b9a926d3c9a.tar.gz
rails-6c95e0f879aafa5921cd7898d5951b9a926d3c9a.tar.bz2
rails-6c95e0f879aafa5921cd7898d5951b9a926d3c9a.zip
Add mounted_helpers to routes
mounted_helpers are a bit similar to url_helpers. They're automatically included in controllers for Rails.application and each of mounted Engines. Mounted helper allows to call url_for and named helpers for given application. Given Blog::Engine mounted as blog_engine, there are 2 helpers defined: app and blog_engine. You can call routes for app and engine using those helpers: app.root_url app.url_for(:controller => "foo") blog_engine.posts_path blog_engine.url_for(@post)
Diffstat (limited to 'actionpack/test/dispatch/url_for_test.rb')
-rw-r--r--actionpack/test/dispatch/url_for_test.rb52
1 files changed, 0 insertions, 52 deletions
diff --git a/actionpack/test/dispatch/url_for_test.rb b/actionpack/test/dispatch/url_for_test.rb
deleted file mode 100644
index 3dc96d27d7..0000000000
--- a/actionpack/test/dispatch/url_for_test.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-require 'abstract_unit'
-
-module UrlForGeneration
- class UrlForTest < ActionDispatch::IntegrationTest
-
- Routes = ActionDispatch::Routing::RouteSet.new
- Routes.draw { match "/foo", :to => "my_route_generating#index", :as => :foo }
-
- class BlogEngine
- def self.routes
- @routes ||= begin
- routes = ActionDispatch::Routing::RouteSet.new
- routes.draw do
- resources :posts
- end
- routes
- end
- end
- end
-
- class Post
- extend ActiveModel::Naming
-
- def to_param
- "1"
- end
-
- def self.model_name
- klass = "Post"
- def klass.name; self end
-
- ActiveModel::Name.new(klass)
- end
- end
-
- include Routes.url_helpers
-
- test "url_for with named url helpers" do
- assert_equal "/posts", url_for(BlogEngine, :posts_path)
- end
-
- test "url_for with polymorphic routes" do
- assert_equal "http://www.example.com/posts/1", url_for(BlogEngine, Post.new)
- end
-
- test "url_for with named url helper with arguments" do
- assert_equal "/posts/1", url_for(BlogEngine, :post_path, 1)
- assert_equal "/posts/1", url_for(BlogEngine, :post_path, :id => 1)
- assert_equal "/posts/1.json", url_for(BlogEngine, :post_path, :id => 1, :format => :json)
- end
- end
-end