##// END OF EJS Templates
test: route: simplify repositories test...
Toshi MARUYAMA -
r8376:5636228f798a
parent child
Show More
@@ -1,132 +1,129
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 test_repositories
21 def test_repositories
22 assert_routing(
22 assert_routing(
23 { :method => 'get',
23 { :method => 'get',
24 :path => "/projects/redmine/repository" },
24 :path => "/projects/redmine/repository" },
25 { :controller => 'repositories', :action => 'show', :id => 'redmine' }
25 { :controller => 'repositories', :action => 'show', :id => 'redmine' }
26 )
26 )
27 ["get", "post"].each do |method|
28 assert_routing(
29 { :method => method,
30 :path => "/projects/redmine/repository/edit" },
31 { :controller => 'repositories', :action => 'edit', :id => 'redmine' }
32 )
33 end
27 assert_routing(
34 assert_routing(
28 { :method => 'get',
35 { :method => 'get',
29 :path => "/projects/redmine/repository/edit" },
36 :path => "/projects/redmine/repository/statistics" },
30 { :controller => 'repositories', :action => 'edit', :id => 'redmine' }
37 { :controller => 'repositories', :action => 'stats', :id => 'redmine' }
31 )
38 )
32 end
39 end
33
40
34 def test_repositories_revisions
41 def test_repositories_revisions
35 assert_routing(
42 assert_routing(
36 { :method => 'get',
43 { :method => 'get',
37 :path => "/projects/redmine/repository/revisions" },
44 :path => "/projects/redmine/repository/revisions" },
38 { :controller => 'repositories', :action => 'revisions', :id => 'redmine' }
45 { :controller => 'repositories', :action => 'revisions', :id => 'redmine' }
39 )
46 )
40 assert_routing(
47 assert_routing(
41 { :method => 'get',
48 { :method => 'get',
42 :path => "/projects/redmine/repository/revisions.atom" },
49 :path => "/projects/redmine/repository/revisions.atom" },
43 { :controller => 'repositories', :action => 'revisions', :id => 'redmine',
50 { :controller => 'repositories', :action => 'revisions', :id => 'redmine',
44 :format => 'atom' }
51 :format => 'atom' }
45 )
52 )
46 assert_routing(
53 assert_routing(
47 { :method => 'get',
54 { :method => 'get',
48 :path => "/projects/redmine/repository/revisions/2457" },
55 :path => "/projects/redmine/repository/revisions/2457" },
49 { :controller => 'repositories', :action => 'revision', :id => 'redmine',
56 { :controller => 'repositories', :action => 'revision', :id => 'redmine',
50 :rev => '2457' }
57 :rev => '2457' }
51 )
58 )
52 assert_routing(
59 assert_routing(
53 { :method => 'get',
60 { :method => 'get',
54 :path => "/projects/redmine/repository/revisions/2457/diff" },
61 :path => "/projects/redmine/repository/revisions/2457/diff" },
55 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
62 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
56 :rev => '2457' }
63 :rev => '2457' }
57 )
64 )
58 assert_routing(
65 assert_routing(
59 { :method => 'get',
66 { :method => 'get',
60 :path => "/projects/redmine/repository/revisions/2457/diff.diff" },
67 :path => "/projects/redmine/repository/revisions/2457/diff.diff" },
61 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
68 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
62 :rev => '2457', :format => 'diff' }
69 :rev => '2457', :format => 'diff' }
63 )
70 )
64 assert_routing(
71 assert_routing(
65 { :method => 'get',
72 { :method => 'get',
66 :path => "/projects/redmine/repository/revisions/2/diff/path/to/file.c" },
73 :path => "/projects/redmine/repository/revisions/2/diff/path/to/file.c" },
67 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
74 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
68 :path => %w[path to file.c], :rev => '2' }
75 :path => %w[path to file.c], :rev => '2' }
69 )
76 )
70 assert_routing(
77 assert_routing(
71 { :method => 'get',
78 { :method => 'get',
72 :path => "/projects/redmine/repository/revisions/2/entry/path/to/file.c" },
79 :path => "/projects/redmine/repository/revisions/2/entry/path/to/file.c" },
73 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
80 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
74 :path => %w[path to file.c], :rev => '2' }
81 :path => %w[path to file.c], :rev => '2' }
75 )
82 )
76 assert_routing(
83 assert_routing(
77 { :method => 'get',
84 { :method => 'get',
78 :path => "/projects/redmine/repository/revisions/2/raw/path/to/file.c" },
85 :path => "/projects/redmine/repository/revisions/2/raw/path/to/file.c" },
79 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
86 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
80 :path => %w[path to file.c], :rev => '2', :format => 'raw' }
87 :path => %w[path to file.c], :rev => '2', :format => 'raw' }
81 )
88 )
82 end
89 end
83
90
84 def test_repositories_etc
91 def test_repositories_non_revisions_path
85 assert_routing(
92 assert_routing(
86 { :method => 'get',
93 { :method => 'get',
87 :path => "/projects/redmine/repository/diff/path/to/file.c" },
94 :path => "/projects/redmine/repository/diff/path/to/file.c" },
88 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
95 { :controller => 'repositories', :action => 'diff', :id => 'redmine',
89 :path => %w[path to file.c] }
96 :path => %w[path to file.c] }
90 )
97 )
91 assert_routing(
98 assert_routing(
92 { :method => 'get',
99 { :method => 'get',
93 :path => "/projects/redmine/repository/browse/path/to/file.c" },
100 :path => "/projects/redmine/repository/browse/path/to/file.c" },
94 { :controller => 'repositories', :action => 'browse', :id => 'redmine',
101 { :controller => 'repositories', :action => 'browse', :id => 'redmine',
95 :path => %w[path to file.c] }
102 :path => %w[path to file.c] }
96 )
103 )
97 assert_routing(
104 assert_routing(
98 { :method => 'get',
105 { :method => 'get',
99 :path => "/projects/redmine/repository/entry/path/to/file.c" },
106 :path => "/projects/redmine/repository/entry/path/to/file.c" },
100 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
107 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
101 :path => %w[path to file.c] }
108 :path => %w[path to file.c] }
102 )
109 )
103 assert_routing(
110 assert_routing(
104 { :method => 'get',
111 { :method => 'get',
105 :path => "/projects/redmine/repository/raw/path/to/file.c" },
112 :path => "/projects/redmine/repository/raw/path/to/file.c" },
106 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
113 { :controller => 'repositories', :action => 'entry', :id => 'redmine',
107 :path => %w[path to file.c], :format => 'raw' }
114 :path => %w[path to file.c], :format => 'raw' }
108 )
115 )
109 assert_routing(
116 assert_routing(
110 { :method => 'get',
117 { :method => 'get',
111 :path => "/projects/redmine/repository/annotate/path/to/file.c" },
118 :path => "/projects/redmine/repository/annotate/path/to/file.c" },
112 { :controller => 'repositories', :action => 'annotate', :id => 'redmine',
119 { :controller => 'repositories', :action => 'annotate', :id => 'redmine',
113 :path => %w[path to file.c] }
120 :path => %w[path to file.c] }
114 )
121 )
115 assert_routing(
122 assert_routing(
116 { :method => 'get',
123 { :method => 'get',
117 :path => "/projects/redmine/repository/changes/path/to/file.c" },
124 :path => "/projects/redmine/repository/changes/path/to/file.c" },
118 { :controller => 'repositories', :action => 'changes', :id => 'redmine',
125 { :controller => 'repositories', :action => 'changes', :id => 'redmine',
119 :path => %w[path to file.c] }
126 :path => %w[path to file.c] }
120 )
127 )
121 assert_routing(
122 { :method => 'get',
123 :path => "/projects/redmine/repository/statistics" },
124 { :controller => 'repositories', :action => 'stats', :id => 'redmine' }
125 )
126 assert_routing(
127 { :method => 'post',
128 :path => "/projects/redmine/repository/edit" },
129 { :controller => 'repositories', :action => 'edit', :id => 'redmine' }
130 )
131 end
128 end
132 end
129 end
General Comments 0
You need to be logged in to leave comments. Login now