@@ -1,129 +1,144 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
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', | |
24 | :path => "/projects/redmine/repository" }, |
|
30 | :path => "/projects/redmine/repository" }, | |
25 | { :controller => 'repositories', :action => 'show', :id => 'redmine' } |
|
31 | { :controller => 'repositories', :action => 'show', :id => 'redmine' } | |
26 | ) |
|
32 | ) | |
27 | ["get", "post"].each do |method| |
|
33 | ["get", "post"].each do |method| | |
28 | assert_routing( |
|
34 | assert_routing( | |
29 | { :method => method, |
|
35 | { :method => method, | |
30 | :path => "/projects/redmine/repository/edit" }, |
|
36 | :path => "/projects/redmine/repository/edit" }, | |
31 | { :controller => 'repositories', :action => 'edit', :id => 'redmine' } |
|
37 | { :controller => 'repositories', :action => 'edit', :id => 'redmine' } | |
32 | ) |
|
38 | ) | |
33 | end |
|
39 | end | |
34 | assert_routing( |
|
40 | assert_routing( | |
35 | { :method => 'get', |
|
41 | { :method => 'get', | |
36 | :path => "/projects/redmine/repository/statistics" }, |
|
42 | :path => "/projects/redmine/repository/statistics" }, | |
37 | { :controller => 'repositories', :action => 'stats', :id => 'redmine' } |
|
43 | { :controller => 'repositories', :action => 'stats', :id => 'redmine' } | |
38 | ) |
|
44 | ) | |
39 | end |
|
45 | end | |
40 |
|
46 | |||
41 | def test_repositories_revisions |
|
47 | def test_repositories_revisions | |
42 | assert_routing( |
|
48 | assert_routing( | |
43 | { :method => 'get', |
|
49 | { :method => 'get', | |
44 | :path => "/projects/redmine/repository/revisions" }, |
|
50 | :path => "/projects/redmine/repository/revisions" }, | |
45 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine' } |
|
51 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine' } | |
46 | ) |
|
52 | ) | |
47 | assert_routing( |
|
53 | assert_routing( | |
48 | { :method => 'get', |
|
54 | { :method => 'get', | |
49 | :path => "/projects/redmine/repository/revisions.atom" }, |
|
55 | :path => "/projects/redmine/repository/revisions.atom" }, | |
50 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', |
|
56 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', | |
51 | :format => 'atom' } |
|
57 | :format => 'atom' } | |
52 | ) |
|
58 | ) | |
53 | assert_routing( |
|
59 | assert_routing( | |
54 | { :method => 'get', |
|
60 | { :method => 'get', | |
55 | :path => "/projects/redmine/repository/revisions/2457" }, |
|
61 | :path => "/projects/redmine/repository/revisions/2457" }, | |
56 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', |
|
62 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', | |
57 | :rev => '2457' } |
|
63 | :rev => '2457' } | |
58 | ) |
|
64 | ) | |
59 | assert_routing( |
|
65 | assert_routing( | |
60 | { :method => 'get', |
|
66 | { :method => 'get', | |
61 | :path => "/projects/redmine/repository/revisions/2457/diff" }, |
|
67 | :path => "/projects/redmine/repository/revisions/2457/diff" }, | |
62 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
68 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', | |
63 | :rev => '2457' } |
|
69 | :rev => '2457' } | |
64 | ) |
|
70 | ) | |
65 | assert_routing( |
|
71 | assert_routing( | |
66 | { :method => 'get', |
|
72 | { :method => 'get', | |
67 | :path => "/projects/redmine/repository/revisions/2457/diff.diff" }, |
|
73 | :path => "/projects/redmine/repository/revisions/2457/diff.diff" }, | |
68 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
74 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', | |
69 | :rev => '2457', :format => 'diff' } |
|
75 | :rev => '2457', :format => 'diff' } | |
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