@@ -1,448 +1,457 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2012 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 'SVG/Graph/Bar' |
|
19 | 19 | require 'SVG/Graph/BarHorizontal' |
|
20 | 20 | require 'digest/sha1' |
|
21 | 21 | require 'redmine/scm/adapters/abstract_adapter' |
|
22 | 22 | |
|
23 | 23 | class ChangesetNotFound < Exception; end |
|
24 | 24 | class InvalidRevisionParam < Exception; end |
|
25 | 25 | |
|
26 | 26 | class RepositoriesController < ApplicationController |
|
27 | 27 | menu_item :repository |
|
28 | 28 | menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers] |
|
29 | 29 | default_search_scope :changesets |
|
30 | 30 | |
|
31 | 31 | before_filter :find_project_by_project_id, :only => [:new, :create] |
|
32 | 32 | before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] |
|
33 | 33 | before_filter :find_project_repository, :except => [:new, :create, :edit, :update, :destroy, :committers] |
|
34 | 34 | before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] |
|
35 | 35 | before_filter :authorize |
|
36 | 36 | accept_rss_auth :revisions |
|
37 | 37 | |
|
38 | 38 | rescue_from Redmine::Scm::Adapters::CommandFailed, :with => :show_error_command_failed |
|
39 | 39 | |
|
40 | 40 | def new |
|
41 | 41 | scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first |
|
42 | 42 | @repository = Repository.factory(scm) |
|
43 | 43 | @repository.is_default = @project.repository.nil? |
|
44 | 44 | @repository.project = @project |
|
45 | 45 | render :layout => !request.xhr? |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def create |
|
49 | 49 | attrs = pickup_extra_info |
|
50 | 50 | @repository = Repository.factory(params[:repository_scm], attrs[:attrs]) |
|
51 | 51 | if attrs[:attrs_extra].keys.any? |
|
52 | 52 | @repository.merge_extra_info(attrs[:attrs_extra]) |
|
53 | 53 | end |
|
54 | 54 | @repository.project = @project |
|
55 | 55 | if request.post? && @repository.save |
|
56 | 56 | redirect_to settings_project_path(@project, :tab => 'repositories') |
|
57 | 57 | else |
|
58 | 58 | render :action => 'new' |
|
59 | 59 | end |
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | def edit |
|
63 | 63 | end |
|
64 | 64 | |
|
65 | 65 | def update |
|
66 | 66 | attrs = pickup_extra_info |
|
67 | 67 | @repository.attributes = attrs[:attrs] |
|
68 | 68 | if attrs[:attrs_extra].keys.any? |
|
69 | 69 | @repository.merge_extra_info(attrs[:attrs_extra]) |
|
70 | 70 | end |
|
71 | 71 | @repository.project = @project |
|
72 | 72 | if request.put? && @repository.save |
|
73 | 73 | redirect_to settings_project_path(@project, :tab => 'repositories') |
|
74 | 74 | else |
|
75 | 75 | render :action => 'edit' |
|
76 | 76 | end |
|
77 | 77 | end |
|
78 | 78 | |
|
79 | 79 | def pickup_extra_info |
|
80 | 80 | p = {} |
|
81 | 81 | p_extra = {} |
|
82 | 82 | params[:repository].each do |k, v| |
|
83 | 83 | if k =~ /^extra_/ |
|
84 | 84 | p_extra[k] = v |
|
85 | 85 | else |
|
86 | 86 | p[k] = v |
|
87 | 87 | end |
|
88 | 88 | end |
|
89 | 89 | {:attrs => p, :attrs_extra => p_extra} |
|
90 | 90 | end |
|
91 | 91 | private :pickup_extra_info |
|
92 | 92 | |
|
93 | 93 | def committers |
|
94 | 94 | @committers = @repository.committers |
|
95 | 95 | @users = @project.users |
|
96 | 96 | additional_user_ids = @committers.collect(&:last).collect(&:to_i) - @users.collect(&:id) |
|
97 | 97 | @users += User.find_all_by_id(additional_user_ids) unless additional_user_ids.empty? |
|
98 | 98 | @users.compact! |
|
99 | 99 | @users.sort! |
|
100 | 100 | if request.post? && params[:committers].is_a?(Hash) |
|
101 | 101 | # Build a hash with repository usernames as keys and corresponding user ids as values |
|
102 | 102 | @repository.committer_ids = params[:committers].values.inject({}) {|h, c| h[c.first] = c.last; h} |
|
103 | 103 | flash[:notice] = l(:notice_successful_update) |
|
104 | 104 | redirect_to settings_project_path(@project, :tab => 'repositories') |
|
105 | 105 | end |
|
106 | 106 | end |
|
107 | 107 | |
|
108 | 108 | def destroy |
|
109 | 109 | @repository.destroy if request.delete? |
|
110 | 110 | redirect_to settings_project_path(@project, :tab => 'repositories') |
|
111 | 111 | end |
|
112 | 112 | |
|
113 | 113 | def show |
|
114 | 114 | @repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty? |
|
115 | 115 | |
|
116 | 116 | @entries = @repository.entries(@path, @rev) |
|
117 | 117 | @changeset = @repository.find_changeset_by_name(@rev) |
|
118 | 118 | if request.xhr? |
|
119 | 119 | @entries ? render(:partial => 'dir_list_content') : render(:nothing => true) |
|
120 | 120 | else |
|
121 | 121 | (show_error_not_found; return) unless @entries |
|
122 | 122 | @changesets = @repository.latest_changesets(@path, @rev) |
|
123 | 123 | @properties = @repository.properties(@path, @rev) |
|
124 | 124 | @repositories = @project.repositories |
|
125 | 125 | render :action => 'show' |
|
126 | 126 | end |
|
127 | 127 | end |
|
128 | 128 | |
|
129 | 129 | alias_method :browse, :show |
|
130 | 130 | |
|
131 | 131 | def changes |
|
132 | 132 | @entry = @repository.entry(@path, @rev) |
|
133 | 133 | (show_error_not_found; return) unless @entry |
|
134 | 134 | @changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) |
|
135 | 135 | @properties = @repository.properties(@path, @rev) |
|
136 | 136 | @changeset = @repository.find_changeset_by_name(@rev) |
|
137 | 137 | end |
|
138 | 138 | |
|
139 | 139 | def revisions |
|
140 | 140 | @changeset_count = @repository.changesets.count |
|
141 | 141 | @changeset_pages = Paginator.new self, @changeset_count, |
|
142 | 142 | per_page_option, |
|
143 | 143 | params['page'] |
|
144 | 144 | @changesets = @repository.changesets.find(:all, |
|
145 | 145 | :limit => @changeset_pages.items_per_page, |
|
146 | 146 | :offset => @changeset_pages.current.offset, |
|
147 | 147 | :include => [:user, :repository, :parents]) |
|
148 | 148 | |
|
149 | 149 | respond_to do |format| |
|
150 | 150 | format.html { render :layout => false if request.xhr? } |
|
151 | 151 | format.atom { render_feed(@changesets, :title => "#{@project.name}: #{l(:label_revision_plural)}") } |
|
152 | 152 | end |
|
153 | 153 | end |
|
154 | 154 | |
|
155 | def raw | |
|
156 | entry_and_raw(true) | |
|
157 | end | |
|
158 | ||
|
155 | 159 | def entry |
|
160 | entry_and_raw(false) | |
|
161 | end | |
|
162 | ||
|
163 | def entry_and_raw(is_raw) | |
|
156 | 164 | @entry = @repository.entry(@path, @rev) |
|
157 | 165 | (show_error_not_found; return) unless @entry |
|
158 | 166 | |
|
159 | 167 | # If the entry is a dir, show the browser |
|
160 | 168 | (show; return) if @entry.is_dir? |
|
161 | 169 | |
|
162 | 170 | @content = @repository.cat(@path, @rev) |
|
163 | 171 | (show_error_not_found; return) unless @content |
|
164 | if 'raw' == params[:format] || | |
|
172 | if is_raw || | |
|
165 | 173 | (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || |
|
166 | 174 | ! is_entry_text_data?(@content, @path) |
|
167 | 175 | # Force the download |
|
168 | 176 | send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) } |
|
169 | 177 | send_type = Redmine::MimeType.of(@path) |
|
170 | 178 | send_opt[:type] = send_type.to_s if send_type |
|
171 | 179 | send_data @content, send_opt |
|
172 | 180 | else |
|
173 | 181 | # Prevent empty lines when displaying a file with Windows style eol |
|
174 | 182 | # TODO: UTF-16 |
|
175 | 183 | # Is this needs? AttachmentsController reads file simply. |
|
176 | 184 | @content.gsub!("\r\n", "\n") |
|
177 | 185 | @changeset = @repository.find_changeset_by_name(@rev) |
|
178 | 186 | end |
|
179 | 187 | end |
|
188 | private :entry_and_raw | |
|
180 | 189 | |
|
181 | 190 | def is_entry_text_data?(ent, path) |
|
182 | 191 | # UTF-16 contains "\x00". |
|
183 | 192 | # It is very strict that file contains less than 30% of ascii symbols |
|
184 | 193 | # in non Western Europe. |
|
185 | 194 | return true if Redmine::MimeType.is_type?('text', path) |
|
186 | 195 | # Ruby 1.8.6 has a bug of integer divisions. |
|
187 | 196 | # http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F |
|
188 | 197 | return false if ent.is_binary_data? |
|
189 | 198 | true |
|
190 | 199 | end |
|
191 | 200 | private :is_entry_text_data? |
|
192 | 201 | |
|
193 | 202 | def annotate |
|
194 | 203 | @entry = @repository.entry(@path, @rev) |
|
195 | 204 | (show_error_not_found; return) unless @entry |
|
196 | 205 | |
|
197 | 206 | @annotate = @repository.scm.annotate(@path, @rev) |
|
198 | 207 | if @annotate.nil? || @annotate.empty? |
|
199 | 208 | (render_error l(:error_scm_annotate); return) |
|
200 | 209 | end |
|
201 | 210 | ann_buf_size = 0 |
|
202 | 211 | @annotate.lines.each do |buf| |
|
203 | 212 | ann_buf_size += buf.size |
|
204 | 213 | end |
|
205 | 214 | if ann_buf_size > Setting.file_max_size_displayed.to_i.kilobyte |
|
206 | 215 | (render_error l(:error_scm_annotate_big_text_file); return) |
|
207 | 216 | end |
|
208 | 217 | @changeset = @repository.find_changeset_by_name(@rev) |
|
209 | 218 | end |
|
210 | 219 | |
|
211 | 220 | def revision |
|
212 | 221 | respond_to do |format| |
|
213 | 222 | format.html |
|
214 | 223 | format.js {render :layout => false} |
|
215 | 224 | end |
|
216 | 225 | end |
|
217 | 226 | |
|
218 | 227 | # Adds a related issue to a changeset |
|
219 | 228 | # POST /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues |
|
220 | 229 | def add_related_issue |
|
221 | 230 | @issue = @changeset.find_referenced_issue_by_id(params[:issue_id]) |
|
222 | 231 | if @issue && (!@issue.visible? || @changeset.issues.include?(@issue)) |
|
223 | 232 | @issue = nil |
|
224 | 233 | end |
|
225 | 234 | |
|
226 | 235 | if @issue |
|
227 | 236 | @changeset.issues << @issue |
|
228 | 237 | respond_to do |format| |
|
229 | 238 | format.js { |
|
230 | 239 | render :update do |page| |
|
231 | 240 | page.replace_html "related-issues", :partial => "related_issues" |
|
232 | 241 | page.visual_effect :highlight, "related-issue-#{@issue.id}" |
|
233 | 242 | end |
|
234 | 243 | } |
|
235 | 244 | end |
|
236 | 245 | else |
|
237 | 246 | respond_to do |format| |
|
238 | 247 | format.js { |
|
239 | 248 | render :update do |page| |
|
240 | 249 | page.alert(l(:label_issue) + ' ' + l('activerecord.errors.messages.invalid')) |
|
241 | 250 | end |
|
242 | 251 | } |
|
243 | 252 | end |
|
244 | 253 | end |
|
245 | 254 | end |
|
246 | 255 | |
|
247 | 256 | # Removes a related issue from a changeset |
|
248 | 257 | # DELETE /projects/:project_id/repository/(:repository_id/)revisions/:rev/issues/:issue_id |
|
249 | 258 | def remove_related_issue |
|
250 | 259 | @issue = Issue.visible.find_by_id(params[:issue_id]) |
|
251 | 260 | if @issue |
|
252 | 261 | @changeset.issues.delete(@issue) |
|
253 | 262 | end |
|
254 | 263 | |
|
255 | 264 | respond_to do |format| |
|
256 | 265 | format.js { |
|
257 | 266 | render :update do |page| |
|
258 | 267 | page.remove "related-issue-#{@issue.id}" |
|
259 | 268 | end if @issue |
|
260 | 269 | } |
|
261 | 270 | end |
|
262 | 271 | end |
|
263 | 272 | |
|
264 | 273 | def diff |
|
265 | 274 | if params[:format] == 'diff' |
|
266 | 275 | @diff = @repository.diff(@path, @rev, @rev_to) |
|
267 | 276 | (show_error_not_found; return) unless @diff |
|
268 | 277 | filename = "changeset_r#{@rev}" |
|
269 | 278 | filename << "_r#{@rev_to}" if @rev_to |
|
270 | 279 | send_data @diff.join, :filename => "#{filename}.diff", |
|
271 | 280 | :type => 'text/x-patch', |
|
272 | 281 | :disposition => 'attachment' |
|
273 | 282 | else |
|
274 | 283 | @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline' |
|
275 | 284 | @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type) |
|
276 | 285 | |
|
277 | 286 | # Save diff type as user preference |
|
278 | 287 | if User.current.logged? && @diff_type != User.current.pref[:diff_type] |
|
279 | 288 | User.current.pref[:diff_type] = @diff_type |
|
280 | 289 | User.current.preference.save |
|
281 | 290 | end |
|
282 | 291 | @cache_key = "repositories/diff/#{@repository.id}/" + |
|
283 | 292 | Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}-#{current_language}") |
|
284 | 293 | unless read_fragment(@cache_key) |
|
285 | 294 | @diff = @repository.diff(@path, @rev, @rev_to) |
|
286 | 295 | show_error_not_found unless @diff |
|
287 | 296 | end |
|
288 | 297 | |
|
289 | 298 | @changeset = @repository.find_changeset_by_name(@rev) |
|
290 | 299 | @changeset_to = @rev_to ? @repository.find_changeset_by_name(@rev_to) : nil |
|
291 | 300 | @diff_format_revisions = @repository.diff_format_revisions(@changeset, @changeset_to) |
|
292 | 301 | end |
|
293 | 302 | end |
|
294 | 303 | |
|
295 | 304 | def stats |
|
296 | 305 | end |
|
297 | 306 | |
|
298 | 307 | def graph |
|
299 | 308 | data = nil |
|
300 | 309 | case params[:graph] |
|
301 | 310 | when "commits_per_month" |
|
302 | 311 | data = graph_commits_per_month(@repository) |
|
303 | 312 | when "commits_per_author" |
|
304 | 313 | data = graph_commits_per_author(@repository) |
|
305 | 314 | end |
|
306 | 315 | if data |
|
307 | 316 | headers["Content-Type"] = "image/svg+xml" |
|
308 | 317 | send_data(data, :type => "image/svg+xml", :disposition => "inline") |
|
309 | 318 | else |
|
310 | 319 | render_404 |
|
311 | 320 | end |
|
312 | 321 | end |
|
313 | 322 | |
|
314 | 323 | private |
|
315 | 324 | |
|
316 | 325 | def find_repository |
|
317 | 326 | @repository = Repository.find(params[:id]) |
|
318 | 327 | @project = @repository.project |
|
319 | 328 | rescue ActiveRecord::RecordNotFound |
|
320 | 329 | render_404 |
|
321 | 330 | end |
|
322 | 331 | |
|
323 | 332 | REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i |
|
324 | 333 | |
|
325 | 334 | def find_project_repository |
|
326 | 335 | @project = Project.find(params[:id]) |
|
327 | 336 | if params[:repository_id].present? |
|
328 | 337 | @repository = @project.repositories.find_by_identifier_param(params[:repository_id]) |
|
329 | 338 | else |
|
330 | 339 | @repository = @project.repository |
|
331 | 340 | end |
|
332 | 341 | (render_404; return false) unless @repository |
|
333 | 342 | @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s |
|
334 | 343 | @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip |
|
335 | 344 | @rev_to = params[:rev_to] |
|
336 | 345 | |
|
337 | 346 | unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE) |
|
338 | 347 | if @repository.branches.blank? |
|
339 | 348 | raise InvalidRevisionParam |
|
340 | 349 | end |
|
341 | 350 | end |
|
342 | 351 | rescue ActiveRecord::RecordNotFound |
|
343 | 352 | render_404 |
|
344 | 353 | rescue InvalidRevisionParam |
|
345 | 354 | show_error_not_found |
|
346 | 355 | end |
|
347 | 356 | |
|
348 | 357 | def find_changeset |
|
349 | 358 | if @rev.present? |
|
350 | 359 | @changeset = @repository.find_changeset_by_name(@rev) |
|
351 | 360 | end |
|
352 | 361 | show_error_not_found unless @changeset |
|
353 | 362 | end |
|
354 | 363 | |
|
355 | 364 | def show_error_not_found |
|
356 | 365 | render_error :message => l(:error_scm_not_found), :status => 404 |
|
357 | 366 | end |
|
358 | 367 | |
|
359 | 368 | # Handler for Redmine::Scm::Adapters::CommandFailed exception |
|
360 | 369 | def show_error_command_failed(exception) |
|
361 | 370 | render_error l(:error_scm_command_failed, exception.message) |
|
362 | 371 | end |
|
363 | 372 | |
|
364 | 373 | def graph_commits_per_month(repository) |
|
365 | 374 | @date_to = Date.today |
|
366 | 375 | @date_from = @date_to << 11 |
|
367 | 376 | @date_from = Date.civil(@date_from.year, @date_from.month, 1) |
|
368 | 377 | commits_by_day = Changeset.count( |
|
369 | 378 | :all, :group => :commit_date, |
|
370 | 379 | :conditions => ["repository_id = ? AND commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) |
|
371 | 380 | commits_by_month = [0] * 12 |
|
372 | 381 | commits_by_day.each {|c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last } |
|
373 | 382 | |
|
374 | 383 | changes_by_day = Change.count( |
|
375 | 384 | :all, :group => :commit_date, :include => :changeset, |
|
376 | 385 | :conditions => ["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]) |
|
377 | 386 | changes_by_month = [0] * 12 |
|
378 | 387 | changes_by_day.each {|c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last } |
|
379 | 388 | |
|
380 | 389 | fields = [] |
|
381 | 390 | 12.times {|m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1)} |
|
382 | 391 | |
|
383 | 392 | graph = SVG::Graph::Bar.new( |
|
384 | 393 | :height => 300, |
|
385 | 394 | :width => 800, |
|
386 | 395 | :fields => fields.reverse, |
|
387 | 396 | :stack => :side, |
|
388 | 397 | :scale_integers => true, |
|
389 | 398 | :step_x_labels => 2, |
|
390 | 399 | :show_data_values => false, |
|
391 | 400 | :graph_title => l(:label_commits_per_month), |
|
392 | 401 | :show_graph_title => true |
|
393 | 402 | ) |
|
394 | 403 | |
|
395 | 404 | graph.add_data( |
|
396 | 405 | :data => commits_by_month[0..11].reverse, |
|
397 | 406 | :title => l(:label_revision_plural) |
|
398 | 407 | ) |
|
399 | 408 | |
|
400 | 409 | graph.add_data( |
|
401 | 410 | :data => changes_by_month[0..11].reverse, |
|
402 | 411 | :title => l(:label_change_plural) |
|
403 | 412 | ) |
|
404 | 413 | |
|
405 | 414 | graph.burn |
|
406 | 415 | end |
|
407 | 416 | |
|
408 | 417 | def graph_commits_per_author(repository) |
|
409 | 418 | commits_by_author = Changeset.count(:all, :group => :committer, :conditions => ["repository_id = ?", repository.id]) |
|
410 | 419 | commits_by_author.to_a.sort! {|x, y| x.last <=> y.last} |
|
411 | 420 | |
|
412 | 421 | changes_by_author = Change.count(:all, :group => :committer, :include => :changeset, :conditions => ["#{Changeset.table_name}.repository_id = ?", repository.id]) |
|
413 | 422 | h = changes_by_author.inject({}) {|o, i| o[i.first] = i.last; o} |
|
414 | 423 | |
|
415 | 424 | fields = commits_by_author.collect {|r| r.first} |
|
416 | 425 | commits_data = commits_by_author.collect {|r| r.last} |
|
417 | 426 | changes_data = commits_by_author.collect {|r| h[r.first] || 0} |
|
418 | 427 | |
|
419 | 428 | fields = fields + [""]*(10 - fields.length) if fields.length<10 |
|
420 | 429 | commits_data = commits_data + [0]*(10 - commits_data.length) if commits_data.length<10 |
|
421 | 430 | changes_data = changes_data + [0]*(10 - changes_data.length) if changes_data.length<10 |
|
422 | 431 | |
|
423 | 432 | # Remove email adress in usernames |
|
424 | 433 | fields = fields.collect {|c| c.gsub(%r{<.+@.+>}, '') } |
|
425 | 434 | |
|
426 | 435 | graph = SVG::Graph::BarHorizontal.new( |
|
427 | 436 | :height => 400, |
|
428 | 437 | :width => 800, |
|
429 | 438 | :fields => fields, |
|
430 | 439 | :stack => :side, |
|
431 | 440 | :scale_integers => true, |
|
432 | 441 | :show_data_values => false, |
|
433 | 442 | :rotate_y_labels => false, |
|
434 | 443 | :graph_title => l(:label_commits_per_author), |
|
435 | 444 | :show_graph_title => true |
|
436 | 445 | ) |
|
437 | 446 | graph.add_data( |
|
438 | 447 | :data => commits_data, |
|
439 | 448 | :title => l(:label_revision_plural) |
|
440 | 449 | ) |
|
441 | 450 | graph.add_data( |
|
442 | 451 | :data => changes_data, |
|
443 | 452 | :title => l(:label_change_plural) |
|
444 | 453 | ) |
|
445 | 454 | graph.burn |
|
446 | 455 | end |
|
447 | 456 | end |
|
448 | 457 |
@@ -1,15 +1,19 | |||
|
1 | 1 | <% if @entry && @entry.kind == 'file' %> |
|
2 | 2 | |
|
3 | 3 | <p> |
|
4 | 4 | <%= link_to_if action_name != 'changes', l(:label_history), {:action => 'changes', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> | |
|
5 | 5 | <% if @repository.supports_cat? %> |
|
6 | 6 | <%= link_to_if action_name != 'entry', l(:button_view), {:action => 'entry', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> | |
|
7 | 7 | <% end %> |
|
8 | 8 | <% if @repository.supports_annotate? %> |
|
9 | 9 | <%= link_to_if action_name != 'annotate', l(:button_annotate), {:action => 'annotate', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> | |
|
10 | 10 | <% end %> |
|
11 | <%= link_to(l(:button_download), {:action => 'entry', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev, :format => 'raw' }) if @repository.supports_cat? %> | |
|
11 | <%= link_to(l(:button_download), | |
|
12 | {:action => 'raw', :id => @project, | |
|
13 | :repository_id => @repository.identifier_param, | |
|
14 | :path => to_path_param(@path), | |
|
15 | :rev => @rev}) if @repository.supports_cat? %> | |
|
12 | 16 | <%= "(#{number_to_human_size(@entry.size)})" if @entry.size %> |
|
13 | 17 | </p> |
|
14 | 18 | |
|
15 | 19 | <% end %> |
@@ -1,344 +1,334 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2012 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 | RedmineApp::Application.routes.draw do |
|
19 | 19 | root :to => 'welcome#index', :as => 'home' |
|
20 | 20 | |
|
21 | 21 | match 'login', :to => 'account#login', :as => 'signin' |
|
22 | 22 | match 'logout', :to => 'account#logout', :as => 'signout' |
|
23 | 23 | match 'account/register', :to => 'account#register', :via => [:get, :post] |
|
24 | 24 | match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post] |
|
25 | 25 | match 'account/activate', :to => 'account#activate', :via => :get |
|
26 | 26 | |
|
27 | 27 | match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news' |
|
28 | 28 | match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue' |
|
29 | 29 | match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue' |
|
30 | 30 | match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue' |
|
31 | 31 | |
|
32 | 32 | match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post |
|
33 | 33 | match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post] |
|
34 | 34 | |
|
35 | 35 | match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post] |
|
36 | 36 | get 'boards/:board_id/topics/:id', :to => 'messages#show' |
|
37 | 37 | match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post] |
|
38 | 38 | get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' |
|
39 | 39 | |
|
40 | 40 | post 'boards/:board_id/topics/preview', :to => 'messages#preview' |
|
41 | 41 | post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply' |
|
42 | 42 | post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' |
|
43 | 43 | post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy' |
|
44 | 44 | |
|
45 | 45 | # Misc issue routes. TODO: move into resources |
|
46 | 46 | match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues' |
|
47 | 47 | match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu' |
|
48 | 48 | match '/issues/changes', :to => 'journals#index', :as => 'issue_changes' |
|
49 | 49 | match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue' |
|
50 | 50 | |
|
51 | 51 | match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get |
|
52 | 52 | match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post] |
|
53 | 53 | |
|
54 | 54 | match '/projects/:project_id/issues/gantt', :to => 'gantts#show' |
|
55 | 55 | match '/issues/gantt', :to => 'gantts#show' |
|
56 | 56 | |
|
57 | 57 | match '/projects/:project_id/issues/calendar', :to => 'calendars#show' |
|
58 | 58 | match '/issues/calendar', :to => 'calendars#show' |
|
59 | 59 | |
|
60 | 60 | match 'projects/:id/issues/report', :to => 'reports#issue_report', :via => :get |
|
61 | 61 | match 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :via => :get |
|
62 | 62 | |
|
63 | 63 | match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post] |
|
64 | 64 | match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post] |
|
65 | 65 | match 'my/page', :controller => 'my', :action => 'page', :via => :get |
|
66 | 66 | match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page |
|
67 | 67 | match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post |
|
68 | 68 | match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post |
|
69 | 69 | match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post] |
|
70 | 70 | match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get |
|
71 | 71 | match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post |
|
72 | 72 | match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post |
|
73 | 73 | match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post |
|
74 | 74 | |
|
75 | 75 | resources :users |
|
76 | 76 | match 'users/:id/memberships/:membership_id', :to => 'users#edit_membership', :via => :put, :as => 'user_membership' |
|
77 | 77 | match 'users/:id/memberships/:membership_id', :to => 'users#destroy_membership', :via => :delete |
|
78 | 78 | match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships' |
|
79 | 79 | |
|
80 | 80 | match 'watchers/new', :controller=> 'watchers', :action => 'new', :via => :get |
|
81 | 81 | match 'watchers', :controller=> 'watchers', :action => 'create', :via => :post |
|
82 | 82 | match 'watchers/append', :controller=> 'watchers', :action => 'append', :via => :post |
|
83 | 83 | match 'watchers/destroy', :controller=> 'watchers', :action => 'destroy', :via => :post |
|
84 | 84 | match 'watchers/watch', :controller=> 'watchers', :action => 'watch', :via => :post |
|
85 | 85 | match 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch', :via => :post |
|
86 | 86 | match 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user', :via => :get |
|
87 | 87 | |
|
88 | 88 | match 'projects/:id/settings/:tab', :to => "projects#settings" |
|
89 | 89 | |
|
90 | 90 | resources :projects do |
|
91 | 91 | member do |
|
92 | 92 | get 'settings' |
|
93 | 93 | post 'modules' |
|
94 | 94 | post 'archive' |
|
95 | 95 | post 'unarchive' |
|
96 | 96 | match 'copy', :via => [:get, :post] |
|
97 | 97 | end |
|
98 | 98 | |
|
99 | 99 | resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :create, :update, :destroy] do |
|
100 | 100 | collection do |
|
101 | 101 | get 'autocomplete' |
|
102 | 102 | end |
|
103 | 103 | end |
|
104 | 104 | |
|
105 | 105 | resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy] |
|
106 | 106 | |
|
107 | 107 | match 'issues/:copy_from/copy', :to => 'issues#new' |
|
108 | 108 | resources :issues, :only => [:index, :new, :create] do |
|
109 | 109 | resources :time_entries, :controller => 'timelog' do |
|
110 | 110 | collection do |
|
111 | 111 | get 'report' |
|
112 | 112 | end |
|
113 | 113 | end |
|
114 | 114 | end |
|
115 | 115 | # issue form update |
|
116 | 116 | match 'issues/new', :controller => 'issues', :action => 'new', :via => [:put, :post], :as => 'issue_form' |
|
117 | 117 | |
|
118 | 118 | resources :files, :only => [:index, :new, :create] |
|
119 | 119 | |
|
120 | 120 | resources :versions, :except => [:index, :show, :edit, :update, :destroy] do |
|
121 | 121 | collection do |
|
122 | 122 | put 'close_completed' |
|
123 | 123 | end |
|
124 | 124 | end |
|
125 | 125 | match 'versions.:format', :to => 'versions#index' |
|
126 | 126 | match 'roadmap', :to => 'versions#index', :format => false |
|
127 | 127 | match 'versions', :to => 'versions#index' |
|
128 | 128 | |
|
129 | 129 | resources :news, :except => [:show, :edit, :update, :destroy] |
|
130 | 130 | resources :time_entries, :controller => 'timelog' do |
|
131 | 131 | get 'report', :on => :collection |
|
132 | 132 | end |
|
133 | 133 | resources :queries, :only => [:new, :create] |
|
134 | 134 | resources :issue_categories, :shallow => true |
|
135 | 135 | resources :documents, :except => [:show, :edit, :update, :destroy] |
|
136 | 136 | resources :boards |
|
137 | 137 | resources :repositories, :shallow => true, :except => [:index, :show] do |
|
138 | 138 | member do |
|
139 | 139 | match 'committers', :via => [:get, :post] |
|
140 | 140 | end |
|
141 | 141 | end |
|
142 | 142 | |
|
143 | 143 | match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get |
|
144 | 144 | match 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff' |
|
145 | 145 | match 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff' |
|
146 | 146 | resources :wiki, :except => [:index, :new, :create] do |
|
147 | 147 | member do |
|
148 | 148 | get 'rename' |
|
149 | 149 | post 'rename' |
|
150 | 150 | get 'history' |
|
151 | 151 | get 'diff' |
|
152 | 152 | match 'preview', :via => [:post, :put] |
|
153 | 153 | post 'protect' |
|
154 | 154 | post 'add_attachment' |
|
155 | 155 | end |
|
156 | 156 | collection do |
|
157 | 157 | get 'export' |
|
158 | 158 | get 'date_index' |
|
159 | 159 | end |
|
160 | 160 | end |
|
161 | 161 | match 'wiki', :controller => 'wiki', :action => 'show', :via => :get |
|
162 | 162 | match 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate' |
|
163 | 163 | end |
|
164 | 164 | |
|
165 | 165 | resources :issues do |
|
166 | 166 | collection do |
|
167 | 167 | match 'bulk_edit', :via => [:get, :post] |
|
168 | 168 | post 'bulk_update' |
|
169 | 169 | end |
|
170 | 170 | resources :time_entries, :controller => 'timelog' do |
|
171 | 171 | collection do |
|
172 | 172 | get 'report' |
|
173 | 173 | end |
|
174 | 174 | end |
|
175 | 175 | resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy] |
|
176 | 176 | end |
|
177 | 177 | match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete |
|
178 | 178 | |
|
179 | 179 | resources :queries, :except => [:show] |
|
180 | 180 | |
|
181 | 181 | resources :news, :only => [:index, :show, :edit, :update, :destroy] |
|
182 | 182 | match '/news/:id/comments', :to => 'comments#create', :via => :post |
|
183 | 183 | match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete |
|
184 | 184 | |
|
185 | 185 | resources :versions, :only => [:show, :edit, :update, :destroy] do |
|
186 | 186 | post 'status_by', :on => :member |
|
187 | 187 | end |
|
188 | 188 | |
|
189 | 189 | resources :documents, :only => [:show, :edit, :update, :destroy] do |
|
190 | 190 | post 'add_attachment', :on => :member |
|
191 | 191 | end |
|
192 | 192 | |
|
193 | 193 | match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu |
|
194 | 194 | |
|
195 | 195 | resources :time_entries, :controller => 'timelog', :except => :destroy do |
|
196 | 196 | collection do |
|
197 | 197 | get 'report' |
|
198 | 198 | get 'bulk_edit' |
|
199 | 199 | post 'bulk_update' |
|
200 | 200 | end |
|
201 | 201 | end |
|
202 | 202 | match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/ |
|
203 | 203 | # TODO: delete /time_entries for bulk deletion |
|
204 | 204 | match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete |
|
205 | 205 | |
|
206 | 206 | # TODO: port to be part of the resources route(s) |
|
207 | 207 | match 'projects/:id/settings/:tab', :to => 'projects#settings', :via => :get |
|
208 | 208 | |
|
209 | 209 | get 'projects/:id/activity', :to => 'activities#index' |
|
210 | 210 | get 'projects/:id/activity.:format', :to => 'activities#index' |
|
211 | 211 | get 'activity', :to => 'activities#index' |
|
212 | 212 | |
|
213 | 213 | # repositories routes |
|
214 | 214 | get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats' |
|
215 | 215 | get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph' |
|
216 | 216 | |
|
217 | 217 | get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))', |
|
218 | 218 | :to => 'repositories#changes' |
|
219 | 219 | |
|
220 | 220 | get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision' |
|
221 | 221 | get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision' |
|
222 | 222 | post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue' |
|
223 | 223 | delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue' |
|
224 | 224 | get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions' |
|
225 | get 'projects/:id/repository/:repository_id/revisions/:rev/:format(/*path(.:ext))', | |
|
226 | :to => 'repositories#entry', | |
|
227 | :constraints => { | |
|
228 | :format => 'raw', | |
|
229 | :rev => /[a-z0-9\.\-_]+/ | |
|
230 | } | |
|
231 | 225 | get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))', |
|
232 | 226 | :controller => 'repositories', |
|
233 | 227 | :constraints => { |
|
234 | :action => /(browse|show|entry|annotate|diff)/, | |
|
228 | :action => /(browse|show|entry|raw|annotate|diff)/, | |
|
235 | 229 | :rev => /[a-z0-9\.\-_]+/ |
|
236 | 230 | } |
|
237 | 231 | |
|
238 | 232 | get 'projects/:id/repository/statistics', :to => 'repositories#stats' |
|
239 | 233 | get 'projects/:id/repository/graph', :to => 'repositories#graph' |
|
240 | 234 | |
|
241 | 235 | get 'projects/:id/repository/changes(/*path(.:ext))', |
|
242 | 236 | :to => 'repositories#changes' |
|
243 | 237 | |
|
244 | 238 | get 'projects/:id/repository/revisions', :to => 'repositories#revisions' |
|
245 | 239 | get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision' |
|
246 | 240 | get 'projects/:id/repository/revision', :to => 'repositories#revision' |
|
247 | 241 | post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue' |
|
248 | 242 | delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue' |
|
249 | get 'projects/:id/repository/revisions/:rev/:format(/*path(.:ext))', | |
|
250 | :to => 'repositories#entry', | |
|
251 | :constraints => { | |
|
252 | :format => 'raw', | |
|
253 | :rev => /[a-z0-9\.\-_]+/ | |
|
254 | } | |
|
255 | 243 | get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))', |
|
256 | 244 | :controller => 'repositories', |
|
257 | 245 | :constraints => { |
|
258 | :action => /(browse|show|entry|annotate|diff)/, | |
|
246 | :action => /(browse|show|entry|raw|annotate|diff)/, | |
|
259 | 247 | :rev => /[a-z0-9\.\-_]+/ |
|
260 | 248 | } |
|
261 |
get 'projects/:id/repository/:repository_id/: |
|
|
262 | get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', :controller => 'repositories', :action => /(browse|show|entry|changes|annotate|diff)/ | |
|
249 | get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', | |
|
250 | :controller => 'repositories', | |
|
251 | :action => /(browse|show|entry|raw|changes|annotate|diff)/ | |
|
263 | 252 | get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil |
|
264 | 253 | |
|
265 |
get 'projects/:id/repository/: |
|
|
266 | get 'projects/:id/repository/:action(/*path(.:ext))', :controller => 'repositories', :action => /(browse|show|entry|changes|annotate|diff)/ | |
|
254 | get 'projects/:id/repository/:action(/*path(.:ext))', | |
|
255 | :controller => 'repositories', | |
|
256 | :action => /(browse|show|entry|raw|changes|annotate|diff)/ | |
|
267 | 257 | get 'projects/:id/repository', :to => 'repositories#show', :path => nil |
|
268 | 258 | |
|
269 | 259 | # additional routes for having the file name at the end of url |
|
270 | 260 | match 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/, :via => :get |
|
271 | 261 | match 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/, :via => :get |
|
272 | 262 | match 'attachments/download/:id', :controller => 'attachments', :action => 'download', :id => /\d+/, :via => :get |
|
273 | 263 | resources :attachments, :only => [:show, :destroy] |
|
274 | 264 | |
|
275 | 265 | resources :groups do |
|
276 | 266 | member do |
|
277 | 267 | get 'autocomplete_for_user' |
|
278 | 268 | end |
|
279 | 269 | end |
|
280 | 270 | |
|
281 | 271 | match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users' |
|
282 | 272 | match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user' |
|
283 | 273 | match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post |
|
284 | 274 | match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post |
|
285 | 275 | |
|
286 | 276 | resources :trackers, :except => :show |
|
287 | 277 | resources :issue_statuses, :except => :show do |
|
288 | 278 | collection do |
|
289 | 279 | post 'update_issue_done_ratio' |
|
290 | 280 | end |
|
291 | 281 | end |
|
292 | 282 | resources :custom_fields, :except => :show |
|
293 | 283 | resources :roles, :except => :show do |
|
294 | 284 | collection do |
|
295 | 285 | match 'permissions', :via => [:get, :post] |
|
296 | 286 | end |
|
297 | 287 | end |
|
298 | 288 | resources :enumerations, :except => :show |
|
299 | 289 | |
|
300 | 290 | get 'projects/:id/search', :controller => 'search', :action => 'index' |
|
301 | 291 | get 'search', :controller => 'search', :action => 'index' |
|
302 | 292 | |
|
303 | 293 | match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post |
|
304 | 294 | |
|
305 | 295 | match 'admin', :controller => 'admin', :action => 'index', :via => :get |
|
306 | 296 | match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get |
|
307 | 297 | match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get |
|
308 | 298 | match 'admin/info', :controller => 'admin', :action => 'info', :via => :get |
|
309 | 299 | match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get |
|
310 | 300 | match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post |
|
311 | 301 | |
|
312 | 302 | resources :auth_sources do |
|
313 | 303 | member do |
|
314 | 304 | get 'test_connection' |
|
315 | 305 | end |
|
316 | 306 | end |
|
317 | 307 | |
|
318 | 308 | match 'workflows', :controller => 'workflows', :action => 'index', :via => :get |
|
319 | 309 | match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post] |
|
320 | 310 | match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post] |
|
321 | 311 | match 'settings', :controller => 'settings', :action => 'index', :via => :get |
|
322 | 312 | match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post] |
|
323 | 313 | match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post] |
|
324 | 314 | |
|
325 | 315 | match 'sys/projects', :to => 'sys#projects', :via => :get |
|
326 | 316 | match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post |
|
327 | 317 | match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => :get |
|
328 | 318 | |
|
329 | 319 | match 'uploads', :to => 'attachments#upload', :via => :post |
|
330 | 320 | |
|
331 | 321 | get 'robots.txt', :to => 'welcome#robots' |
|
332 | 322 | |
|
333 | 323 | Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| |
|
334 | 324 | file = File.join(plugin_dir, "config/routes.rb") |
|
335 | 325 | if File.exists?(file) |
|
336 | 326 | begin |
|
337 | 327 | instance_eval File.read(file) |
|
338 | 328 | rescue Exception => e |
|
339 | 329 | puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}." |
|
340 | 330 | exit 1 |
|
341 | 331 | end |
|
342 | 332 | end |
|
343 | 333 | end |
|
344 | 334 | end |
@@ -1,238 +1,238 | |||
|
1 | 1 | require 'redmine/access_control' |
|
2 | 2 | require 'redmine/menu_manager' |
|
3 | 3 | require 'redmine/activity' |
|
4 | 4 | require 'redmine/search' |
|
5 | 5 | require 'redmine/custom_field_format' |
|
6 | 6 | require 'redmine/mime_type' |
|
7 | 7 | require 'redmine/core_ext' |
|
8 | 8 | require 'redmine/themes' |
|
9 | 9 | require 'redmine/hook' |
|
10 | 10 | require 'redmine/plugin' |
|
11 | 11 | require 'redmine/notifiable' |
|
12 | 12 | require 'redmine/wiki_formatting' |
|
13 | 13 | require 'redmine/scm/base' |
|
14 | 14 | |
|
15 | 15 | begin |
|
16 | 16 | require 'RMagick' unless Object.const_defined?(:Magick) |
|
17 | 17 | rescue LoadError |
|
18 | 18 | # RMagick is not available |
|
19 | 19 | end |
|
20 | 20 | |
|
21 | 21 | if RUBY_VERSION < '1.9' |
|
22 | 22 | require 'fastercsv' |
|
23 | 23 | else |
|
24 | 24 | require 'csv' |
|
25 | 25 | FCSV = CSV |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | Redmine::Scm::Base.add "Subversion" |
|
29 | 29 | Redmine::Scm::Base.add "Darcs" |
|
30 | 30 | Redmine::Scm::Base.add "Mercurial" |
|
31 | 31 | Redmine::Scm::Base.add "Cvs" |
|
32 | 32 | Redmine::Scm::Base.add "Bazaar" |
|
33 | 33 | Redmine::Scm::Base.add "Git" |
|
34 | 34 | Redmine::Scm::Base.add "Filesystem" |
|
35 | 35 | |
|
36 | 36 | Redmine::CustomFieldFormat.map do |fields| |
|
37 | 37 | fields.register 'string' |
|
38 | 38 | fields.register 'text' |
|
39 | 39 | fields.register 'int', :label => :label_integer |
|
40 | 40 | fields.register 'float' |
|
41 | 41 | fields.register 'list' |
|
42 | 42 | fields.register 'date' |
|
43 | 43 | fields.register 'bool', :label => :label_boolean |
|
44 | 44 | fields.register 'user', :only => %w(Issue TimeEntry Version Project), :edit_as => 'list' |
|
45 | 45 | fields.register 'version', :only => %w(Issue TimeEntry Version Project), :edit_as => 'list' |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | # Permissions |
|
49 | 49 | Redmine::AccessControl.map do |map| |
|
50 | 50 | map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true |
|
51 | 51 | map.permission :search_project, {:search => :index}, :public => true |
|
52 | 52 | map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin |
|
53 | 53 | map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member |
|
54 | 54 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
55 | 55 | map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member |
|
56 | 56 | map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member |
|
57 | 57 | map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member |
|
58 | 58 | |
|
59 | 59 | map.project_module :issue_tracking do |map| |
|
60 | 60 | # Issue categories |
|
61 | 61 | map.permission :manage_categories, {:projects => :settings, :issue_categories => [:index, :show, :new, :create, :edit, :update, :destroy]}, :require => :member |
|
62 | 62 | # Issues |
|
63 | 63 | map.permission :view_issues, {:issues => [:index, :show], |
|
64 | 64 | :auto_complete => [:issues], |
|
65 | 65 | :context_menus => [:issues], |
|
66 | 66 | :versions => [:index, :show, :status_by], |
|
67 | 67 | :journals => [:index, :diff], |
|
68 | 68 | :queries => :index, |
|
69 | 69 | :reports => [:issue_report, :issue_report_details]} |
|
70 | 70 | map.permission :add_issues, {:issues => [:new, :create, :update_form], :attachments => :upload} |
|
71 | 71 | map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new], :attachments => :upload} |
|
72 | 72 | map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]} |
|
73 | 73 | map.permission :manage_subtasks, {} |
|
74 | 74 | map.permission :set_issues_private, {} |
|
75 | 75 | map.permission :set_own_issues_private, {}, :require => :loggedin |
|
76 | 76 | map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new], :attachments => :upload} |
|
77 | 77 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
|
78 | 78 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin |
|
79 | 79 | map.permission :move_issues, {:issues => [:bulk_edit, :bulk_update]}, :require => :loggedin |
|
80 | 80 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
|
81 | 81 | # Queries |
|
82 | 82 | map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member |
|
83 | 83 | map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin |
|
84 | 84 | # Watchers |
|
85 | 85 | map.permission :view_issue_watchers, {} |
|
86 | 86 | map.permission :add_issue_watchers, {:watchers => :new} |
|
87 | 87 | map.permission :delete_issue_watchers, {:watchers => :destroy} |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | map.project_module :time_tracking do |map| |
|
91 | 91 | map.permission :log_time, {:timelog => [:new, :create]}, :require => :loggedin |
|
92 | 92 | map.permission :view_time_entries, :timelog => [:index, :report, :show] |
|
93 | 93 | map.permission :edit_time_entries, {:timelog => [:edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member |
|
94 | 94 | map.permission :edit_own_time_entries, {:timelog => [:edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin |
|
95 | 95 | map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | map.project_module :news do |map| |
|
99 | 99 | map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member |
|
100 | 100 | map.permission :view_news, {:news => [:index, :show]}, :public => true |
|
101 | 101 | map.permission :comment_news, {:comments => :create} |
|
102 | 102 | end |
|
103 | 103 | |
|
104 | 104 | map.project_module :documents do |map| |
|
105 | 105 | map.permission :manage_documents, {:documents => [:new, :create, :edit, :update, :destroy, :add_attachment]}, :require => :loggedin |
|
106 | 106 | map.permission :view_documents, :documents => [:index, :show, :download] |
|
107 | 107 | end |
|
108 | 108 | |
|
109 | 109 | map.project_module :files do |map| |
|
110 | 110 | map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin |
|
111 | 111 | map.permission :view_files, :files => :index, :versions => :download |
|
112 | 112 | end |
|
113 | 113 | |
|
114 | 114 | map.project_module :wiki do |map| |
|
115 | 115 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
116 | 116 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
117 | 117 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
118 | 118 | map.permission :view_wiki_pages, :wiki => [:index, :show, :special, :date_index] |
|
119 | 119 | map.permission :export_wiki_pages, :wiki => [:export] |
|
120 | 120 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] |
|
121 | 121 | map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment] |
|
122 | 122 | map.permission :delete_wiki_pages_attachments, {} |
|
123 | 123 | map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member |
|
124 | 124 | end |
|
125 | 125 | |
|
126 | 126 | map.project_module :repository do |map| |
|
127 | 127 | map.permission :manage_repository, {:repositories => [:new, :create, :edit, :update, :committers, :destroy]}, :require => :member |
|
128 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] | |
|
128 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :raw, :annotate, :changes, :diff, :stats, :graph] | |
|
129 | 129 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
130 | 130 | map.permission :commit_access, {} |
|
131 | 131 | map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]} |
|
132 | 132 | end |
|
133 | 133 | |
|
134 | 134 | map.project_module :boards do |map| |
|
135 | 135 | map.permission :manage_boards, {:boards => [:new, :create, :edit, :update, :destroy]}, :require => :member |
|
136 | 136 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true |
|
137 | 137 | map.permission :add_messages, {:messages => [:new, :reply, :quote]} |
|
138 | 138 | map.permission :edit_messages, {:messages => :edit}, :require => :member |
|
139 | 139 | map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin |
|
140 | 140 | map.permission :delete_messages, {:messages => :destroy}, :require => :member |
|
141 | 141 | map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin |
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | map.project_module :calendar do |map| |
|
145 | 145 | map.permission :view_calendar, :calendars => [:show, :update] |
|
146 | 146 | end |
|
147 | 147 | |
|
148 | 148 | map.project_module :gantt do |map| |
|
149 | 149 | map.permission :view_gantt, :gantts => [:show, :update] |
|
150 | 150 | end |
|
151 | 151 | end |
|
152 | 152 | |
|
153 | 153 | Redmine::MenuManager.map :top_menu do |menu| |
|
154 | 154 | menu.push :home, :home_path |
|
155 | 155 | menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } |
|
156 | 156 | menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural |
|
157 | 157 | menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true |
|
158 | 158 | menu.push :help, Redmine::Info.help_url, :last => true |
|
159 | 159 | end |
|
160 | 160 | |
|
161 | 161 | Redmine::MenuManager.map :account_menu do |menu| |
|
162 | 162 | menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? } |
|
163 | 163 | menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? } |
|
164 | 164 | menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } |
|
165 | 165 | menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? } |
|
166 | 166 | end |
|
167 | 167 | |
|
168 | 168 | Redmine::MenuManager.map :application_menu do |menu| |
|
169 | 169 | # Empty |
|
170 | 170 | end |
|
171 | 171 | |
|
172 | 172 | Redmine::MenuManager.map :admin_menu do |menu| |
|
173 | 173 | menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural |
|
174 | 174 | menu.push :users, {:controller => 'users'}, :caption => :label_user_plural |
|
175 | 175 | menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural |
|
176 | 176 | menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions |
|
177 | 177 | menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural |
|
178 | 178 | menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural, |
|
179 | 179 | :html => {:class => 'issue_statuses'} |
|
180 | 180 | menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow |
|
181 | 181 | menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural, |
|
182 | 182 | :html => {:class => 'custom_fields'} |
|
183 | 183 | menu.push :enumerations, {:controller => 'enumerations'} |
|
184 | 184 | menu.push :settings, {:controller => 'settings'} |
|
185 | 185 | menu.push :ldap_authentication, {:controller => 'auth_sources', :action => 'index'}, |
|
186 | 186 | :html => {:class => 'server_authentication'} |
|
187 | 187 | menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true |
|
188 | 188 | menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true |
|
189 | 189 | end |
|
190 | 190 | |
|
191 | 191 | Redmine::MenuManager.map :project_menu do |menu| |
|
192 | 192 | menu.push :overview, { :controller => 'projects', :action => 'show' } |
|
193 | 193 | menu.push :activity, { :controller => 'activities', :action => 'index' } |
|
194 | 194 | menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id, |
|
195 | 195 | :if => Proc.new { |p| p.shared_versions.any? } |
|
196 | 196 | menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural |
|
197 | 197 | menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, |
|
198 | 198 | :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } |
|
199 | 199 | menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt |
|
200 | 200 | menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar |
|
201 | 201 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural |
|
202 | 202 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural |
|
203 | 203 | menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id, |
|
204 | 204 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
205 | 205 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, |
|
206 | 206 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
|
207 | 207 | menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id |
|
208 | 208 | menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil }, |
|
209 | 209 | :if => Proc.new { |p| p.repository && !p.repository.new_record? } |
|
210 | 210 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true |
|
211 | 211 | end |
|
212 | 212 | |
|
213 | 213 | Redmine::Activity.map do |activity| |
|
214 | 214 | activity.register :issues, :class_name => %w(Issue Journal) |
|
215 | 215 | activity.register :changesets |
|
216 | 216 | activity.register :news |
|
217 | 217 | activity.register :documents, :class_name => %w(Document Attachment) |
|
218 | 218 | activity.register :files, :class_name => 'Attachment' |
|
219 | 219 | activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false |
|
220 | 220 | activity.register :messages, :default => false |
|
221 | 221 | activity.register :time_entries, :default => false |
|
222 | 222 | end |
|
223 | 223 | |
|
224 | 224 | Redmine::Search.map do |search| |
|
225 | 225 | search.register :issues |
|
226 | 226 | search.register :news |
|
227 | 227 | search.register :documents |
|
228 | 228 | search.register :changesets |
|
229 | 229 | search.register :wiki_pages |
|
230 | 230 | search.register :messages |
|
231 | 231 | search.register :projects |
|
232 | 232 | end |
|
233 | 233 | |
|
234 | 234 | Redmine::WikiFormatting.map do |format| |
|
235 | 235 | format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper |
|
236 | 236 | end |
|
237 | 237 | |
|
238 | 238 | ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler |
@@ -1,164 +1,163 | |||
|
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 RepositoriesFilesystemControllerTest < ActionController::TestCase |
|
21 | 21 | tests RepositoriesController |
|
22 | 22 | |
|
23 | 23 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
24 | 24 | :repositories, :enabled_modules |
|
25 | 25 | |
|
26 | 26 | REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s |
|
27 | 27 | PRJ_ID = 3 |
|
28 | 28 | |
|
29 | 29 | def setup |
|
30 | 30 | @ruby19_non_utf8_pass = |
|
31 | 31 | (RUBY_VERSION >= '1.9' && Encoding.default_external.to_s != 'UTF-8') |
|
32 | 32 | User.current = nil |
|
33 | 33 | Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem') |
|
34 | 34 | @project = Project.find(PRJ_ID) |
|
35 | 35 | @repository = Repository::Filesystem.create( |
|
36 | 36 | :project => @project, |
|
37 | 37 | :url => REPOSITORY_PATH, |
|
38 | 38 | :path_encoding => '' |
|
39 | 39 | ) |
|
40 | 40 | assert @repository |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | if File.directory?(REPOSITORY_PATH) |
|
44 | 44 | def test_get_new |
|
45 | 45 | @request.session[:user_id] = 1 |
|
46 | 46 | @project.repository.destroy |
|
47 | 47 | get :new, :project_id => 'subproject1', :repository_scm => 'Filesystem' |
|
48 | 48 | assert_response :success |
|
49 | 49 | assert_template 'new' |
|
50 | 50 | assert_kind_of Repository::Filesystem, assigns(:repository) |
|
51 | 51 | assert assigns(:repository).new_record? |
|
52 | 52 | end |
|
53 | 53 | |
|
54 | 54 | def test_browse_root |
|
55 | 55 | @repository.fetch_changesets |
|
56 | 56 | @repository.reload |
|
57 | 57 | get :show, :id => PRJ_ID |
|
58 | 58 | assert_response :success |
|
59 | 59 | assert_template 'show' |
|
60 | 60 | assert_not_nil assigns(:entries) |
|
61 | 61 | assert assigns(:entries).size > 0 |
|
62 | 62 | assert_not_nil assigns(:changesets) |
|
63 | 63 | assert assigns(:changesets).size == 0 |
|
64 | 64 | |
|
65 | 65 | assert_no_tag 'input', :attributes => {:name => 'rev'} |
|
66 | 66 | assert_no_tag 'a', :content => 'Statistics' |
|
67 | 67 | assert_no_tag 'a', :content => 'Atom' |
|
68 | 68 | end |
|
69 | 69 | |
|
70 | 70 | def test_show_no_extension |
|
71 | 71 | get :entry, :id => PRJ_ID, :path => repository_path_hash(['test'])[:param] |
|
72 | 72 | assert_response :success |
|
73 | 73 | assert_template 'entry' |
|
74 | 74 | assert_tag :tag => 'th', |
|
75 | 75 | :content => '1', |
|
76 | 76 | :attributes => { :class => 'line-num' }, |
|
77 | 77 | :sibling => { :tag => 'td', :content => /TEST CAT/ } |
|
78 | 78 | end |
|
79 | 79 | |
|
80 | 80 | def test_entry_download_no_extension |
|
81 |
get : |
|
|
82 | :format => 'raw' | |
|
81 | get :raw, :id => PRJ_ID, :path => repository_path_hash(['test'])[:param] | |
|
83 | 82 | assert_response :success |
|
84 | 83 | assert_equal 'application/octet-stream', @response.content_type |
|
85 | 84 | end |
|
86 | 85 | |
|
87 | 86 | def test_show_non_ascii_contents |
|
88 | 87 | with_settings :repositories_encodings => 'UTF-8,EUC-JP' do |
|
89 | 88 | get :entry, :id => PRJ_ID, |
|
90 | 89 | :path => repository_path_hash(['japanese', 'euc-jp.txt'])[:param] |
|
91 | 90 | assert_response :success |
|
92 | 91 | assert_template 'entry' |
|
93 | 92 | assert_tag :tag => 'th', |
|
94 | 93 | :content => '2', |
|
95 | 94 | :attributes => { :class => 'line-num' }, |
|
96 | 95 | :sibling => { :tag => 'td', :content => /japanese/ } |
|
97 | 96 | if @ruby19_non_utf8_pass |
|
98 | 97 | puts "TODO: show repository file contents test fails in Ruby 1.9 " + |
|
99 | 98 | "and Encoding.default_external is not UTF-8. " + |
|
100 | 99 | "Current value is '#{Encoding.default_external.to_s}'" |
|
101 | 100 | else |
|
102 | 101 | str_japanese = "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" |
|
103 | 102 | str_japanese.force_encoding('UTF-8') if str_japanese.respond_to?(:force_encoding) |
|
104 | 103 | assert_tag :tag => 'th', |
|
105 | 104 | :content => '3', |
|
106 | 105 | :attributes => { :class => 'line-num' }, |
|
107 | 106 | :sibling => { :tag => 'td', :content => /#{str_japanese}/ } |
|
108 | 107 | end |
|
109 | 108 | end |
|
110 | 109 | end |
|
111 | 110 | |
|
112 | 111 | def test_show_utf16 |
|
113 | 112 | with_settings :repositories_encodings => 'UTF-16' do |
|
114 | 113 | get :entry, :id => PRJ_ID, |
|
115 | 114 | :path => repository_path_hash(['japanese', 'utf-16.txt'])[:param] |
|
116 | 115 | assert_response :success |
|
117 | 116 | assert_tag :tag => 'th', |
|
118 | 117 | :content => '2', |
|
119 | 118 | :attributes => { :class => 'line-num' }, |
|
120 | 119 | :sibling => { :tag => 'td', :content => /japanese/ } |
|
121 | 120 | end |
|
122 | 121 | end |
|
123 | 122 | |
|
124 | 123 | def test_show_text_file_should_send_if_too_big |
|
125 | 124 | with_settings :file_max_size_displayed => 1 do |
|
126 | 125 | get :entry, :id => PRJ_ID, |
|
127 | 126 | :path => repository_path_hash(['japanese', 'big-file.txt'])[:param] |
|
128 | 127 | assert_response :success |
|
129 | 128 | assert_equal 'text/plain', @response.content_type |
|
130 | 129 | end |
|
131 | 130 | end |
|
132 | 131 | |
|
133 | 132 | def test_destroy_valid_repository |
|
134 | 133 | @request.session[:user_id] = 1 # admin |
|
135 | 134 | |
|
136 | 135 | assert_difference 'Repository.count', -1 do |
|
137 | 136 | delete :destroy, :id => @repository.id |
|
138 | 137 | end |
|
139 | 138 | assert_response 302 |
|
140 | 139 | @project.reload |
|
141 | 140 | assert_nil @project.repository |
|
142 | 141 | end |
|
143 | 142 | |
|
144 | 143 | def test_destroy_invalid_repository |
|
145 | 144 | @request.session[:user_id] = 1 # admin |
|
146 | 145 | @project.repository.destroy |
|
147 | 146 | @repository = Repository::Filesystem.create!( |
|
148 | 147 | :project => @project, |
|
149 | 148 | :url => "/invalid", |
|
150 | 149 | :path_encoding => '' |
|
151 | 150 | ) |
|
152 | 151 | |
|
153 | 152 | assert_difference 'Repository.count', -1 do |
|
154 | 153 | delete :destroy, :id => @repository.id |
|
155 | 154 | end |
|
156 | 155 | assert_response 302 |
|
157 | 156 | @project.reload |
|
158 | 157 | assert_nil @project.repository |
|
159 | 158 | end |
|
160 | 159 | else |
|
161 | 160 | puts "Filesystem test repository NOT FOUND. Skipping functional tests !!!" |
|
162 | 161 | def test_fake; assert true end |
|
163 | 162 | end |
|
164 | 163 | end |
@@ -1,412 +1,411 | |||
|
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 RepositoriesSubversionControllerTest < ActionController::TestCase |
|
21 | 21 | tests RepositoriesController |
|
22 | 22 | |
|
23 | 23 | fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, |
|
24 | 24 | :repositories, :issues, :issue_statuses, :changesets, :changes, |
|
25 | 25 | :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers |
|
26 | 26 | |
|
27 | 27 | PRJ_ID = 3 |
|
28 | 28 | NUM_REV = 11 |
|
29 | 29 | |
|
30 | 30 | def setup |
|
31 | 31 | Setting.default_language = 'en' |
|
32 | 32 | User.current = nil |
|
33 | 33 | |
|
34 | 34 | @project = Project.find(PRJ_ID) |
|
35 | 35 | @repository = Repository::Subversion.create(:project => @project, |
|
36 | 36 | :url => self.class.subversion_repository_url) |
|
37 | 37 | assert @repository |
|
38 | 38 | end |
|
39 | 39 | |
|
40 | 40 | if repository_configured?('subversion') |
|
41 | 41 | def test_new |
|
42 | 42 | @request.session[:user_id] = 1 |
|
43 | 43 | @project.repository.destroy |
|
44 | 44 | get :new, :project_id => 'subproject1', :repository_scm => 'Subversion' |
|
45 | 45 | assert_response :success |
|
46 | 46 | assert_template 'new' |
|
47 | 47 | assert_kind_of Repository::Subversion, assigns(:repository) |
|
48 | 48 | assert assigns(:repository).new_record? |
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | def test_show |
|
52 | 52 | assert_equal 0, @repository.changesets.count |
|
53 | 53 | @repository.fetch_changesets |
|
54 | 54 | @project.reload |
|
55 | 55 | assert_equal NUM_REV, @repository.changesets.count |
|
56 | 56 | get :show, :id => PRJ_ID |
|
57 | 57 | assert_response :success |
|
58 | 58 | assert_template 'show' |
|
59 | 59 | assert_not_nil assigns(:entries) |
|
60 | 60 | assert_not_nil assigns(:changesets) |
|
61 | 61 | |
|
62 | 62 | entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} |
|
63 | 63 | assert_not_nil entry |
|
64 | 64 | assert_equal 'dir', entry.kind |
|
65 | 65 | assert_select 'tr.dir a[href=/projects/subproject1/repository/show/subversion_test]' |
|
66 | 66 | |
|
67 | 67 | assert_tag 'input', :attributes => {:name => 'rev'} |
|
68 | 68 | assert_tag 'a', :content => 'Statistics' |
|
69 | 69 | assert_tag 'a', :content => 'Atom' |
|
70 | 70 | assert_tag :tag => 'a', |
|
71 | 71 | :attributes => {:href => '/projects/subproject1/repository'}, |
|
72 | 72 | :content => 'root' |
|
73 | 73 | end |
|
74 | 74 | |
|
75 | 75 | def test_show_non_default |
|
76 | 76 | Repository::Subversion.create(:project => @project, |
|
77 | 77 | :url => self.class.subversion_repository_url, |
|
78 | 78 | :is_default => false, :identifier => 'svn') |
|
79 | 79 | |
|
80 | 80 | get :show, :id => PRJ_ID, :repository_id => 'svn' |
|
81 | 81 | assert_response :success |
|
82 | 82 | assert_template 'show' |
|
83 | 83 | assert_select 'tr.dir a[href=/projects/subproject1/repository/svn/show/subversion_test]' |
|
84 | 84 | # Repository menu should link to the main repo |
|
85 | 85 | assert_select '#main-menu a[href=/projects/subproject1/repository]' |
|
86 | 86 | end |
|
87 | 87 | |
|
88 | 88 | def test_browse_directory |
|
89 | 89 | assert_equal 0, @repository.changesets.count |
|
90 | 90 | @repository.fetch_changesets |
|
91 | 91 | @project.reload |
|
92 | 92 | assert_equal NUM_REV, @repository.changesets.count |
|
93 | 93 | get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param] |
|
94 | 94 | assert_response :success |
|
95 | 95 | assert_template 'show' |
|
96 | 96 | assert_not_nil assigns(:entries) |
|
97 | 97 | assert_equal [ |
|
98 | 98 | '[folder_with_brackets]', 'folder', '.project', |
|
99 | 99 | 'helloworld.c', 'textfile.txt' |
|
100 | 100 | ], |
|
101 | 101 | assigns(:entries).collect(&:name) |
|
102 | 102 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} |
|
103 | 103 | assert_equal 'file', entry.kind |
|
104 | 104 | assert_equal 'subversion_test/helloworld.c', entry.path |
|
105 | 105 | assert_tag :a, :content => 'helloworld.c', :attributes => { :class => /text\-x\-c/ } |
|
106 | 106 | end |
|
107 | 107 | |
|
108 | 108 | def test_browse_at_given_revision |
|
109 | 109 | assert_equal 0, @repository.changesets.count |
|
110 | 110 | @repository.fetch_changesets |
|
111 | 111 | @project.reload |
|
112 | 112 | assert_equal NUM_REV, @repository.changesets.count |
|
113 | 113 | get :show, :id => PRJ_ID, :path => repository_path_hash(['subversion_test'])[:param], |
|
114 | 114 | :rev => 4 |
|
115 | 115 | assert_response :success |
|
116 | 116 | assert_template 'show' |
|
117 | 117 | assert_not_nil assigns(:entries) |
|
118 | 118 | assert_equal ['folder', '.project', 'helloworld.c', 'helloworld.rb', 'textfile.txt'], |
|
119 | 119 | assigns(:entries).collect(&:name) |
|
120 | 120 | end |
|
121 | 121 | |
|
122 | 122 | def test_file_changes |
|
123 | 123 | assert_equal 0, @repository.changesets.count |
|
124 | 124 | @repository.fetch_changesets |
|
125 | 125 | @project.reload |
|
126 | 126 | assert_equal NUM_REV, @repository.changesets.count |
|
127 | 127 | get :changes, :id => PRJ_ID, |
|
128 | 128 | :path => repository_path_hash(['subversion_test', 'folder', 'helloworld.rb'])[:param] |
|
129 | 129 | assert_response :success |
|
130 | 130 | assert_template 'changes' |
|
131 | 131 | |
|
132 | 132 | changesets = assigns(:changesets) |
|
133 | 133 | assert_not_nil changesets |
|
134 | 134 | assert_equal %w(6 3 2), changesets.collect(&:revision) |
|
135 | 135 | |
|
136 | 136 | # svn properties displayed with svn >= 1.5 only |
|
137 | 137 | if Redmine::Scm::Adapters::SubversionAdapter.client_version_above?([1, 5, 0]) |
|
138 | 138 | assert_not_nil assigns(:properties) |
|
139 | 139 | assert_equal 'native', assigns(:properties)['svn:eol-style'] |
|
140 | 140 | assert_tag :ul, |
|
141 | 141 | :child => { :tag => 'li', |
|
142 | 142 | :child => { :tag => 'b', :content => 'svn:eol-style' }, |
|
143 | 143 | :child => { :tag => 'span', :content => 'native' } } |
|
144 | 144 | end |
|
145 | 145 | end |
|
146 | 146 | |
|
147 | 147 | def test_directory_changes |
|
148 | 148 | assert_equal 0, @repository.changesets.count |
|
149 | 149 | @repository.fetch_changesets |
|
150 | 150 | @project.reload |
|
151 | 151 | assert_equal NUM_REV, @repository.changesets.count |
|
152 | 152 | get :changes, :id => PRJ_ID, |
|
153 | 153 | :path => repository_path_hash(['subversion_test', 'folder'])[:param] |
|
154 | 154 | assert_response :success |
|
155 | 155 | assert_template 'changes' |
|
156 | 156 | |
|
157 | 157 | changesets = assigns(:changesets) |
|
158 | 158 | assert_not_nil changesets |
|
159 | 159 | assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision) |
|
160 | 160 | end |
|
161 | 161 | |
|
162 | 162 | def test_entry |
|
163 | 163 | assert_equal 0, @repository.changesets.count |
|
164 | 164 | @repository.fetch_changesets |
|
165 | 165 | @project.reload |
|
166 | 166 | assert_equal NUM_REV, @repository.changesets.count |
|
167 | 167 | get :entry, :id => PRJ_ID, |
|
168 | 168 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
169 | 169 | assert_response :success |
|
170 | 170 | assert_template 'entry' |
|
171 | 171 | end |
|
172 | 172 | |
|
173 | 173 | def test_entry_should_send_if_too_big |
|
174 | 174 | assert_equal 0, @repository.changesets.count |
|
175 | 175 | @repository.fetch_changesets |
|
176 | 176 | @project.reload |
|
177 | 177 | assert_equal NUM_REV, @repository.changesets.count |
|
178 | 178 | # no files in the test repo is larger than 1KB... |
|
179 | 179 | with_settings :file_max_size_displayed => 0 do |
|
180 | 180 | get :entry, :id => PRJ_ID, |
|
181 | 181 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
182 | 182 | assert_response :success |
|
183 | 183 | assert_equal 'attachment; filename="helloworld.c"', |
|
184 | 184 | @response.headers['Content-Disposition'] |
|
185 | 185 | end |
|
186 | 186 | end |
|
187 | 187 | |
|
188 | 188 | def test_entry_at_given_revision |
|
189 | 189 | assert_equal 0, @repository.changesets.count |
|
190 | 190 | @repository.fetch_changesets |
|
191 | 191 | @project.reload |
|
192 | 192 | assert_equal NUM_REV, @repository.changesets.count |
|
193 | 193 | get :entry, :id => PRJ_ID, |
|
194 | 194 | :path => repository_path_hash(['subversion_test', 'helloworld.rb'])[:param], |
|
195 | 195 | :rev => 2 |
|
196 | 196 | assert_response :success |
|
197 | 197 | assert_template 'entry' |
|
198 | 198 | # this line was removed in r3 and file was moved in r6 |
|
199 | 199 | assert_tag :tag => 'td', :attributes => { :class => /line-code/}, |
|
200 | 200 | :content => /Here's the code/ |
|
201 | 201 | end |
|
202 | 202 | |
|
203 | 203 | def test_entry_not_found |
|
204 | 204 | assert_equal 0, @repository.changesets.count |
|
205 | 205 | @repository.fetch_changesets |
|
206 | 206 | @project.reload |
|
207 | 207 | assert_equal NUM_REV, @repository.changesets.count |
|
208 | 208 | get :entry, :id => PRJ_ID, |
|
209 | 209 | :path => repository_path_hash(['subversion_test', 'zzz.c'])[:param] |
|
210 | 210 | assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ }, |
|
211 | 211 | :content => /The entry or revision was not found in the repository/ |
|
212 | 212 | end |
|
213 | 213 | |
|
214 | 214 | def test_entry_download |
|
215 | 215 | assert_equal 0, @repository.changesets.count |
|
216 | 216 | @repository.fetch_changesets |
|
217 | 217 | @project.reload |
|
218 | 218 | assert_equal NUM_REV, @repository.changesets.count |
|
219 |
get : |
|
|
220 |
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
|
221 | :format => 'raw' | |
|
219 | get :raw, :id => PRJ_ID, | |
|
220 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] | |
|
222 | 221 | assert_response :success |
|
223 | 222 | assert_equal 'attachment; filename="helloworld.c"', @response.headers['Content-Disposition'] |
|
224 | 223 | end |
|
225 | 224 | |
|
226 | 225 | def test_directory_entry |
|
227 | 226 | assert_equal 0, @repository.changesets.count |
|
228 | 227 | @repository.fetch_changesets |
|
229 | 228 | @project.reload |
|
230 | 229 | assert_equal NUM_REV, @repository.changesets.count |
|
231 | 230 | get :entry, :id => PRJ_ID, |
|
232 | 231 | :path => repository_path_hash(['subversion_test', 'folder'])[:param] |
|
233 | 232 | assert_response :success |
|
234 | 233 | assert_template 'show' |
|
235 | 234 | assert_not_nil assigns(:entry) |
|
236 | 235 | assert_equal 'folder', assigns(:entry).name |
|
237 | 236 | end |
|
238 | 237 | |
|
239 | 238 | # TODO: this test needs fixtures. |
|
240 | 239 | def test_revision |
|
241 | 240 | get :revision, :id => 1, :rev => 2 |
|
242 | 241 | assert_response :success |
|
243 | 242 | assert_template 'revision' |
|
244 | 243 | assert_tag :tag => 'ul', |
|
245 | 244 | :child => { :tag => 'li', |
|
246 | 245 | # link to the entry at rev 2 |
|
247 | 246 | :child => { :tag => 'a', |
|
248 | 247 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'}, |
|
249 | 248 | :content => 'repo', |
|
250 | 249 | # link to partial diff |
|
251 | 250 | :sibling => { :tag => 'a', |
|
252 | 251 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' } |
|
253 | 252 | } |
|
254 | 253 | } |
|
255 | 254 | } |
|
256 | 255 | end |
|
257 | 256 | |
|
258 | 257 | def test_invalid_revision |
|
259 | 258 | assert_equal 0, @repository.changesets.count |
|
260 | 259 | @repository.fetch_changesets |
|
261 | 260 | @project.reload |
|
262 | 261 | assert_equal NUM_REV, @repository.changesets.count |
|
263 | 262 | get :revision, :id => PRJ_ID, :rev => 'something_weird' |
|
264 | 263 | assert_response 404 |
|
265 | 264 | assert_error_tag :content => /was not found/ |
|
266 | 265 | end |
|
267 | 266 | |
|
268 | 267 | def test_invalid_revision_diff |
|
269 | 268 | get :diff, :id => PRJ_ID, :rev => '1', :rev_to => 'something_weird' |
|
270 | 269 | assert_response 404 |
|
271 | 270 | assert_error_tag :content => /was not found/ |
|
272 | 271 | end |
|
273 | 272 | |
|
274 | 273 | def test_empty_revision |
|
275 | 274 | assert_equal 0, @repository.changesets.count |
|
276 | 275 | @repository.fetch_changesets |
|
277 | 276 | @project.reload |
|
278 | 277 | assert_equal NUM_REV, @repository.changesets.count |
|
279 | 278 | ['', ' ', nil].each do |r| |
|
280 | 279 | get :revision, :id => PRJ_ID, :rev => r |
|
281 | 280 | assert_response 404 |
|
282 | 281 | assert_error_tag :content => /was not found/ |
|
283 | 282 | end |
|
284 | 283 | end |
|
285 | 284 | |
|
286 | 285 | # TODO: this test needs fixtures. |
|
287 | 286 | def test_revision_with_repository_pointing_to_a_subdirectory |
|
288 | 287 | r = Project.find(1).repository |
|
289 | 288 | # Changes repository url to a subdirectory |
|
290 | 289 | r.update_attribute :url, (r.url + '/test/some') |
|
291 | 290 | |
|
292 | 291 | get :revision, :id => 1, :rev => 2 |
|
293 | 292 | assert_response :success |
|
294 | 293 | assert_template 'revision' |
|
295 | 294 | assert_tag :tag => 'ul', |
|
296 | 295 | :child => { :tag => 'li', |
|
297 | 296 | # link to the entry at rev 2 |
|
298 | 297 | :child => { :tag => 'a', |
|
299 | 298 | :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'}, |
|
300 | 299 | :content => 'repo', |
|
301 | 300 | # link to partial diff |
|
302 | 301 | :sibling => { :tag => 'a', |
|
303 | 302 | :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' } |
|
304 | 303 | } |
|
305 | 304 | } |
|
306 | 305 | } |
|
307 | 306 | end |
|
308 | 307 | |
|
309 | 308 | def test_revision_diff |
|
310 | 309 | assert_equal 0, @repository.changesets.count |
|
311 | 310 | @repository.fetch_changesets |
|
312 | 311 | @project.reload |
|
313 | 312 | assert_equal NUM_REV, @repository.changesets.count |
|
314 | 313 | ['inline', 'sbs'].each do |dt| |
|
315 | 314 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt |
|
316 | 315 | assert_response :success |
|
317 | 316 | assert_template 'diff' |
|
318 | 317 | assert_tag :tag => 'h2', |
|
319 | 318 | :content => / 3/ |
|
320 | 319 | end |
|
321 | 320 | end |
|
322 | 321 | |
|
323 | 322 | def test_revision_diff_raw_format |
|
324 | 323 | assert_equal 0, @repository.changesets.count |
|
325 | 324 | @repository.fetch_changesets |
|
326 | 325 | @project.reload |
|
327 | 326 | assert_equal NUM_REV, @repository.changesets.count |
|
328 | 327 | |
|
329 | 328 | get :diff, :id => PRJ_ID, :rev => 3, :format => 'diff' |
|
330 | 329 | assert_response :success |
|
331 | 330 | assert_equal 'text/x-patch', @response.content_type |
|
332 | 331 | assert_equal 'Index: subversion_test/textfile.txt', @response.body.split(/\r?\n/).first |
|
333 | 332 | end |
|
334 | 333 | |
|
335 | 334 | def test_directory_diff |
|
336 | 335 | assert_equal 0, @repository.changesets.count |
|
337 | 336 | @repository.fetch_changesets |
|
338 | 337 | @project.reload |
|
339 | 338 | assert_equal NUM_REV, @repository.changesets.count |
|
340 | 339 | ['inline', 'sbs'].each do |dt| |
|
341 | 340 | get :diff, :id => PRJ_ID, :rev => 6, :rev_to => 2, |
|
342 | 341 | :path => repository_path_hash(['subversion_test', 'folder'])[:param], |
|
343 | 342 | :type => dt |
|
344 | 343 | assert_response :success |
|
345 | 344 | assert_template 'diff' |
|
346 | 345 | |
|
347 | 346 | diff = assigns(:diff) |
|
348 | 347 | assert_not_nil diff |
|
349 | 348 | # 2 files modified |
|
350 | 349 | assert_equal 2, Redmine::UnifiedDiff.new(diff).size |
|
351 | 350 | assert_tag :tag => 'h2', :content => /2:6/ |
|
352 | 351 | end |
|
353 | 352 | end |
|
354 | 353 | |
|
355 | 354 | def test_annotate |
|
356 | 355 | assert_equal 0, @repository.changesets.count |
|
357 | 356 | @repository.fetch_changesets |
|
358 | 357 | @project.reload |
|
359 | 358 | assert_equal NUM_REV, @repository.changesets.count |
|
360 | 359 | get :annotate, :id => PRJ_ID, |
|
361 | 360 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
362 | 361 | assert_response :success |
|
363 | 362 | assert_template 'annotate' |
|
364 | 363 | end |
|
365 | 364 | |
|
366 | 365 | def test_annotate_at_given_revision |
|
367 | 366 | assert_equal 0, @repository.changesets.count |
|
368 | 367 | @repository.fetch_changesets |
|
369 | 368 | @project.reload |
|
370 | 369 | assert_equal NUM_REV, @repository.changesets.count |
|
371 | 370 | get :annotate, :id => PRJ_ID, :rev => 8, |
|
372 | 371 | :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param] |
|
373 | 372 | assert_response :success |
|
374 | 373 | assert_template 'annotate' |
|
375 | 374 | assert_tag :tag => 'h2', :content => /@ 8/ |
|
376 | 375 | end |
|
377 | 376 | |
|
378 | 377 | def test_destroy_valid_repository |
|
379 | 378 | @request.session[:user_id] = 1 # admin |
|
380 | 379 | assert_equal 0, @repository.changesets.count |
|
381 | 380 | @repository.fetch_changesets |
|
382 | 381 | assert_equal NUM_REV, @repository.changesets.count |
|
383 | 382 | |
|
384 | 383 | assert_difference 'Repository.count', -1 do |
|
385 | 384 | delete :destroy, :id => @repository.id |
|
386 | 385 | end |
|
387 | 386 | assert_response 302 |
|
388 | 387 | @project.reload |
|
389 | 388 | assert_nil @project.repository |
|
390 | 389 | end |
|
391 | 390 | |
|
392 | 391 | def test_destroy_invalid_repository |
|
393 | 392 | @request.session[:user_id] = 1 # admin |
|
394 | 393 | @project.repository.destroy |
|
395 | 394 | @repository = Repository::Subversion.create!( |
|
396 | 395 | :project => @project, |
|
397 | 396 | :url => "file:///invalid") |
|
398 | 397 | @repository.fetch_changesets |
|
399 | 398 | assert_equal 0, @repository.changesets.count |
|
400 | 399 | |
|
401 | 400 | assert_difference 'Repository.count', -1 do |
|
402 | 401 | delete :destroy, :id => @repository.id |
|
403 | 402 | end |
|
404 | 403 | assert_response 302 |
|
405 | 404 | @project.reload |
|
406 | 405 | assert_nil @project.repository |
|
407 | 406 | end |
|
408 | 407 | else |
|
409 | 408 | puts "Subversion test repository NOT FOUND. Skipping functional tests !!!" |
|
410 | 409 | def test_fake; assert true end |
|
411 | 410 | end |
|
412 | 411 | end |
@@ -1,409 +1,409 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2012 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 "path/to/file.c", @path_hash[:param] |
|
25 | 25 | end |
|
26 | 26 | |
|
27 | 27 | def test_repositories_resources |
|
28 | 28 | assert_routing( |
|
29 | 29 | { :method => 'get', |
|
30 | 30 | :path => "/projects/redmine/repositories/new" }, |
|
31 | 31 | { :controller => 'repositories', :action => 'new', :project_id => 'redmine' } |
|
32 | 32 | ) |
|
33 | 33 | assert_routing( |
|
34 | 34 | { :method => 'post', |
|
35 | 35 | :path => "/projects/redmine/repositories" }, |
|
36 | 36 | { :controller => 'repositories', :action => 'create', :project_id => 'redmine' } |
|
37 | 37 | ) |
|
38 | 38 | assert_routing( |
|
39 | 39 | { :method => 'get', |
|
40 | 40 | :path => "/repositories/1/edit" }, |
|
41 | 41 | { :controller => 'repositories', :action => 'edit', :id => '1' } |
|
42 | 42 | ) |
|
43 | 43 | assert_routing( |
|
44 | 44 | { :method => 'put', |
|
45 | 45 | :path => "/repositories/1" }, |
|
46 | 46 | { :controller => 'repositories', :action => 'update', :id => '1' } |
|
47 | 47 | ) |
|
48 | 48 | assert_routing( |
|
49 | 49 | { :method => 'delete', |
|
50 | 50 | :path => "/repositories/1" }, |
|
51 | 51 | { :controller => 'repositories', :action => 'destroy', :id => '1' } |
|
52 | 52 | ) |
|
53 | 53 | ["get", "post"].each do |method| |
|
54 | 54 | assert_routing( |
|
55 | 55 | { :method => method, |
|
56 | 56 | :path => "/repositories/1/committers" }, |
|
57 | 57 | { :controller => 'repositories', :action => 'committers', :id => '1' } |
|
58 | 58 | ) |
|
59 | 59 | end |
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | def test_repositories_show |
|
63 | 63 | assert_routing( |
|
64 | 64 | { :method => 'get', |
|
65 | 65 | :path => "/projects/redmine/repository" }, |
|
66 | 66 | { :controller => 'repositories', :action => 'show', :id => 'redmine' } |
|
67 | 67 | ) |
|
68 | 68 | end |
|
69 | 69 | |
|
70 | 70 | def test_repositories |
|
71 | 71 | assert_routing( |
|
72 | 72 | { :method => 'get', |
|
73 | 73 | :path => "/projects/redmine/repository/statistics" }, |
|
74 | 74 | { :controller => 'repositories', :action => 'stats', :id => 'redmine' } |
|
75 | 75 | ) |
|
76 | 76 | assert_routing( |
|
77 | 77 | { :method => 'get', |
|
78 | 78 | :path => "/projects/redmine/repository/graph" }, |
|
79 | 79 | { :controller => 'repositories', :action => 'graph', :id => 'redmine' } |
|
80 | 80 | ) |
|
81 | 81 | end |
|
82 | 82 | |
|
83 | 83 | def test_repositories_show_with_repository_id |
|
84 | 84 | assert_routing( |
|
85 | 85 | { :method => 'get', |
|
86 | 86 | :path => "/projects/redmine/repository/foo" }, |
|
87 | 87 | { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo' } |
|
88 | 88 | ) |
|
89 | 89 | end |
|
90 | 90 | |
|
91 | 91 | def test_repositories_with_repository_id |
|
92 | 92 | assert_routing( |
|
93 | 93 | { :method => 'get', |
|
94 | 94 | :path => "/projects/redmine/repository/foo/statistics" }, |
|
95 | 95 | { :controller => 'repositories', :action => 'stats', :id => 'redmine', :repository_id => 'foo' } |
|
96 | 96 | ) |
|
97 | 97 | assert_routing( |
|
98 | 98 | { :method => 'get', |
|
99 | 99 | :path => "/projects/redmine/repository/foo/graph" }, |
|
100 | 100 | { :controller => 'repositories', :action => 'graph', :id => 'redmine', :repository_id => 'foo' } |
|
101 | 101 | ) |
|
102 | 102 | end |
|
103 | 103 | |
|
104 | 104 | def test_repositories_revisions |
|
105 | 105 | empty_path_param = [] |
|
106 | 106 | assert_routing( |
|
107 | 107 | { :method => 'get', |
|
108 | 108 | :path => "/projects/redmine/repository/revisions" }, |
|
109 | 109 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine' } |
|
110 | 110 | ) |
|
111 | 111 | assert_routing( |
|
112 | 112 | { :method => 'get', |
|
113 | 113 | :path => "/projects/redmine/repository/revisions.atom" }, |
|
114 | 114 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', |
|
115 | 115 | :format => 'atom' } |
|
116 | 116 | ) |
|
117 | 117 | assert_routing( |
|
118 | 118 | { :method => 'get', |
|
119 | 119 | :path => "/projects/redmine/repository/revisions/2457" }, |
|
120 | 120 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', |
|
121 | 121 | :rev => '2457' } |
|
122 | 122 | ) |
|
123 | 123 | assert_routing( |
|
124 | 124 | { :method => 'get', |
|
125 | 125 | :path => "/projects/redmine/repository/revisions/2457/show" }, |
|
126 | 126 | { :controller => 'repositories', :action => 'show', :id => 'redmine', |
|
127 | 127 | :rev => '2457' } |
|
128 | 128 | ) |
|
129 | 129 | assert_routing( |
|
130 | 130 | { :method => 'get', |
|
131 | 131 | :path => "/projects/redmine/repository/revisions/2457/show/#{@path_hash[:path]}" }, |
|
132 | 132 | { :controller => 'repositories', :action => 'show', :id => 'redmine', |
|
133 | 133 | :path => @path_hash[:param] , :rev => '2457'} |
|
134 | 134 | ) |
|
135 | 135 | assert_routing( |
|
136 | 136 | { :method => 'get', |
|
137 | 137 | :path => "/projects/redmine/repository/changes" }, |
|
138 | 138 | { :controller => 'repositories', :action => 'changes', :id => 'redmine' } |
|
139 | 139 | ) |
|
140 | 140 | ['2457', 'master', 'slash/slash'].each do |rev| |
|
141 | 141 | assert_routing( |
|
142 | 142 | { :method => 'get', |
|
143 | 143 | :path => "/projects/redmine/repository/changes" }, |
|
144 | 144 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
145 | 145 | :rev => rev }, |
|
146 | 146 | {}, |
|
147 | 147 | { :rev => rev } |
|
148 | 148 | ) |
|
149 | 149 | end |
|
150 | 150 | ['2457', 'master', 'slash/slash'].each do |rev| |
|
151 | 151 | assert_routing( |
|
152 | 152 | { :method => 'get', |
|
153 | 153 | :path => "/projects/redmine/repository/changes/#{@path_hash[:path]}" }, |
|
154 | 154 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
155 | 155 | :path => @path_hash[:param], :rev => rev }, |
|
156 | 156 | {}, |
|
157 | 157 | { :rev => rev } |
|
158 | 158 | ) |
|
159 | 159 | end |
|
160 | 160 | assert_routing( |
|
161 | 161 | { :method => 'get', |
|
162 | 162 | :path => "/projects/redmine/repository/revisions/2457/diff" }, |
|
163 | 163 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
164 | 164 | :rev => '2457' } |
|
165 | 165 | ) |
|
166 | 166 | assert_routing( |
|
167 | 167 | { :method => 'get', |
|
168 | 168 | :path => "/projects/redmine/repository/revisions/2457/diff.diff" }, |
|
169 | 169 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
170 | 170 | :rev => '2457', :format => 'diff' } |
|
171 | 171 | ) |
|
172 | 172 | assert_routing( |
|
173 | 173 | { :method => 'get', |
|
174 | 174 | :path => "/projects/redmine/repository/revisions/2/diff/#{@path_hash[:path]}" }, |
|
175 | 175 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
176 | 176 | :path => @path_hash[:param], :rev => '2' } |
|
177 | 177 | ) |
|
178 | 178 | assert_routing( |
|
179 | 179 | { :method => 'get', |
|
180 | 180 | :path => "/projects/redmine/repository/revisions/2/entry/#{@path_hash[:path]}" }, |
|
181 | 181 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
182 | 182 | :path => @path_hash[:param], :rev => '2' } |
|
183 | 183 | ) |
|
184 | 184 | assert_routing( |
|
185 | 185 | { :method => 'get', |
|
186 | 186 | :path => "/projects/redmine/repository/revisions/2/raw/#{@path_hash[:path]}" }, |
|
187 |
{ :controller => 'repositories', :action => ' |
|
|
188 |
:path => @path_hash[:param], :rev => '2' |
|
|
187 | { :controller => 'repositories', :action => 'raw', :id => 'redmine', | |
|
188 | :path => @path_hash[:param], :rev => '2' } | |
|
189 | 189 | ) |
|
190 | 190 | assert_routing( |
|
191 | 191 | { :method => 'get', |
|
192 | 192 | :path => "/projects/redmine/repository/revisions/2/annotate/#{@path_hash[:path]}" }, |
|
193 | 193 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', |
|
194 | 194 | :path => @path_hash[:param], :rev => '2' } |
|
195 | 195 | ) |
|
196 | 196 | end |
|
197 | 197 | |
|
198 | 198 | def test_repositories_revisions_with_repository_id |
|
199 | 199 | empty_path_param = [] |
|
200 | 200 | assert_routing( |
|
201 | 201 | { :method => 'get', |
|
202 | 202 | :path => "/projects/redmine/repository/foo/revisions" }, |
|
203 | 203 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo' } |
|
204 | 204 | ) |
|
205 | 205 | assert_routing( |
|
206 | 206 | { :method => 'get', |
|
207 | 207 | :path => "/projects/redmine/repository/foo/revisions.atom" }, |
|
208 | 208 | { :controller => 'repositories', :action => 'revisions', :id => 'redmine', :repository_id => 'foo', |
|
209 | 209 | :format => 'atom' } |
|
210 | 210 | ) |
|
211 | 211 | assert_routing( |
|
212 | 212 | { :method => 'get', |
|
213 | 213 | :path => "/projects/redmine/repository/foo/revisions/2457" }, |
|
214 | 214 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', :repository_id => 'foo', |
|
215 | 215 | :rev => '2457' } |
|
216 | 216 | ) |
|
217 | 217 | assert_routing( |
|
218 | 218 | { :method => 'get', |
|
219 | 219 | :path => "/projects/redmine/repository/foo/revisions/2457/show" }, |
|
220 | 220 | { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo', |
|
221 | 221 | :rev => '2457' } |
|
222 | 222 | ) |
|
223 | 223 | assert_routing( |
|
224 | 224 | { :method => 'get', |
|
225 | 225 | :path => "/projects/redmine/repository/foo/revisions/2457/show/#{@path_hash[:path]}" }, |
|
226 | 226 | { :controller => 'repositories', :action => 'show', :id => 'redmine', :repository_id => 'foo', |
|
227 | 227 | :path => @path_hash[:param] , :rev => '2457'} |
|
228 | 228 | ) |
|
229 | 229 | assert_routing( |
|
230 | 230 | { :method => 'get', |
|
231 | 231 | :path => "/projects/redmine/repository/foo/changes" }, |
|
232 | 232 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo' } |
|
233 | 233 | ) |
|
234 | 234 | ['2457', 'master', 'slash/slash'].each do |rev| |
|
235 | 235 | assert_routing( |
|
236 | 236 | { :method => 'get', |
|
237 | 237 | :path => "/projects/redmine/repository/foo/changes" }, |
|
238 | 238 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
239 | 239 | :repository_id => 'foo', :rev => rev }, |
|
240 | 240 | {}, |
|
241 | 241 | { :rev => rev } |
|
242 | 242 | ) |
|
243 | 243 | end |
|
244 | 244 | ['2457', 'master', 'slash/slash'].each do |rev| |
|
245 | 245 | assert_routing( |
|
246 | 246 | { :method => 'get', |
|
247 | 247 | :path => "/projects/redmine/repository/foo/changes/#{@path_hash[:path]}" }, |
|
248 | 248 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
249 | 249 | :repository_id => 'foo', :path => @path_hash[:param], :rev => rev }, |
|
250 | 250 | {}, |
|
251 | 251 | { :rev => rev } |
|
252 | 252 | ) |
|
253 | 253 | end |
|
254 | 254 | assert_routing( |
|
255 | 255 | { :method => 'get', |
|
256 | 256 | :path => "/projects/redmine/repository/foo/revisions/2457/diff" }, |
|
257 | 257 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', |
|
258 | 258 | :rev => '2457' } |
|
259 | 259 | ) |
|
260 | 260 | assert_routing( |
|
261 | 261 | { :method => 'get', |
|
262 | 262 | :path => "/projects/redmine/repository/foo/revisions/2457/diff.diff" }, |
|
263 | 263 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', |
|
264 | 264 | :rev => '2457', :format => 'diff' } |
|
265 | 265 | ) |
|
266 | 266 | assert_routing( |
|
267 | 267 | { :method => 'get', |
|
268 | 268 | :path => "/projects/redmine/repository/foo/revisions/2/diff/#{@path_hash[:path]}" }, |
|
269 | 269 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', |
|
270 | 270 | :path => @path_hash[:param], :rev => '2' } |
|
271 | 271 | ) |
|
272 | 272 | assert_routing( |
|
273 | 273 | { :method => 'get', |
|
274 | 274 | :path => "/projects/redmine/repository/foo/revisions/2/entry/#{@path_hash[:path]}" }, |
|
275 | 275 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', |
|
276 | 276 | :path => @path_hash[:param], :rev => '2' } |
|
277 | 277 | ) |
|
278 | 278 | assert_routing( |
|
279 | 279 | { :method => 'get', |
|
280 | 280 | :path => "/projects/redmine/repository/foo/revisions/2/raw/#{@path_hash[:path]}" }, |
|
281 |
{ :controller => 'repositories', :action => ' |
|
|
282 |
:path => @path_hash[:param], :rev => '2' |
|
|
281 | { :controller => 'repositories', :action => 'raw', :id => 'redmine', :repository_id => 'foo', | |
|
282 | :path => @path_hash[:param], :rev => '2' } | |
|
283 | 283 | ) |
|
284 | 284 | assert_routing( |
|
285 | 285 | { :method => 'get', |
|
286 | 286 | :path => "/projects/redmine/repository/foo/revisions/2/annotate/#{@path_hash[:path]}" }, |
|
287 | 287 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo', |
|
288 | 288 | :path => @path_hash[:param], :rev => '2' } |
|
289 | 289 | ) |
|
290 | 290 | end |
|
291 | 291 | |
|
292 | 292 | def test_repositories_non_revisions_path |
|
293 | 293 | assert_routing( |
|
294 | 294 | { :method => 'get', |
|
295 | 295 | :path => "/projects/redmine/repository/diff/#{@path_hash[:path]}" }, |
|
296 | 296 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', |
|
297 | 297 | :path => @path_hash[:param] } |
|
298 | 298 | ) |
|
299 | 299 | assert_routing( |
|
300 | 300 | { :method => 'get', |
|
301 | 301 | :path => "/projects/redmine/repository/browse/#{@path_hash[:path]}" }, |
|
302 | 302 | { :controller => 'repositories', :action => 'browse', :id => 'redmine', |
|
303 | 303 | :path => @path_hash[:param] } |
|
304 | 304 | ) |
|
305 | 305 | assert_routing( |
|
306 | 306 | { :method => 'get', |
|
307 | 307 | :path => "/projects/redmine/repository/entry/#{@path_hash[:path]}" }, |
|
308 | 308 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', |
|
309 | 309 | :path => @path_hash[:param] } |
|
310 | 310 | ) |
|
311 | 311 | assert_routing( |
|
312 | 312 | { :method => 'get', |
|
313 | 313 | :path => "/projects/redmine/repository/raw/#{@path_hash[:path]}" }, |
|
314 |
{ :controller => 'repositories', :action => ' |
|
|
315 |
:path => @path_hash[:param] |
|
|
314 | { :controller => 'repositories', :action => 'raw', :id => 'redmine', | |
|
315 | :path => @path_hash[:param] } | |
|
316 | 316 | ) |
|
317 | 317 | assert_routing( |
|
318 | 318 | { :method => 'get', |
|
319 | 319 | :path => "/projects/redmine/repository/annotate/#{@path_hash[:path]}" }, |
|
320 | 320 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', |
|
321 | 321 | :path => @path_hash[:param] } |
|
322 | 322 | ) |
|
323 | 323 | assert_routing( |
|
324 | 324 | { :method => 'get', |
|
325 | 325 | :path => "/projects/redmine/repository/changes/#{@path_hash[:path]}" }, |
|
326 | 326 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', |
|
327 | 327 | :path => @path_hash[:param] } |
|
328 | 328 | ) |
|
329 | 329 | assert_routing( |
|
330 | 330 | { :method => 'get', |
|
331 | 331 | :path => "/projects/redmine/repository/revision" }, |
|
332 | 332 | { :controller => 'repositories', :action => 'revision', :id => 'redmine' } |
|
333 | 333 | ) |
|
334 | 334 | end |
|
335 | 335 | |
|
336 | 336 | def test_repositories_non_revisions_path_with_repository_id |
|
337 | 337 | assert_routing( |
|
338 | 338 | { :method => 'get', |
|
339 | 339 | :path => "/projects/redmine/repository/foo/diff/#{@path_hash[:path]}" }, |
|
340 | 340 | { :controller => 'repositories', :action => 'diff', :id => 'redmine', :repository_id => 'foo', |
|
341 | 341 | :path => @path_hash[:param] } |
|
342 | 342 | ) |
|
343 | 343 | assert_routing( |
|
344 | 344 | { :method => 'get', |
|
345 | 345 | :path => "/projects/redmine/repository/foo/browse/#{@path_hash[:path]}" }, |
|
346 | 346 | { :controller => 'repositories', :action => 'browse', :id => 'redmine', :repository_id => 'foo', |
|
347 | 347 | :path => @path_hash[:param] } |
|
348 | 348 | ) |
|
349 | 349 | assert_routing( |
|
350 | 350 | { :method => 'get', |
|
351 | 351 | :path => "/projects/redmine/repository/foo/entry/#{@path_hash[:path]}" }, |
|
352 | 352 | { :controller => 'repositories', :action => 'entry', :id => 'redmine', :repository_id => 'foo', |
|
353 | 353 | :path => @path_hash[:param] } |
|
354 | 354 | ) |
|
355 | 355 | assert_routing( |
|
356 | 356 | { :method => 'get', |
|
357 | 357 | :path => "/projects/redmine/repository/foo/raw/#{@path_hash[:path]}" }, |
|
358 |
{ :controller => 'repositories', :action => ' |
|
|
359 |
:path => @path_hash[:param] |
|
|
358 | { :controller => 'repositories', :action => 'raw', :id => 'redmine', :repository_id => 'foo', | |
|
359 | :path => @path_hash[:param] } | |
|
360 | 360 | ) |
|
361 | 361 | assert_routing( |
|
362 | 362 | { :method => 'get', |
|
363 | 363 | :path => "/projects/redmine/repository/foo/annotate/#{@path_hash[:path]}" }, |
|
364 | 364 | { :controller => 'repositories', :action => 'annotate', :id => 'redmine', :repository_id => 'foo', |
|
365 | 365 | :path => @path_hash[:param] } |
|
366 | 366 | ) |
|
367 | 367 | assert_routing( |
|
368 | 368 | { :method => 'get', |
|
369 | 369 | :path => "/projects/redmine/repository/foo/changes/#{@path_hash[:path]}" }, |
|
370 | 370 | { :controller => 'repositories', :action => 'changes', :id => 'redmine', :repository_id => 'foo', |
|
371 | 371 | :path => @path_hash[:param] } |
|
372 | 372 | ) |
|
373 | 373 | assert_routing( |
|
374 | 374 | { :method => 'get', |
|
375 | 375 | :path => "/projects/redmine/repository/foo/revision" }, |
|
376 | 376 | { :controller => 'repositories', :action => 'revision', :id => 'redmine', :repository_id => 'foo'} |
|
377 | 377 | ) |
|
378 | 378 | end |
|
379 | 379 | |
|
380 | 380 | def test_repositories_related_issues |
|
381 | 381 | assert_routing( |
|
382 | 382 | { :method => 'post', |
|
383 | 383 | :path => "/projects/redmine/repository/revisions/123/issues" }, |
|
384 | 384 | { :controller => 'repositories', :action => 'add_related_issue', |
|
385 | 385 | :id => 'redmine', :rev => '123' } |
|
386 | 386 | ) |
|
387 | 387 | assert_routing( |
|
388 | 388 | { :method => 'delete', |
|
389 | 389 | :path => "/projects/redmine/repository/revisions/123/issues/25" }, |
|
390 | 390 | { :controller => 'repositories', :action => 'remove_related_issue', |
|
391 | 391 | :id => 'redmine', :rev => '123', :issue_id => '25' } |
|
392 | 392 | ) |
|
393 | 393 | end |
|
394 | 394 | |
|
395 | 395 | def test_repositories_related_issues_with_repository_id |
|
396 | 396 | assert_routing( |
|
397 | 397 | { :method => 'post', |
|
398 | 398 | :path => "/projects/redmine/repository/foo/revisions/123/issues" }, |
|
399 | 399 | { :controller => 'repositories', :action => 'add_related_issue', |
|
400 | 400 | :id => 'redmine', :repository_id => 'foo', :rev => '123' } |
|
401 | 401 | ) |
|
402 | 402 | assert_routing( |
|
403 | 403 | { :method => 'delete', |
|
404 | 404 | :path => "/projects/redmine/repository/foo/revisions/123/issues/25" }, |
|
405 | 405 | { :controller => 'repositories', :action => 'remove_related_issue', |
|
406 | 406 | :id => 'redmine', :repository_id => 'foo', :rev => '123', :issue_id => '25' } |
|
407 | 407 | ) |
|
408 | 408 | end |
|
409 | 409 | end |
General Comments 0
You need to be logged in to leave comments.
Login now