@@ -1,129 +1,144 | |||
|
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 | 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', |
|
24 | 30 | :path => "/projects/redmine/repository" }, |
|
25 | 31 | { :controller => 'repositories', :action => 'show', :id => 'redmine' } |
|
26 | 32 | ) |
|
27 | 33 | ["get", "post"].each do |method| |
|
28 | 34 | assert_routing( |
|
29 | 35 | { :method => method, |
|
30 | 36 | :path => "/projects/redmine/repository/edit" }, |
|
31 | 37 | { :controller => 'repositories', :action => 'edit', :id => 'redmine' } |
|
32 | 38 | ) |
|
33 | 39 | end |
|
34 | 40 | assert_routing( |
|
35 | 41 | { :method => 'get', |
|
36 | 42 | :path => "/projects/redmine/repository/statistics" }, |
|
37 | 43 | { :controller => 'repositories', :action => 'stats', :id => 'redmine' } |
|
38 | 44 | ) |
|
39 | 45 | end |
|
40 | 46 | |
|
41 | 47 | def test_repositories_revisions |
|
42 | 48 | assert_routing( |
|
43 | 49 | { :method => 'get', |
|
44 | 50 | :path => "/projects/redmine/repository/revisions" }, |
|
45 | 51 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine' } |
|
46 | 52 | ) |
|
47 | 53 | assert_routing( |
|
48 | 54 | { :method => 'get', |
|
49 | 55 | :path => "/projects/redmine/repository/revisions.atom" }, |
|
50 | 56 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', |
|
51 | 57 | :format => 'atom' } |
|
52 | 58 | ) |
|
53 | 59 | assert_routing( |
|
54 | 60 | { :method => 'get', |
|
55 | 61 | :path => "/projects/redmine/repository/revisions/2457" }, |
|
56 | 62 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', |
|
57 | 63 | :rev => '2457' } |
|
58 | 64 | ) |
|
59 | 65 | assert_routing( |
|
60 | 66 | { :method => 'get', |
|
61 | 67 | :path => "/projects/redmine/repository/revisions/2457/diff" }, |
|
62 | 68 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
63 | 69 | :rev => '2457' } |
|
64 | 70 | ) |
|
65 | 71 | assert_routing( |
|
66 | 72 | { :method => 'get', |
|
67 | 73 | :path => "/projects/redmine/repository/revisions/2457/diff.diff" }, |
|
68 | 74 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
69 | 75 | :rev => '2457', :format => 'diff' } |
|
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