@@ -18,6 +18,12 | |||||
18 | require File.expand_path('../../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class RoutingRepositoriesTest < ActionController::IntegrationTest |
|
20 | class RoutingRepositoriesTest < ActionController::IntegrationTest | |
|
21 | def setup | |||
|
22 | @path_hash = repository_path_hash(%w[path to file.c]) | |||
|
23 | assert_equal "path/to/file.c", @path_hash[:path] | |||
|
24 | assert_equal %w[path to file.c], @path_hash[:param] | |||
|
25 | end | |||
|
26 | ||||
21 | def test_repositories |
|
27 | def test_repositories | |
22 | assert_routing( |
|
28 | assert_routing( | |
23 | { :method => 'get', |
|
29 | { :method => 'get', | |
@@ -70,60 +76,69 class RoutingRepositoriesTest < ActionController::IntegrationTest | |||||
70 | ) |
|
76 | ) | |
71 | assert_routing( |
|
77 | assert_routing( | |
72 | { :method => 'get', |
|
78 | { :method => 'get', | |
73 |
:path => "/projects/redmine/repository/revisions/2/diff/ |
|
79 | :path => "/projects/redmine/repository/revisions/2/diff/#{@path_hash[:path]}" }, | |
74 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
80 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', | |
75 |
:path => |
|
81 | :path => @path_hash[:param], :rev => '2' } | |
76 | ) |
|
82 | ) | |
77 | assert_routing( |
|
83 | assert_routing( | |
78 | { :method => 'get', |
|
84 | { :method => 'get', | |
79 |
:path => "/projects/redmine/repository/revisions/2/entry/ |
|
85 | :path => "/projects/redmine/repository/revisions/2/entry/#{@path_hash[:path]}" }, | |
80 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
86 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', | |
81 |
:path => |
|
87 | :path => @path_hash[:param], :rev => '2' } | |
82 | ) |
|
88 | ) | |
83 | assert_routing( |
|
89 | assert_routing( | |
84 | { :method => 'get', |
|
90 | { :method => 'get', | |
85 |
:path => "/projects/redmine/repository/revisions/2/raw/ |
|
91 | :path => "/projects/redmine/repository/revisions/2/raw/#{@path_hash[:path]}" }, | |
86 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
92 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', | |
87 |
:path => |
|
93 | :path => @path_hash[:param], :rev => '2', :format => 'raw' } | |
88 | ) |
|
94 | ) | |
89 | end |
|
95 | end | |
90 |
|
96 | |||
91 | def test_repositories_non_revisions_path |
|
97 | def test_repositories_non_revisions_path | |
92 | assert_routing( |
|
98 | assert_routing( | |
93 | { :method => 'get', |
|
99 | { :method => 'get', | |
94 |
:path => "/projects/redmine/repository/diff/ |
|
100 | :path => "/projects/redmine/repository/diff/#{@path_hash[:path]}" }, | |
95 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
101 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', | |
96 |
:path => |
|
102 | :path => @path_hash[:param] } | |
97 | ) |
|
103 | ) | |
98 | assert_routing( |
|
104 | assert_routing( | |
99 | { :method => 'get', |
|
105 | { :method => 'get', | |
100 |
:path => "/projects/redmine/repository/browse/ |
|
106 | :path => "/projects/redmine/repository/browse/#{@path_hash[:path]}" }, | |
101 | { :controller => 'repositories', :action => 'browse', :id => 'redmine', |
|
107 | { :controller => 'repositories', :action => 'browse', :id => 'redmine', | |
102 |
:path => |
|
108 | :path => @path_hash[:param] } | |
103 | ) |
|
109 | ) | |
104 | assert_routing( |
|
110 | assert_routing( | |
105 | { :method => 'get', |
|
111 | { :method => 'get', | |
106 |
:path => "/projects/redmine/repository/entry/ |
|
112 | :path => "/projects/redmine/repository/entry/#{@path_hash[:path]}" }, | |
107 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
113 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', | |
108 |
:path => |
|
114 | :path => @path_hash[:param] } | |
109 | ) |
|
115 | ) | |
110 | assert_routing( |
|
116 | assert_routing( | |
111 | { :method => 'get', |
|
117 | { :method => 'get', | |
112 |
:path => "/projects/redmine/repository/raw/ |
|
118 | :path => "/projects/redmine/repository/raw/#{@path_hash[:path]}" }, | |
113 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
119 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', | |
114 |
:path => |
|
120 | :path => @path_hash[:param], :format => 'raw' } | |
115 | ) |
|
121 | ) | |
116 | assert_routing( |
|
122 | assert_routing( | |
117 | { :method => 'get', |
|
123 | { :method => 'get', | |
118 |
:path => "/projects/redmine/repository/annotate/ |
|
124 | :path => "/projects/redmine/repository/annotate/#{@path_hash[:path]}" }, | |
119 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', |
|
125 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', | |
120 |
:path => |
|
126 | :path => @path_hash[:param] } | |
121 | ) |
|
127 | ) | |
122 | assert_routing( |
|
128 | assert_routing( | |
123 | { :method => 'get', |
|
129 | { :method => 'get', | |
124 |
:path => "/projects/redmine/repository/changes/ |
|
130 | :path => "/projects/redmine/repository/changes/#{@path_hash[:path]}" }, | |
125 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
131 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', | |
126 |
:path => |
|
132 | :path => @path_hash[:param] } | |
127 | ) |
|
133 | ) | |
128 | end |
|
134 | end | |
|
135 | ||||
|
136 | private | |||
|
137 | ||||
|
138 | def repository_path_hash(arr) | |||
|
139 | hs = {} | |||
|
140 | hs[:path] = arr.join("/") | |||
|
141 | hs[:param] = arr | |||
|
142 | hs | |||
|
143 | end | |||
129 | end |
|
144 | end |
General Comments 0
You need to be logged in to leave comments.
Login now