From cda307dfd29360801334720835c42026f629984f Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Wed, 4 Jan 2012 10:01:19 +0000 Subject: [PATCH] Rails3: test: route: add private method to convert path parameter at repositories test On Rails3, route returns "path/to/file.c" as :path parameter git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8498 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/integration/routing/repositories_test.rb | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/test/integration/routing/repositories_test.rb b/test/integration/routing/repositories_test.rb index 8caa0e9e6..2a88a9eae 100644 --- a/test/integration/routing/repositories_test.rb +++ b/test/integration/routing/repositories_test.rb @@ -18,6 +18,12 @@ require File.expand_path('../../../test_helper', __FILE__) class RoutingRepositoriesTest < ActionController::IntegrationTest + def setup + @path_hash = repository_path_hash(%w[path to file.c]) + assert_equal "path/to/file.c", @path_hash[:path] + assert_equal %w[path to file.c], @path_hash[:param] + end + def test_repositories assert_routing( { :method => 'get', @@ -70,60 +76,69 @@ class RoutingRepositoriesTest < ActionController::IntegrationTest ) assert_routing( { :method => 'get', - :path => "/projects/redmine/repository/revisions/2/diff/path/to/file.c" }, + :path => "/projects/redmine/repository/revisions/2/diff/#{@path_hash[:path]}" }, { :controller => 'repositories', :action => 'diff', :id => 'redmine', - :path => %w[path to file.c], :rev => '2' } + :path => @path_hash[:param], :rev => '2' } ) assert_routing( { :method => 'get', - :path => "/projects/redmine/repository/revisions/2/entry/path/to/file.c" }, + :path => "/projects/redmine/repository/revisions/2/entry/#{@path_hash[:path]}" }, { :controller => 'repositories', :action => 'entry', :id => 'redmine', - :path => %w[path to file.c], :rev => '2' } + :path => @path_hash[:param], :rev => '2' } ) assert_routing( { :method => 'get', - :path => "/projects/redmine/repository/revisions/2/raw/path/to/file.c" }, + :path => "/projects/redmine/repository/revisions/2/raw/#{@path_hash[:path]}" }, { :controller => 'repositories', :action => 'entry', :id => 'redmine', - :path => %w[path to file.c], :rev => '2', :format => 'raw' } + :path => @path_hash[:param], :rev => '2', :format => 'raw' } ) end def test_repositories_non_revisions_path assert_routing( { :method => 'get', - :path => "/projects/redmine/repository/diff/path/to/file.c" }, + :path => "/projects/redmine/repository/diff/#{@path_hash[:path]}" }, { :controller => 'repositories', :action => 'diff', :id => 'redmine', - :path => %w[path to file.c] } + :path => @path_hash[:param] } ) assert_routing( { :method => 'get', - :path => "/projects/redmine/repository/browse/path/to/file.c" }, + :path => "/projects/redmine/repository/browse/#{@path_hash[:path]}" }, { :controller => 'repositories', :action => 'browse', :id => 'redmine', - :path => %w[path to file.c] } + :path => @path_hash[:param] } ) assert_routing( { :method => 'get', - :path => "/projects/redmine/repository/entry/path/to/file.c" }, + :path => "/projects/redmine/repository/entry/#{@path_hash[:path]}" }, { :controller => 'repositories', :action => 'entry', :id => 'redmine', - :path => %w[path to file.c] } + :path => @path_hash[:param] } ) assert_routing( { :method => 'get', - :path => "/projects/redmine/repository/raw/path/to/file.c" }, + :path => "/projects/redmine/repository/raw/#{@path_hash[:path]}" }, { :controller => 'repositories', :action => 'entry', :id => 'redmine', - :path => %w[path to file.c], :format => 'raw' } + :path => @path_hash[:param], :format => 'raw' } ) assert_routing( { :method => 'get', - :path => "/projects/redmine/repository/annotate/path/to/file.c" }, + :path => "/projects/redmine/repository/annotate/#{@path_hash[:path]}" }, { :controller => 'repositories', :action => 'annotate', :id => 'redmine', - :path => %w[path to file.c] } + :path => @path_hash[:param] } ) assert_routing( { :method => 'get', - :path => "/projects/redmine/repository/changes/path/to/file.c" }, + :path => "/projects/redmine/repository/changes/#{@path_hash[:path]}" }, { :controller => 'repositories', :action => 'changes', :id => 'redmine', - :path => %w[path to file.c] } + :path => @path_hash[:param] } ) end + +private + + def repository_path_hash(arr) + hs = {} + hs[:path] = arr.join("/") + hs[:param] = arr + hs + end end -- 2.39.5