@@ -1,144 +1,175 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../../test_helper', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class RoutingRepositoriesTest < ActionController::IntegrationTest |
|
21 | 21 | def setup |
|
22 | 22 | @path_hash = repository_path_hash(%w[path to file.c]) |
|
23 | 23 | assert_equal "path/to/file.c", @path_hash[:path] |
|
24 | 24 | assert_equal %w[path to file.c], @path_hash[:param] |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | 27 | def test_repositories |
|
28 | 28 | assert_routing( |
|
29 | 29 | { :method => 'get', |
|
30 | 30 | :path => "/projects/redmine/repository" }, |
|
31 | 31 | { :controller => 'repositories', :action => 'show', :id => 'redmine' } |
|
32 | 32 | ) |
|
33 | 33 | ["get", "post"].each do |method| |
|
34 | 34 | assert_routing( |
|
35 | 35 | { :method => method, |
|
36 | 36 | :path => "/projects/redmine/repository/edit" }, |
|
37 | 37 | { :controller => 'repositories', :action => 'edit', :id => 'redmine' } |
|
38 | 38 | ) |
|
39 | 39 | end |
|
40 | 40 | assert_routing( |
|
41 | 41 | { :method => 'get', |
|
42 | 42 | :path => "/projects/redmine/repository/statistics" }, |
|
43 | 43 | { :controller => 'repositories', :action => 'stats', :id => 'redmine' } |
|
44 | 44 | ) |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | def test_repositories_revisions |
|
48 | empty_path_param = [] | |
|
48 | 49 | assert_routing( |
|
49 | 50 | { :method => 'get', |
|
50 | 51 | :path => "/projects/redmine/repository/revisions" }, |
|
51 | 52 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine' } |
|
52 | 53 | ) |
|
53 | 54 | assert_routing( |
|
54 | 55 | { :method => 'get', |
|
55 | 56 | :path => "/projects/redmine/repository/revisions.atom" }, |
|
56 | 57 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', |
|
57 | 58 | :format => 'atom' } |
|
58 | 59 | ) |
|
59 | 60 | assert_routing( |
|
60 | 61 | { :method => 'get', |
|
61 | 62 | :path => "/projects/redmine/repository/revisions/2457" }, |
|
62 | 63 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', |
|
63 | 64 | :rev => '2457' } |
|
64 | 65 | ) |
|
65 | 66 | assert_routing( |
|
66 | 67 | { :method => 'get', |
|
68 | :path => "/projects/redmine/repository/revisions/2457/show" }, | |
|
69 | { :controller => 'repositories', :action => 'show', :id => 'redmine', | |
|
70 | :path => empty_path_param, :rev => '2457' } | |
|
71 | ) | |
|
72 | assert_routing( | |
|
73 | { :method => 'get', | |
|
74 | :path => "/projects/redmine/repository/revisions/2457/show/#{@path_hash[:path]}" }, | |
|
75 | { :controller => 'repositories', :action => 'show', :id => 'redmine', | |
|
76 | :path => @path_hash[:param] , :rev => '2457'} | |
|
77 | ) | |
|
78 | assert_routing( | |
|
79 | { :method => 'get', | |
|
80 | :path => "/projects/redmine/repository/revisions/2457/changes" }, | |
|
81 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', | |
|
82 | :path => empty_path_param, :rev => '2457' } | |
|
83 | ) | |
|
84 | assert_routing( | |
|
85 | { :method => 'get', | |
|
86 | :path => "/projects/redmine/repository/revisions/2457/changes/#{@path_hash[:path]}" }, | |
|
87 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', | |
|
88 | :path => @path_hash[:param] , :rev => '2457'} | |
|
89 | ) | |
|
90 | assert_routing( | |
|
91 | { :method => 'get', | |
|
67 | 92 | :path => "/projects/redmine/repository/revisions/2457/diff" }, |
|
68 | 93 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
69 | 94 | :rev => '2457' } |
|
70 | 95 | ) |
|
71 | 96 | assert_routing( |
|
72 | 97 | { :method => 'get', |
|
73 | 98 | :path => "/projects/redmine/repository/revisions/2457/diff.diff" }, |
|
74 | 99 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
75 | 100 | :rev => '2457', :format => 'diff' } |
|
76 | 101 | ) |
|
77 | 102 | assert_routing( |
|
78 | 103 | { :method => 'get', |
|
79 | 104 | :path => "/projects/redmine/repository/revisions/2/diff/#{@path_hash[:path]}" }, |
|
80 | 105 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
81 | 106 | :path => @path_hash[:param], :rev => '2' } |
|
82 | 107 | ) |
|
83 | 108 | assert_routing( |
|
84 | 109 | { :method => 'get', |
|
85 | 110 | :path => "/projects/redmine/repository/revisions/2/entry/#{@path_hash[:path]}" }, |
|
86 | 111 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
87 | 112 | :path => @path_hash[:param], :rev => '2' } |
|
88 | 113 | ) |
|
89 | 114 | assert_routing( |
|
90 | 115 | { :method => 'get', |
|
91 | 116 | :path => "/projects/redmine/repository/revisions/2/raw/#{@path_hash[:path]}" }, |
|
92 | 117 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
93 | 118 | :path => @path_hash[:param], :rev => '2', :format => 'raw' } |
|
94 | 119 | ) |
|
120 | assert_routing( | |
|
121 | { :method => 'get', | |
|
122 | :path => "/projects/redmine/repository/revisions/2/annotate/#{@path_hash[:path]}" }, | |
|
123 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', | |
|
124 | :path => @path_hash[:param], :rev => '2' } | |
|
125 | ) | |
|
95 | 126 | end |
|
96 | 127 | |
|
97 | 128 | def test_repositories_non_revisions_path |
|
98 | 129 | assert_routing( |
|
99 | 130 | { :method => 'get', |
|
100 | 131 | :path => "/projects/redmine/repository/diff/#{@path_hash[:path]}" }, |
|
101 | 132 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
102 | 133 | :path => @path_hash[:param] } |
|
103 | 134 | ) |
|
104 | 135 | assert_routing( |
|
105 | 136 | { :method => 'get', |
|
106 | 137 | :path => "/projects/redmine/repository/browse/#{@path_hash[:path]}" }, |
|
107 | 138 | { :controller => 'repositories', :action => 'browse', :id => 'redmine', |
|
108 | 139 | :path => @path_hash[:param] } |
|
109 | 140 | ) |
|
110 | 141 | assert_routing( |
|
111 | 142 | { :method => 'get', |
|
112 | 143 | :path => "/projects/redmine/repository/entry/#{@path_hash[:path]}" }, |
|
113 | 144 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
114 | 145 | :path => @path_hash[:param] } |
|
115 | 146 | ) |
|
116 | 147 | assert_routing( |
|
117 | 148 | { :method => 'get', |
|
118 | 149 | :path => "/projects/redmine/repository/raw/#{@path_hash[:path]}" }, |
|
119 | 150 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
120 | 151 | :path => @path_hash[:param], :format => 'raw' } |
|
121 | 152 | ) |
|
122 | 153 | assert_routing( |
|
123 | 154 | { :method => 'get', |
|
124 | 155 | :path => "/projects/redmine/repository/annotate/#{@path_hash[:path]}" }, |
|
125 | 156 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', |
|
126 | 157 | :path => @path_hash[:param] } |
|
127 | 158 | ) |
|
128 | 159 | assert_routing( |
|
129 | 160 | { :method => 'get', |
|
130 | 161 | :path => "/projects/redmine/repository/changes/#{@path_hash[:path]}" }, |
|
131 | 162 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
132 | 163 | :path => @path_hash[:param] } |
|
133 | 164 | ) |
|
134 | 165 | end |
|
135 | 166 | |
|
136 | 167 | private |
|
137 | 168 | |
|
138 | 169 | def repository_path_hash(arr) |
|
139 | 170 | hs = {} |
|
140 | 171 | hs[:path] = arr.join("/") |
|
141 | 172 | hs[:param] = arr |
|
142 | 173 | hs |
|
143 | 174 | end |
|
144 | 175 | end |
General Comments 0
You need to be logged in to leave comments.
Login now