summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-01-04 10:01:19 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-01-04 10:01:19 +0000
commitcda307dfd29360801334720835c42026f629984f (patch)
tree613fccba94f8340948cb1f4164725f4fa74122d3 /test/integration
parent6e17b5dccf90972d7fb44da18d0580ed99d27c4f (diff)
downloadredmine-cda307dfd29360801334720835c42026f629984f.tar.gz
redmine-cda307dfd29360801334720835c42026f629984f.zip
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
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/routing/repositories_test.rb51
1 files 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