diff options
| author | José Valim <jose.valim@gmail.com> | 2010-06-23 00:43:25 +0200 | 
|---|---|---|
| committer | José Valim <jose.valim@gmail.com> | 2010-06-23 00:43:25 +0200 | 
| commit | 61317b643ae4ff61d458eb273aa86f6f7e780433 (patch) | |
| tree | fbbf58ade8703d3ef901380b18ed71b113ece611 | |
| parent | e5444f84dfa0237b1ffa758c940723852f366a9c (diff) | |
| download | rails-61317b643ae4ff61d458eb273aa86f6f7e780433.tar.gz rails-61317b643ae4ff61d458eb273aa86f6f7e780433.tar.bz2 rails-61317b643ae4ff61d458eb273aa86f6f7e780433.zip | |
Provive resources_path_names helpers in the router.
| -rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 4 | ||||
| -rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 11 | 
2 files changed, 15 insertions, 0 deletions
| diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 2005382b8e..f2c8e9e97e 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -577,6 +577,10 @@ module ActionDispatch            @scope[:path_names] = @set.resources_path_names          end +        def resources_path_names(options) +          @scope[:path_names].merge!(options) +        end +          def resource(*resources, &block)            options = resources.extract_options!            options = (@scope[:options] || {}).merge(options) diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index 51b241eb1f..4277321707 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -16,6 +16,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest      Routes = routes      Routes.draw do        default_url_options :host => "rubyonrails.org" +      resources_path_names :correlation_indexes => "info_about_correlation_indexes"        controller :sessions do          get  'login' => :new @@ -86,6 +87,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest        resources :projects, :controller => :project do          resources :involvements, :attachments +        get :correlation_indexes, :on => :collection          resources :participants do            put :update_all, :on => :collection @@ -112,6 +114,7 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest            end            member do +            get  :some_path_with_name              put  :accessible_projects              post :resend, :generate_new_password            end @@ -710,6 +713,14 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest      end    end +  def test_projects_with_resources_path_names +    with_test_routes do +      get '/projects/info_about_correlation_indexes' +      assert_equal 'project#correlation_indexes', @response.body +      assert_equal '/projects/info_about_correlation_indexes', correlation_indexes_projects_path +    end +  end +    def test_projects_posts      with_test_routes do        get '/projects/1/posts' | 
