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