##// END OF EJS Templates
Use /raw/ for url instead of ?format=raw for getting raw repository files (#1901, #4119)....
Jean-Philippe Lang -
r2960:e24358bc4374
parent child
Show More
@@ -1,268 +1,272
1 1 ActionController::Routing::Routes.draw do |map|
2 2 # Add your own custom routes here.
3 3 # The priority is based upon order of creation: first created -> highest priority.
4 4
5 5 # Here's a sample route:
6 6 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7 7 # Keep in mind you can assign values other than :controller and :action
8 8
9 9 map.home '', :controller => 'welcome'
10 10
11 11 map.signin 'login', :controller => 'account', :action => 'login'
12 12 map.signout 'logout', :controller => 'account', :action => 'logout'
13 13
14 14 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
15 15 map.connect 'help/:ctrl/:page', :controller => 'help'
16 16
17 17 map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog'
18 18 map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog'
19 19 map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog'
20 20
21 21 map.with_options :controller => 'timelog' do |timelog|
22 22 timelog.connect 'projects/:project_id/time_entries', :action => 'details'
23 23
24 24 timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details|
25 25 time_details.connect 'time_entries'
26 26 time_details.connect 'time_entries.:format'
27 27 time_details.connect 'issues/:issue_id/time_entries'
28 28 time_details.connect 'issues/:issue_id/time_entries.:format'
29 29 time_details.connect 'projects/:project_id/time_entries.:format'
30 30 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries'
31 31 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format'
32 32 end
33 33 timelog.connect 'projects/:project_id/time_entries/report', :action => 'report'
34 34 timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report|
35 35 time_report.connect 'time_entries/report'
36 36 time_report.connect 'time_entries/report.:format'
37 37 time_report.connect 'projects/:project_id/time_entries/report.:format'
38 38 end
39 39
40 40 timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit|
41 41 time_edit.connect 'issues/:issue_id/time_entries/new'
42 42 end
43 43
44 44 timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
45 45 end
46 46
47 47 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
48 48 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
49 49 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
50 50 map.with_options :controller => 'wiki' do |wiki_routes|
51 51 wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
52 52 wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i
53 53 wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
54 54 wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
55 55 wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
56 56 wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
57 57 wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
58 58 wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
59 59 end
60 60
61 61 wiki_routes.connect 'projects/:id/wiki/:page/:action',
62 62 :action => /edit|rename|destroy|preview|protect/,
63 63 :conditions => {:method => :post}
64 64 end
65 65
66 66 map.with_options :controller => 'messages' do |messages_routes|
67 67 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
68 68 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
69 69 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
70 70 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
71 71 end
72 72 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
73 73 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
74 74 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
75 75 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
76 76 end
77 77 end
78 78
79 79 map.with_options :controller => 'boards' do |board_routes|
80 80 board_routes.with_options :conditions => {:method => :get} do |board_views|
81 81 board_views.connect 'projects/:project_id/boards', :action => 'index'
82 82 board_views.connect 'projects/:project_id/boards/new', :action => 'new'
83 83 board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
84 84 board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show'
85 85 board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
86 86 end
87 87 board_routes.with_options :conditions => {:method => :post} do |board_actions|
88 88 board_actions.connect 'projects/:project_id/boards', :action => 'new'
89 89 board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
90 90 end
91 91 end
92 92
93 93 map.with_options :controller => 'documents' do |document_routes|
94 94 document_routes.with_options :conditions => {:method => :get} do |document_views|
95 95 document_views.connect 'projects/:project_id/documents', :action => 'index'
96 96 document_views.connect 'projects/:project_id/documents/new', :action => 'new'
97 97 document_views.connect 'documents/:id', :action => 'show'
98 98 document_views.connect 'documents/:id/edit', :action => 'edit'
99 99 end
100 100 document_routes.with_options :conditions => {:method => :post} do |document_actions|
101 101 document_actions.connect 'projects/:project_id/documents', :action => 'new'
102 102 document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
103 103 end
104 104 end
105 105
106 106 map.with_options :controller => 'issues' do |issues_routes|
107 107 issues_routes.with_options :conditions => {:method => :get} do |issues_views|
108 108 issues_views.connect 'issues', :action => 'index'
109 109 issues_views.connect 'issues.:format', :action => 'index'
110 110 issues_views.connect 'projects/:project_id/issues', :action => 'index'
111 111 issues_views.connect 'projects/:project_id/issues.:format', :action => 'index'
112 112 issues_views.connect 'projects/:project_id/issues/new', :action => 'new'
113 113 issues_views.connect 'projects/:project_id/issues/gantt', :action => 'gantt'
114 114 issues_views.connect 'projects/:project_id/issues/calendar', :action => 'calendar'
115 115 issues_views.connect 'projects/:project_id/issues/:copy_from/copy', :action => 'new'
116 116 issues_views.connect 'issues/:id', :action => 'show', :id => /\d+/
117 117 issues_views.connect 'issues/:id.:format', :action => 'show', :id => /\d+/
118 118 issues_views.connect 'issues/:id/edit', :action => 'edit', :id => /\d+/
119 119 issues_views.connect 'issues/:id/move', :action => 'move', :id => /\d+/
120 120 end
121 121 issues_routes.with_options :conditions => {:method => :post} do |issues_actions|
122 122 issues_actions.connect 'projects/:project_id/issues', :action => 'new'
123 123 issues_actions.connect 'issues/:id/quoted', :action => 'reply', :id => /\d+/
124 124 issues_actions.connect 'issues/:id/:action', :action => /edit|move|destroy/, :id => /\d+/
125 125 end
126 126 issues_routes.connect 'issues/:action'
127 127 end
128 128
129 129 map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
130 130 relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
131 131 relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
132 132 end
133 133
134 134 map.with_options :controller => 'reports', :action => 'issue_report', :conditions => {:method => :get} do |reports|
135 135 reports.connect 'projects/:id/issues/report'
136 136 reports.connect 'projects/:id/issues/report/:detail'
137 137 end
138 138
139 139 map.with_options :controller => 'news' do |news_routes|
140 140 news_routes.with_options :conditions => {:method => :get} do |news_views|
141 141 news_views.connect 'news', :action => 'index'
142 142 news_views.connect 'projects/:project_id/news', :action => 'index'
143 143 news_views.connect 'projects/:project_id/news.:format', :action => 'index'
144 144 news_views.connect 'news.:format', :action => 'index'
145 145 news_views.connect 'projects/:project_id/news/new', :action => 'new'
146 146 news_views.connect 'news/:id', :action => 'show'
147 147 news_views.connect 'news/:id/edit', :action => 'edit'
148 148 end
149 149 news_routes.with_options do |news_actions|
150 150 news_actions.connect 'projects/:project_id/news', :action => 'new'
151 151 news_actions.connect 'news/:id/edit', :action => 'edit'
152 152 news_actions.connect 'news/:id/destroy', :action => 'destroy'
153 153 end
154 154 end
155 155
156 156 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
157 157
158 158 map.with_options :controller => 'users' do |users|
159 159 users.with_options :conditions => {:method => :get} do |user_views|
160 160 user_views.connect 'users', :action => 'index'
161 161 user_views.connect 'users/:id', :action => 'show', :id => /\d+/
162 162 user_views.connect 'users/new', :action => 'add'
163 163 user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil
164 164 end
165 165 users.with_options :conditions => {:method => :post} do |user_actions|
166 166 user_actions.connect 'users', :action => 'add'
167 167 user_actions.connect 'users/new', :action => 'add'
168 168 user_actions.connect 'users/:id/edit', :action => 'edit'
169 169 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
170 170 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
171 171 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
172 172 end
173 173 end
174 174
175 175 map.with_options :controller => 'projects' do |projects|
176 176 projects.with_options :conditions => {:method => :get} do |project_views|
177 177 project_views.connect 'projects', :action => 'index'
178 178 project_views.connect 'projects.:format', :action => 'index'
179 179 project_views.connect 'projects/new', :action => 'add'
180 180 project_views.connect 'projects/:id', :action => 'show'
181 181 project_views.connect 'projects/:id/:action', :action => /roadmap|changelog|destroy|settings/
182 182 project_views.connect 'projects/:id/files', :action => 'list_files'
183 183 project_views.connect 'projects/:id/files/new', :action => 'add_file'
184 184 project_views.connect 'projects/:id/versions/new', :action => 'add_version'
185 185 project_views.connect 'projects/:id/categories/new', :action => 'add_issue_category'
186 186 project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
187 187 end
188 188
189 189 projects.with_options :action => 'activity', :conditions => {:method => :get} do |activity|
190 190 activity.connect 'projects/:id/activity'
191 191 activity.connect 'projects/:id/activity.:format'
192 192 activity.connect 'activity', :id => nil
193 193 activity.connect 'activity.:format', :id => nil
194 194 end
195 195
196 196 projects.with_options :conditions => {:method => :post} do |project_actions|
197 197 project_actions.connect 'projects/new', :action => 'add'
198 198 project_actions.connect 'projects', :action => 'add'
199 199 project_actions.connect 'projects/:id/:action', :action => /destroy|archive|unarchive/
200 200 project_actions.connect 'projects/:id/files/new', :action => 'add_file'
201 201 project_actions.connect 'projects/:id/versions/new', :action => 'add_version'
202 202 project_actions.connect 'projects/:id/categories/new', :action => 'add_issue_category'
203 203 project_actions.connect 'projects/:id/activities/save', :action => 'save_activities'
204 204 end
205 205
206 206 projects.with_options :conditions => {:method => :delete} do |project_actions|
207 207 project_actions.conditions 'projects/:id/reset_activities', :action => 'reset_activities'
208 208 end
209 209 end
210 210
211 211 map.with_options :controller => 'versions' do |versions|
212 212 versions.with_options :conditions => {:method => :post} do |version_actions|
213 213 version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed'
214 214 end
215 215 end
216 216
217 217 map.with_options :controller => 'repositories' do |repositories|
218 218 repositories.with_options :conditions => {:method => :get} do |repository_views|
219 219 repository_views.connect 'projects/:id/repository', :action => 'show'
220 220 repository_views.connect 'projects/:id/repository/edit', :action => 'edit'
221 221 repository_views.connect 'projects/:id/repository/statistics', :action => 'stats'
222 222 repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions'
223 223 repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
224 224 repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
225 225 repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
226 226 repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
227 repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
227 228 repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ }
229 repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw'
230 # TODO: why the following route is required?
231 repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry'
228 232 repository_views.connect 'projects/:id/repository/:action/*path'
229 233 end
230 234
231 235 repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
232 236 end
233 237
234 238 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
235 239 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
236 240 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
237 241
238 242 map.resources :groups
239 243
240 244 #left old routes at the bottom for backwards compat
241 245 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
242 246 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
243 247 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
244 248 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
245 249 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
246 250 map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
247 251 map.connect 'projects/:project_id/news/:action', :controller => 'news'
248 252 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
249 253 map.with_options :controller => 'repositories' do |omap|
250 254 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
251 255 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
252 256 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
253 257 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
254 258 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
255 259 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
256 260 end
257 261
258 262 map.with_options :controller => 'sys' do |sys|
259 263 sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get}
260 264 sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post}
261 265 end
262 266
263 267 # Install the default route as the lowest priority.
264 268 map.connect ':controller/:action/:id'
265 269 map.connect 'robots.txt', :controller => 'welcome', :action => 'robots'
266 270 # Used for OpenID
267 271 map.root :controller => 'account', :action => 'login'
268 272 end
@@ -1,214 +1,228
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper'
19 19 require 'repositories_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class RepositoriesController; def rescue_action(e) raise e end; end
23 23
24 24 class RepositoriesControllerTest < ActionController::TestCase
25 25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
26 26
27 27 def setup
28 28 @controller = RepositoriesController.new
29 29 @request = ActionController::TestRequest.new
30 30 @response = ActionController::TestResponse.new
31 31 User.current = nil
32 32 end
33 33
34 34 def test_show_routing
35 35 assert_routing(
36 36 {:method => :get, :path => '/projects/redmine/repository'},
37 37 :controller => 'repositories', :action => 'show', :id => 'redmine'
38 38 )
39 39 end
40 40
41 41 def test_edit_routing
42 42 assert_routing(
43 43 {:method => :get, :path => '/projects/world_domination/repository/edit'},
44 44 :controller => 'repositories', :action => 'edit', :id => 'world_domination'
45 45 )
46 46 assert_routing(
47 47 {:method => :post, :path => '/projects/world_domination/repository/edit'},
48 48 :controller => 'repositories', :action => 'edit', :id => 'world_domination'
49 49 )
50 50 end
51 51
52 52 def test_revisions_routing
53 53 assert_routing(
54 54 {:method => :get, :path => '/projects/redmine/repository/revisions'},
55 55 :controller => 'repositories', :action => 'revisions', :id => 'redmine'
56 56 )
57 57 end
58 58
59 59 def test_revisions_atom_routing
60 60 assert_routing(
61 61 {:method => :get, :path => '/projects/redmine/repository/revisions.atom'},
62 62 :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
63 63 )
64 64 end
65 65
66 66 def test_revisions
67 67 get :revisions, :id => 1
68 68 assert_response :success
69 69 assert_template 'revisions'
70 70 assert_not_nil assigns(:changesets)
71 71 end
72 72
73 73 def test_revision_routing
74 74 assert_routing(
75 75 {:method => :get, :path => '/projects/restmine/repository/revisions/2457'},
76 76 :controller => 'repositories', :action => 'revision', :id => 'restmine', :rev => '2457'
77 77 )
78 78 end
79 79
80 80 def test_revision
81 81 get :revision, :id => 1, :rev => 1
82 82 assert_response :success
83 83 assert_not_nil assigns(:changeset)
84 84 assert_equal "1", assigns(:changeset).revision
85 85 end
86 86
87 87 def test_revision_with_before_nil_and_afer_normal
88 88 get :revision, {:id => 1, :rev => 1}
89 89 assert_response :success
90 90 assert_template 'revision'
91 91 assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
92 92 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/0'}
93 93 }
94 94 assert_tag :tag => "div", :attributes => { :class => "contextual" },
95 95 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'}
96 96 }
97 97 end
98 98
99 99 def test_diff_routing
100 100 assert_routing(
101 101 {:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff'},
102 102 :controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457'
103 103 )
104 104 end
105 105
106 106 def test_unified_diff_routing
107 107 assert_routing(
108 108 {:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff.diff'},
109 109 :controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457', :format => 'diff'
110 110 )
111 111 end
112 112
113 113 def test_diff_path_routing
114 114 assert_routing(
115 115 {:method => :get, :path => '/projects/restmine/repository/diff/path/to/file.c'},
116 116 :controller => 'repositories', :action => 'diff', :id => 'restmine', :path => %w[path to file.c]
117 117 )
118 118 end
119 119
120 120 def test_diff_path_routing_with_revision
121 121 assert_routing(
122 122 {:method => :get, :path => '/projects/restmine/repository/revisions/2/diff/path/to/file.c'},
123 123 :controller => 'repositories', :action => 'diff', :id => 'restmine', :path => %w[path to file.c], :rev => '2'
124 124 )
125 125 end
126 126
127 127 def test_browse_routing
128 128 assert_routing(
129 129 {:method => :get, :path => '/projects/restmine/repository/browse/path/to/dir'},
130 130 :controller => 'repositories', :action => 'browse', :id => 'restmine', :path => %w[path to dir]
131 131 )
132 132 end
133 133
134 134 def test_entry_routing
135 135 assert_routing(
136 136 {:method => :get, :path => '/projects/restmine/repository/entry/path/to/file.c'},
137 137 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c]
138 138 )
139 139 end
140 140
141 141 def test_entry_routing_with_revision
142 142 assert_routing(
143 143 {:method => :get, :path => '/projects/restmine/repository/revisions/2/entry/path/to/file.c'},
144 144 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c], :rev => '2'
145 145 )
146 146 end
147 147
148 def test_raw_routing
149 assert_routing(
150 {:method => :get, :path => '/projects/restmine/repository/raw/path/to/file.c'},
151 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c], :format => 'raw'
152 )
153 end
154
155 def test_raw_routing_with_revision
156 assert_routing(
157 {:method => :get, :path => '/projects/restmine/repository/revisions/2/raw/path/to/file.c'},
158 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c], :format => 'raw', :rev => '2'
159 )
160 end
161
148 162 def test_annotate_routing
149 163 assert_routing(
150 164 {:method => :get, :path => '/projects/restmine/repository/annotate/path/to/file.c'},
151 165 :controller => 'repositories', :action => 'annotate', :id => 'restmine', :path => %w[path to file.c]
152 166 )
153 167 end
154 168
155 169 def test_changesrouting
156 170 assert_routing(
157 171 {:method => :get, :path => '/projects/restmine/repository/changes/path/to/file.c'},
158 172 :controller => 'repositories', :action => 'changes', :id => 'restmine', :path => %w[path to file.c]
159 173 )
160 174 end
161 175
162 176 def test_statistics_routing
163 177 assert_routing(
164 178 {:method => :get, :path => '/projects/restmine/repository/statistics'},
165 179 :controller => 'repositories', :action => 'stats', :id => 'restmine'
166 180 )
167 181 end
168 182
169 183 def test_graph_commits_per_month
170 184 get :graph, :id => 1, :graph => 'commits_per_month'
171 185 assert_response :success
172 186 assert_equal 'image/svg+xml', @response.content_type
173 187 end
174 188
175 189 def test_graph_commits_per_author
176 190 get :graph, :id => 1, :graph => 'commits_per_author'
177 191 assert_response :success
178 192 assert_equal 'image/svg+xml', @response.content_type
179 193 end
180 194
181 195 def test_committers
182 196 @request.session[:user_id] = 2
183 197 # add a commit with an unknown user
184 198 Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
185 199
186 200 get :committers, :id => 1
187 201 assert_response :success
188 202 assert_template 'committers'
189 203
190 204 assert_tag :td, :content => 'dlopper',
191 205 :sibling => { :tag => 'td',
192 206 :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} },
193 207 :child => { :tag => 'option', :content => 'Dave Lopper',
194 208 :attributes => { :value => '3', :selected => 'selected' }}}}
195 209 assert_tag :td, :content => 'foo',
196 210 :sibling => { :tag => 'td',
197 211 :child => { :tag => 'select', :attributes => { :name => %r{^committers\[\d+\]\[\]$} }}}
198 212 assert_no_tag :td, :content => 'foo',
199 213 :sibling => { :tag => 'td',
200 214 :descendant => { :tag => 'option', :attributes => { :selected => 'selected' }}}
201 215 end
202 216
203 217 def test_map_committers
204 218 @request.session[:user_id] = 2
205 219 # add a commit with an unknown user
206 220 c = Changeset.create!(:repository => Project.find(1).repository, :committer => 'foo', :committed_on => Time.now, :revision => 100, :comments => 'Committed by foo.')
207 221
208 222 assert_no_difference "Changeset.count(:conditions => 'user_id = 3')" do
209 223 post :committers, :id => 1, :committers => { '0' => ['foo', '2'], '1' => ['dlopper', '3']}
210 224 assert_redirected_to 'projects/ecookbook/repository/committers'
211 225 assert_equal User.find(2), c.reload.user
212 226 end
213 227 end
214 228 end
General Comments 0
You need to be logged in to leave comments. Login now