##// END OF EJS Templates
Converted routing and urls to follow the Rails REST convention....
Eric Davis -
r2315:765f7abc6033
parent child
Show More
@@ -0,0 +1,22
1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'issue_relations_controller'
3
4 # Re-raise errors caught by the controller.
5 class IssueRelationsController; def rescue_action(e) raise e end; end
6
7
8 class IssueRelationsControllerTest < Test::Unit::TestCase
9 def test_new_routing
10 assert_routing(
11 {:method => :post, :path => '/issues/1/relations'},
12 {:controller => 'issue_relations', :action => 'new', :issue_id => '1'}
13 )
14 end
15
16 def test_destroy_routing
17 assert_recognizes( #TODO: use DELETE on issue URI
18 {:controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'},
19 {:method => :post, :path => '/issues/1/relations/23/destroy'}
20 )
21 end
22 end
@@ -0,0 +1,15
1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'members_controller'
3
4 # Re-raise errors caught by the controller.
5 class MembersController; def rescue_action(e) raise e end; end
6
7
8 class MembersControllerTest < Test::Unit::TestCase
9 def test_members_routing
10 assert_routing(
11 {:method => :post, :path => 'projects/5234/members/new'},
12 :controller => 'members', :action => 'new', :id => '5234'
13 )
14 end
15 end
@@ -0,0 +1,20
1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'reports_controller'
3
4 # Re-raise errors caught by the controller.
5 class ReportsController; def rescue_action(e) raise e end; end
6
7
8 class ReportsControllerTest < Test::Unit::TestCase
9 def test_issue_report_routing
10 assert_routing(
11 {:method => :get, :path => '/projects/567/issues/report'},
12 :controller => 'reports', :action => 'issue_report', :id => '567'
13 )
14 assert_routing(
15 {:method => :get, :path => '/projects/567/issues/report/assigned_to'},
16 :controller => 'reports', :action => 'issue_report', :id => '567', :detail => 'assigned_to'
17 )
18
19 end
20 end
@@ -243,39 +243,36 module ApplicationHelper
243 url_param.clear if url_param.has_key?(:set_filter)
243 url_param.clear if url_param.has_key?(:set_filter)
244
244
245 html = ''
245 html = ''
246 html << link_to_remote(('&#171; ' + l(:label_previous)),
246 if paginator.current.previous
247 {:update => 'content',
247 html << link_to_remote_content_update('&#171; ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' '
248 :url => url_param.merge(page_param => paginator.current.previous),
248 end
249 :complete => 'window.scrollTo(0,0)'},
250 {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
251
249
252 html << (pagination_links_each(paginator, options) do |n|
250 html << (pagination_links_each(paginator, options) do |n|
253 link_to_remote(n.to_s,
251 link_to_remote_content_update(n.to_s, url_param.merge(page_param => n))
254 {:url => {:params => url_param.merge(page_param => n)},
255 :update => 'content',
256 :complete => 'window.scrollTo(0,0)'},
257 {:href => url_for(:params => url_param.merge(page_param => n))})
258 end || '')
252 end || '')
259
253
260 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
254 if paginator.current.next
261 {:update => 'content',
255 html << ' ' + link_to_remote_content_update((l(:label_next) + ' &#187;'), url_param.merge(page_param => paginator.current.next))
262 :url => url_param.merge(page_param => paginator.current.next),
256 end
263 :complete => 'window.scrollTo(0,0)'},
264 {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next
265
257
266 unless count.nil?
258 unless count.nil?
267 html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ')
259 html << [
260 " (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})",
261 per_page_links(paginator.items_per_page)
262 ].compact.join(' | ')
268 end
263 end
269
264
270 html
265 html
271 end
266 end
272
267
273 def per_page_links(selected=nil)
268 def per_page_links(selected=nil)
274 url_param = params.dup
269 url_param = params.dup
275 url_param.clear if url_param.has_key?(:set_filter)
270 url_param.clear if url_param.has_key?(:set_filter)
276
271
277 links = Setting.per_page_options_array.collect do |n|
272 links = Setting.per_page_options_array.collect do |n|
278 n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)},
273 n == selected ? n : link_to_remote(n, {:update => "content",
274 :url => params.dup.merge(:per_page => n),
275 :method => :get},
279 {:href => url_for(url_param.merge(:per_page => n))})
276 {:href => url_for(url_param.merge(:per_page => n))})
280 end
277 end
281 links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
278 links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
@@ -664,4 +661,12 module ApplicationHelper
664 extend helper
661 extend helper
665 return self
662 return self
666 end
663 end
664
665 def link_to_remote_content_update(text, url_params)
666 link_to_remote(text,
667 {:url => url_params, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'},
668 {:href => url_for(:params => url_params)}
669 )
670 end
671
667 end
672 end
@@ -121,7 +121,7 module SortHelper
121 url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
121 url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
122
122
123 link_to_remote(caption,
123 link_to_remote(caption,
124 {:update => "content", :url => url_options},
124 {:update => "content", :url => url_options, :method => :get},
125 {:href => url_for(url_options)}) +
125 {:href => url_for(url_options)}) +
126 (icon ? nbsp(2) + image_tag(icon) : '')
126 (icon ? nbsp(2) + image_tag(icon) : '')
127 end
127 end
@@ -26,7 +26,7
26 <% end %>
26 <% end %>
27
27
28 <% content_for :sidebar do %>
28 <% content_for :sidebar do %>
29 <% form_tag do %>
29 <% form_tag({},:method => :get) do %>
30 <h3><%= l(:label_change_log) %></h3>
30 <h3><%= l(:label_change_log) %></h3>
31 <% @trackers.each do |tracker| %>
31 <% @trackers.each do |tracker| %>
32 <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
32 <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
@@ -6,7 +6,9
6
6
7 <h2><%= l(:label_spent_time) %></h2>
7 <h2><%= l(:label_spent_time) %></h2>
8
8
9 <% form_remote_tag( :url => {}, :method => :get, :update => 'content' ) do %>
9 <% form_remote_tag( :url => {}, :html => {:method => :get}, :method => :get, :update => 'content' ) do %>
10 <%# TOOD: remove the project_id and issue_id hidden fields, that information is
11 already in the URI %>
10 <%= hidden_field_tag 'project_id', params[:project_id] %>
12 <%= hidden_field_tag 'project_id', params[:project_id] %>
11 <%= hidden_field_tag 'issue_id', params[:issue_id] if @issue %>
13 <%= hidden_field_tag 'issue_id', params[:issue_id] if @issue %>
12 <%= render :partial => 'date_range' %>
14 <%= render :partial => 'date_range' %>
@@ -6,10 +6,11
6
6
7 <h2><%= l(:label_spent_time) %></h2>
7 <h2><%= l(:label_spent_time) %></h2>
8
8
9 <% form_remote_tag(:url => {}, :update => 'content') do %>
9 <% form_remote_tag(:url => {}, :html => {:method => :get}, :method => :get, :update => 'content') do %>
10 <% @criterias.each do |criteria| %>
10 <% @criterias.each do |criteria| %>
11 <%= hidden_field_tag 'criterias[]', criteria, :id => nil %>
11 <%= hidden_field_tag 'criterias[]', criteria, :id => nil %>
12 <% end %>
12 <% end %>
13 <%# TODO: get rid of the project_id field, that should already be in the URL %>
13 <%= hidden_field_tag 'project_id', params[:project_id] %>
14 <%= hidden_field_tag 'project_id', params[:project_id] %>
14 <%= render :partial => 'date_range' %>
15 <%= render :partial => 'date_range' %>
15
16
@@ -25,6 +26,7
25 :id => nil,
26 :id => nil,
26 :disabled => (@criterias.length >= 3)) %>
27 :disabled => (@criterias.length >= 3)) %>
27 <%= link_to_remote l(:button_clear), {:url => {:project_id => @project, :period_type => params[:period_type], :period => params[:period], :from => @from, :to => @to, :columns => @columns},
28 <%= link_to_remote l(:button_clear), {:url => {:project_id => @project, :period_type => params[:period_type], :period => params[:period], :from => @from, :to => @to, :columns => @columns},
29 :method => :get,
28 :update => 'content'
30 :update => 'content'
29 }, :class => 'icon icon-reload' %></p>
31 }, :class => 'icon icon-reload' %></p>
30 <% end %>
32 <% end %>
@@ -1,4 +1,4
1 <% labelled_tabular_form_for :user, @user, :url => { :action => "edit" } do |f| %>
1 <% labelled_tabular_form_for :user, @user, :url => { :action => "edit", :tab => nil } do |f| %>
2 <%= render :partial => 'form', :locals => { :f => f } %>
2 <%= render :partial => 'form', :locals => { :f => f } %>
3 <%= submit_tag l(:button_save) %>
3 <%= submit_tag l(:button_save) %>
4 <% end %>
4 <% end %>
@@ -12,39 +12,241 ActionController::Routing::Routes.draw do |map|
12 end
12 end
13
13
14 map.home '', :controller => 'welcome'
14 map.home '', :controller => 'welcome'
15
15 map.signin 'login', :controller => 'account', :action => 'login'
16 map.signin 'login', :controller => 'account', :action => 'login'
16 map.signout 'logout', :controller => 'account', :action => 'logout'
17 map.signout 'logout', :controller => 'account', :action => 'logout'
17
18
18 map.connect 'wiki/:id/:page/:action', :controller => 'wiki', :page => nil
19 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
19 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
20 map.connect 'help/:ctrl/:page', :controller => 'help'
20 map.connect 'help/:ctrl/:page', :controller => 'help'
21 #map.connect ':controller/:action/:id/:sort_key/:sort_order'
22
21
23 map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
22 map.connect 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog'
23 map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog'
24 map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog'
25
26 map.with_options :controller => 'timelog' do |timelog|
27 timelog.connect 'projects/:project_id/time_entries', :action => 'details'
28
29 timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details|
30 time_details.connect 'time_entries'
31 time_details.connect 'time_entries.:format'
32 time_details.connect 'issues/:issue_id/time_entries'
33 time_details.connect 'issues/:issue_id/time_entries.:format'
34 time_details.connect 'projects/:project_id/time_entries.:format'
35 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries'
36 time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format'
37 end
38 timelog.connect 'projects/:project_id/time_entries/report', :action => 'report'
39 timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report|
40 time_report.connect 'time_entries/report'
41 time_report.connect 'time_entries/report.:format'
42 time_report.connect 'projects/:project_id/time_entries/report.:format'
43 end
44
45 timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit|
46 time_edit.connect 'issues/:issue_id/time_entries/new'
47 end
48
49 timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
50 end
51
52 map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
53 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
54 map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
55 map.with_options :controller => 'wiki' do |wiki_routes|
56 wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
57 wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i
58 wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
59 wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
60 wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
61 wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
62 wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
63 wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
64 end
65
66 wiki_routes.connect 'projects/:id/wiki/:page/:action',
67 :action => /edit|rename|destroy|preview|protect/,
68 :conditions => {:method => :post}
69 end
70
71 map.with_options :controller => 'messages' do |messages_routes|
72 messages_routes.with_options :conditions => {:method => :get} do |messages_views|
73 messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
74 messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
75 messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
76 end
77 messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
78 messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
79 messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
80 messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
81 end
82 end
83
84 map.with_options :controller => 'boards' do |board_routes|
85 board_routes.with_options :conditions => {:method => :get} do |board_views|
86 board_views.connect 'projects/:project_id/boards', :action => 'index'
87 board_views.connect 'projects/:project_id/boards/new', :action => 'new'
88 board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
89 board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
90 end
91 board_routes.with_options :conditions => {:method => :post} do |board_actions|
92 board_actions.connect 'projects/:project_id/boards', :action => 'new'
93 board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
94 end
95 end
96
97 map.with_options :controller => 'documents' do |document_routes|
98 document_routes.with_options :conditions => {:method => :get} do |document_views|
99 document_views.connect 'projects/:project_id/documents', :action => 'index'
100 document_views.connect 'projects/:project_id/documents/new', :action => 'new'
101 document_views.connect 'documents/:id', :action => 'show'
102 document_views.connect 'documents/:id/edit', :action => 'edit'
103 end
104 document_routes.with_options :conditions => {:method => :post} do |document_actions|
105 document_actions.connect 'projects/:project_id/documents', :action => 'new'
106 document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
107 end
108 end
109
110 map.with_options :controller => 'issues' do |issues_routes|
111 issues_routes.with_options :conditions => {:method => :get} do |issues_views|
112 issues_views.connect 'issues', :action => 'index'
113 issues_views.connect 'issues.:format', :action => 'index'
114 issues_views.connect 'projects/:project_id/issues.:format', :action => 'index'
115 issues_views.connect 'projects/:project_id/issues/new', :action => 'new'
116 issues_views.connect 'projects/:project_id/issues/:copy_from/copy', :action => 'new'
117 issues_views.connect 'issues/:id', :action => 'show'
118 issues_views.connect 'issues/:id.:format', :action => 'show'
119 issues_views.connect 'issues/:id/edit', :action => 'edit'
120 issues_views.connect 'issues/:id/move', :action => 'move'
121 end
122 issues_routes.with_options :conditions => {:method => :post} do |issues_actions|
123 issues_actions.connect 'projects/:project_id/issues', :action => 'new'
124 issues_actions.connect 'issues/:id/quoted', :action => 'reply'
125 issues_actions.connect 'issues/:id/:action',
126 :action => /edit|move|destroy/
127 end
128 end
129
130 map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
131 relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
132 relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
133 end
134
135 map.with_options :controller => 'reports', :action => 'issue_report', :conditions => {:method => :get} do |reports|
136 reports.connect 'projects/:id/issues/report'
137 reports.connect 'projects/:id/issues/report/:detail'
138 end
139
140 map.with_options :controller => 'news' do |news_routes|
141 news_routes.with_options :conditions => {:method => :get} do |news_views|
142 news_views.connect 'news', :action => 'index'
143 news_views.connect 'projects/:project_id/news', :action => 'index'
144 news_views.connect 'projects/:project_id/news.:format', :action => 'index'
145 news_views.connect 'news.:format', :action => 'index'
146 news_views.connect 'projects/:project_id/news/new', :action => 'new'
147 news_views.connect 'news/:id', :action => 'show'
148 news_views.connect 'news/:id/edit', :action => 'edit'
149 end
150 news_routes.with_options do |news_actions|
151 news_actions.connect 'projects/:project_id/news', :action => 'new'
152 news_actions.connect 'news/:id/edit', :action => 'edit'
153 news_actions.connect 'news/:id/destroy', :action => 'destroy'
154 end
155 end
156
157 map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
158
159 map.with_options :controller => 'users' do |users|
160 users.with_options :conditions => {:method => :get} do |user_views|
161 user_views.connect 'users', :action => 'list'
162 user_views.connect 'users', :action => 'index'
163 user_views.connect 'users/new', :action => 'add'
164 user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil
165 end
166 users.with_options :conditions => {:method => :post} do |user_actions|
167 user_actions.connect 'users', :action => 'add'
168 user_actions.connect 'users/new', :action => 'add'
169 user_actions.connect 'users/:id/edit', :action => 'edit'
170 user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
171 user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
172 user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
173 end
174 end
175
176 map.with_options :controller => 'projects' do |projects|
177 projects.with_options :conditions => {:method => :get} do |project_views|
178 project_views.connect 'projects', :action => 'index'
179 project_views.connect 'projects.:format', :action => 'index'
180 project_views.connect 'projects/new', :action => 'add'
181 project_views.connect 'projects/:id', :action => 'show'
182 project_views.connect 'projects/:id/:action', :action => /roadmap|changelog|destroy|settings/
183 project_views.connect 'projects/:id/files', :action => 'list_files'
184 project_views.connect 'projects/:id/files/new', :action => 'add_file'
185 project_views.connect 'projects/:id/versions/new', :action => 'add_version'
186 project_views.connect 'projects/:id/categories/new', :action => 'add_issue_category'
187 project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
188 end
189
190 projects.with_options :action => 'activity', :conditions => {:method => :get} do |activity|
191 activity.connect 'projects/:id/activity'
192 activity.connect 'projects/:id/activity.:format'
193 activity.connect 'activity'
194 activity.connect 'activity.:format'
195 end
196
197 projects.with_options :conditions => {:method => :post} do |project_actions|
198 project_actions.connect 'projects/new', :action => 'add'
199 project_actions.connect 'projects', :action => 'add'
200 project_actions.connect 'projects/:id/:action', :action => /destroy|archive|unarchive/
201 project_actions.connect 'projects/:id/files/new', :action => 'add_file'
202 project_actions.connect 'projects/:id/versions/new', :action => 'add_version'
203 project_actions.connect 'projects/:id/categories/new', :action => 'add_issue_category'
204 end
205 end
206
207 map.with_options :controller => 'repositories' do |repositories|
208 repositories.with_options :conditions => {:method => :get} do |repository_views|
209 repositories.connect 'projects/:id/repository', :action => 'show'
210 repositories.connect 'projects/:id/repository/edit', :action => 'edit'
211 repositories.connect 'projects/:id/repository/statistics', :action => 'stats'
212 repositories.connect 'projects/:id/repository/revisions', :action => 'revisions'
213 repositories.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
214 repositories.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
215 repositories.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
216 repositories.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
217 repositories.connect 'projects/:id/repository/revisions/:rev/:action/*path'
218 repositories.connect 'projects/:id/repository/:action/*path'
219 end
220
221 repositories.connect 'projects/:id/repository/edit', :action => 'edit', :conditions => {:method => :post}
222 end
223
224 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
225 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
226 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
227
228
229 #left old routes at the bottom for backwards compat
24 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
230 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
25 map.connect 'projects/:project_id/news/:action', :controller => 'news'
26 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
231 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
27 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
232 map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
28 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
29 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
233 map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
30
234 map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
235 map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
236 map.connect 'projects/:project_id/news/:action', :controller => 'news'
237 map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
31 map.with_options :controller => 'repositories' do |omap|
238 map.with_options :controller => 'repositories' do |omap|
32 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
239 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
33 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
240 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
34 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
241 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
35 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
242 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
36 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
243 omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
37 omap.repositories_revision 'repositories/revision/:id/:rev', :action => 'revision'
244 omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
38 end
245 end
39
40 map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
41 map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
42 map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
43
246
44 # Allow downloading Web Service WSDL as a file with an extension
247 # Allow downloading Web Service WSDL as a file with an extension
45 # instead of a file named 'wsdl'
248 # instead of a file named 'wsdl'
46 map.connect ':controller/service.wsdl', :action => 'wsdl'
249 map.connect ':controller/service.wsdl', :action => 'wsdl'
47
48
250
49 # Install the default route as the lowest priority.
251 # Install the default route as the lowest priority.
50 map.connect ':controller/:action/:id'
252 map.connect ':controller/:action/:id'
@@ -38,6 +38,13 class AdminControllerTest < Test::Unit::TestCase
38 :attributes => { :class => /nodata/ }
38 :attributes => { :class => /nodata/ }
39 end
39 end
40
40
41 def test_projects_routing
42 assert_routing(
43 {:method => :get, :path => '/admin/projects'},
44 :controller => 'admin', :action => 'projects'
45 )
46 end
47
41 def test_index_with_no_configuration_data
48 def test_index_with_no_configuration_data
42 delete_configuration_data
49 delete_configuration_data
43 get :index
50 get :index
@@ -31,6 +31,13 class BoardsControllerTest < Test::Unit::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_index_routing
35 assert_routing(
36 {:method => :get, :path => '/projects/world_domination/boards'},
37 :controller => 'boards', :action => 'index', :project_id => 'world_domination'
38 )
39 end
40
34 def test_index
41 def test_index
35 get :index, :project_id => 1
42 get :index, :project_id => 1
36 assert_response :success
43 assert_response :success
@@ -39,6 +46,24 class BoardsControllerTest < Test::Unit::TestCase
39 assert_not_nil assigns(:project)
46 assert_not_nil assigns(:project)
40 end
47 end
41
48
49 def test_new_routing
50 assert_routing(
51 {:method => :get, :path => '/projects/world_domination/boards/new'},
52 :controller => 'boards', :action => 'new', :project_id => 'world_domination'
53 )
54 assert_recognizes(
55 {:controller => 'boards', :action => 'new', :project_id => 'world_domination'},
56 {:method => :post, :path => '/projects/world_domination/boards'}
57 )
58 end
59
60 def test_show_routing
61 assert_routing(
62 {:method => :get, :path => '/projects/world_domination/boards/44'},
63 :controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination'
64 )
65 end
66
42 def test_show
67 def test_show
43 get :show, :project_id => 1, :id => 1
68 get :show, :project_id => 1, :id => 1
44 assert_response :success
69 assert_response :success
@@ -47,4 +72,22 class BoardsControllerTest < Test::Unit::TestCase
47 assert_not_nil assigns(:project)
72 assert_not_nil assigns(:project)
48 assert_not_nil assigns(:topics)
73 assert_not_nil assigns(:topics)
49 end
74 end
75
76 def test_edit_routing
77 assert_routing(
78 {:method => :get, :path => '/projects/world_domination/boards/44/edit'},
79 :controller => 'boards', :action => 'edit', :id => '44', :project_id => 'world_domination'
80 )
81 assert_recognizes(#TODO: use PUT method to board_path, modify form accordingly
82 {:controller => 'boards', :action => 'edit', :id => '44', :project_id => 'world_domination'},
83 {:method => :post, :path => '/projects/world_domination/boards/44/edit'}
84 )
85 end
86
87 def test_destroy_routing
88 assert_routing(#TODO: use DELETE method to board_path, modify form accoringly
89 {:method => :post, :path => '/projects/world_domination/boards/44/destroy'},
90 :controller => 'boards', :action => 'destroy', :id => '44', :project_id => 'world_domination'
91 )
92 end
50 end
93 end
@@ -30,7 +30,14 class DocumentsControllerTest < Test::Unit::TestCase
30 @response = ActionController::TestResponse.new
30 @response = ActionController::TestResponse.new
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_index_routing
35 assert_routing(
36 {:method => :get, :path => '/projects/567/documents'},
37 :controller => 'documents', :action => 'index', :project_id => '567'
38 )
39 end
40
34 def test_index
41 def test_index
35 # Sets a default category
42 # Sets a default category
36 e = Enumeration.find_by_name('Technical documentation')
43 e = Enumeration.find_by_name('Technical documentation')
@@ -47,6 +54,17 class DocumentsControllerTest < Test::Unit::TestCase
47 :content => 'Technical documentation'}
54 :content => 'Technical documentation'}
48 end
55 end
49
56
57 def test_new_routing
58 assert_routing(
59 {:method => :get, :path => '/projects/567/documents/new'},
60 :controller => 'documents', :action => 'new', :project_id => '567'
61 )
62 assert_recognizes(
63 {:controller => 'documents', :action => 'new', :project_id => '567'},
64 {:method => :post, :path => '/projects/567/documents'}
65 )
66 end
67
50 def test_new_with_one_attachment
68 def test_new_with_one_attachment
51 @request.session[:user_id] = 2
69 @request.session[:user_id] = 2
52 set_tmp_attachments_directory
70 set_tmp_attachments_directory
@@ -66,6 +84,31 class DocumentsControllerTest < Test::Unit::TestCase
66 assert_equal 'testfile.txt', document.attachments.first.filename
84 assert_equal 'testfile.txt', document.attachments.first.filename
67 end
85 end
68
86
87 def test_edit_routing
88 assert_routing(
89 {:method => :get, :path => '/documents/22/edit'},
90 :controller => 'documents', :action => 'edit', :id => '22'
91 )
92 assert_recognizes(#TODO: should be using PUT on document URI
93 {:controller => 'documents', :action => 'edit', :id => '567'},
94 {:method => :post, :path => '/documents/567/edit'}
95 )
96 end
97
98 def test_show_routing
99 assert_routing(
100 {:method => :get, :path => '/documents/22'},
101 :controller => 'documents', :action => 'show', :id => '22'
102 )
103 end
104
105 def test_destroy_routing
106 assert_recognizes(#TODO: should be using DELETE on document URI
107 {:controller => 'documents', :action => 'destroy', :id => '567'},
108 {:method => :post, :path => '/documents/567/destroy'}
109 )
110 end
111
69 def test_destroy
112 def test_destroy
70 @request.session[:user_id] = 2
113 @request.session[:user_id] = 2
71 post :destroy, :id => 1
114 post :destroy, :id => 1
@@ -49,6 +49,13 class IssuesControllerTest < Test::Unit::TestCase
49 @response = ActionController::TestResponse.new
49 @response = ActionController::TestResponse.new
50 User.current = nil
50 User.current = nil
51 end
51 end
52
53 def test_index_routing
54 assert_routing(
55 {:method => :get, :path => '/issues'},
56 :controller => 'issues', :action => 'index'
57 )
58 end
52
59
53 def test_index
60 def test_index
54 get :index
61 get :index
@@ -74,6 +81,31 class IssuesControllerTest < Test::Unit::TestCase
74 assert_tag :tag => 'a', :content => /Subproject issue/
81 assert_tag :tag => 'a', :content => /Subproject issue/
75 end
82 end
76
83
84 def test_index_with_project_routing
85 assert_routing(
86 {:method => :get, :path => '/projects/23/issues'},
87 :controller => 'issues', :action => 'index', :project_id => '23'
88 )
89 end
90
91 def test_index_should_not_list_issues_when_module_disabled
92 EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
93 get :index
94 assert_response :success
95 assert_template 'index.rhtml'
96 assert_not_nil assigns(:issues)
97 assert_nil assigns(:project)
98 assert_no_tag :tag => 'a', :content => /Can't print recipes/
99 assert_tag :tag => 'a', :content => /Subproject issue/
100 end
101
102 def test_index_with_project_routing
103 assert_routing(
104 {:method => :get, :path => 'projects/23/issues'},
105 :controller => 'issues', :action => 'index', :project_id => '23'
106 )
107 end
108
77 def test_index_with_project
109 def test_index_with_project
78 Setting.display_subprojects_issues = 0
110 Setting.display_subprojects_issues = 0
79 get :index, :project_id => 1
111 get :index, :project_id => 1
@@ -107,6 +139,17 class IssuesControllerTest < Test::Unit::TestCase
107 assert_tag :tag => 'a', :content => /Issue of a private subproject/
139 assert_tag :tag => 'a', :content => /Issue of a private subproject/
108 end
140 end
109
141
142 def test_index_with_project_routing_formatted
143 assert_routing(
144 {:method => :get, :path => 'projects/23/issues.pdf'},
145 :controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf'
146 )
147 assert_routing(
148 {:method => :get, :path => 'projects/23/issues.atom'},
149 :controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom'
150 )
151 end
152
110 def test_index_with_project_and_filter
153 def test_index_with_project_and_filter
111 get :index, :project_id => 1, :set_filter => 1
154 get :index, :project_id => 1, :set_filter => 1
112 assert_response :success
155 assert_response :success
@@ -126,6 +169,17 class IssuesControllerTest < Test::Unit::TestCase
126 assert_equal 'text/csv', @response.content_type
169 assert_equal 'text/csv', @response.content_type
127 end
170 end
128
171
172 def test_index_formatted
173 assert_routing(
174 {:method => :get, :path => 'issues.pdf'},
175 :controller => 'issues', :action => 'index', :format => 'pdf'
176 )
177 assert_routing(
178 {:method => :get, :path => 'issues.atom'},
179 :controller => 'issues', :action => 'index', :format => 'atom'
180 )
181 end
182
129 def test_index_pdf
183 def test_index_pdf
130 get :index, :format => 'pdf'
184 get :index, :format => 'pdf'
131 assert_response :success
185 assert_response :success
@@ -221,6 +275,24 class IssuesControllerTest < Test::Unit::TestCase
221 assert_equal 'application/atom+xml', @response.content_type
275 assert_equal 'application/atom+xml', @response.content_type
222 end
276 end
223
277
278 def test_show_routing
279 assert_routing(
280 {:method => :get, :path => '/issues/64'},
281 :controller => 'issues', :action => 'show', :id => '64'
282 )
283 end
284
285 def test_show_routing_formatted
286 assert_routing(
287 {:method => :get, :path => '/issues/2332.pdf'},
288 :controller => 'issues', :action => 'show', :id => '2332', :format => 'pdf'
289 )
290 assert_routing(
291 {:method => :get, :path => '/issues/23123.atom'},
292 :controller => 'issues', :action => 'show', :id => '23123', :format => 'atom'
293 )
294 end
295
224 def test_show_by_anonymous
296 def test_show_by_anonymous
225 get :show, :id => 1
297 get :show, :id => 1
226 assert_response :success
298 assert_response :success
@@ -251,6 +323,17 class IssuesControllerTest < Test::Unit::TestCase
251 :child => { :tag => 'legend',
323 :child => { :tag => 'legend',
252 :content => /Notes/ } }
324 :content => /Notes/ } }
253 end
325 end
326
327 def test_new_routing
328 assert_routing(
329 {:method => :get, :path => '/projects/1/issues/new'},
330 :controller => 'issues', :action => 'new', :project_id => '1'
331 )
332 assert_recognizes(
333 {:controller => 'issues', :action => 'new', :project_id => '1'},
334 {:method => :post, :path => '/projects/1/issues'}
335 )
336 end
254
337
255 def test_show_export_to_pdf
338 def test_show_export_to_pdf
256 get :show, :id => 3, :format => 'pdf'
339 get :show, :id => 3, :format => 'pdf'
@@ -290,7 +373,7 class IssuesControllerTest < Test::Unit::TestCase
290 :priority_id => 5}
373 :priority_id => 5}
291 assert_response :success
374 assert_response :success
292 assert_template 'new'
375 assert_template 'new'
293 end
376 end
294
377
295 def test_post_new
378 def test_post_new
296 @request.session[:user_id] = 2
379 @request.session[:user_id] = 2
@@ -301,7 +384,7 class IssuesControllerTest < Test::Unit::TestCase
301 :priority_id => 5,
384 :priority_id => 5,
302 :estimated_hours => '',
385 :estimated_hours => '',
303 :custom_field_values => {'2' => 'Value for field 2'}}
386 :custom_field_values => {'2' => 'Value for field 2'}}
304 assert_redirected_to :controller => 'issues', :action => 'show'
387 assert_redirected_to :action => 'show'
305
388
306 issue = Issue.find_by_subject('This is the test_new issue')
389 issue = Issue.find_by_subject('This is the test_new issue')
307 assert_not_nil issue
390 assert_not_nil issue
@@ -330,9 +413,9 class IssuesControllerTest < Test::Unit::TestCase
330 :subject => 'This is the test_new issue',
413 :subject => 'This is the test_new issue',
331 :description => 'This is the description',
414 :description => 'This is the description',
332 :priority_id => 5}
415 :priority_id => 5}
333 assert_redirected_to :controller => 'issues', :action => 'show'
416 assert_redirected_to :action => 'show'
334 end
417 end
335
418
336 def test_post_new_with_required_custom_field_and_without_custom_fields_param
419 def test_post_new_with_required_custom_field_and_without_custom_fields_param
337 field = IssueCustomField.find_by_name('Database')
420 field = IssueCustomField.find_by_name('Database')
338 field.update_attribute(:is_required, true)
421 field.update_attribute(:is_required, true)
@@ -402,6 +485,13 class IssuesControllerTest < Test::Unit::TestCase
402 :value => 'Value for field 2'}
485 :value => 'Value for field 2'}
403 end
486 end
404
487
488 def test_copy_routing
489 assert_routing(
490 {:method => :get, :path => '/projects/world_domination/issues/567/copy'},
491 :controller => 'issues', :action => 'new', :project_id => 'world_domination', :copy_from => '567'
492 )
493 end
494
405 def test_copy_issue
495 def test_copy_issue
406 @request.session[:user_id] = 2
496 @request.session[:user_id] = 2
407 get :new, :project_id => 1, :copy_from => 1
497 get :new, :project_id => 1, :copy_from => 1
@@ -411,6 +501,17 class IssuesControllerTest < Test::Unit::TestCase
411 assert_equal orig.subject, assigns(:issue).subject
501 assert_equal orig.subject, assigns(:issue).subject
412 end
502 end
413
503
504 def test_edit_routing
505 assert_routing(
506 {:method => :get, :path => '/issues/1/edit'},
507 :controller => 'issues', :action => 'edit', :id => '1'
508 )
509 assert_recognizes( #TODO: use a PUT on the issue URI isntead, need to adjust form
510 {:controller => 'issues', :action => 'edit', :id => '1'},
511 {:method => :post, :path => '/issues/1/edit'}
512 )
513 end
514
414 def test_get_edit
515 def test_get_edit
415 @request.session[:user_id] = 2
516 @request.session[:user_id] = 2
416 get :edit, :id => 1
517 get :edit, :id => 1
@@ -442,6 +543,13 class IssuesControllerTest < Test::Unit::TestCase
442 :attributes => { :selected => 'selected' } }
543 :attributes => { :selected => 'selected' } }
443 end
544 end
444
545
546 def test_reply_routing
547 assert_routing(
548 {:method => :post, :path => '/issues/1/quoted'},
549 :controller => 'issues', :action => 'reply', :id => '1'
550 )
551 end
552
445 def test_reply_to_issue
553 def test_reply_to_issue
446 @request.session[:user_id] = 2
554 @request.session[:user_id] = 2
447 get :reply, :id => 1
555 get :reply, :id => 1
@@ -473,7 +581,7 class IssuesControllerTest < Test::Unit::TestCase
473 }
581 }
474 end
582 end
475 end
583 end
476 assert_redirected_to 'issues/show/1'
584 assert_redirected_to :action => 'show', :id => '1'
477 issue.reload
585 issue.reload
478 assert_equal new_subject, issue.subject
586 assert_equal new_subject, issue.subject
479 # Make sure custom fields were not cleared
587 # Make sure custom fields were not cleared
@@ -499,7 +607,7 class IssuesControllerTest < Test::Unit::TestCase
499 }
607 }
500 end
608 end
501 end
609 end
502 assert_redirected_to 'issues/show/1'
610 assert_redirected_to :action => 'show', :id => '1'
503 issue.reload
611 issue.reload
504 assert_equal 'New custom value', issue.custom_value_for(2).value
612 assert_equal 'New custom value', issue.custom_value_for(2).value
505
613
@@ -519,7 +627,7 class IssuesControllerTest < Test::Unit::TestCase
519 :notes => 'Assigned to dlopper',
627 :notes => 'Assigned to dlopper',
520 :time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
628 :time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
521 end
629 end
522 assert_redirected_to 'issues/show/1'
630 assert_redirected_to :action => 'show', :id => '1'
523 issue.reload
631 issue.reload
524 assert_equal 2, issue.status_id
632 assert_equal 2, issue.status_id
525 j = issue.journals.find(:first, :order => 'id DESC')
633 j = issue.journals.find(:first, :order => 'id DESC')
@@ -536,7 +644,7 class IssuesControllerTest < Test::Unit::TestCase
536 post :edit,
644 post :edit,
537 :id => 1,
645 :id => 1,
538 :notes => notes
646 :notes => notes
539 assert_redirected_to 'issues/show/1'
647 assert_redirected_to :action => 'show', :id => '1'
540 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
648 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
541 assert_equal notes, j.notes
649 assert_equal notes, j.notes
542 assert_equal 0, j.details.size
650 assert_equal 0, j.details.size
@@ -555,7 +663,7 class IssuesControllerTest < Test::Unit::TestCase
555 :notes => '2.5 hours added',
663 :notes => '2.5 hours added',
556 :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
664 :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
557 end
665 end
558 assert_redirected_to 'issues/show/1'
666 assert_redirected_to :action => 'show', :id => '1'
559
667
560 issue = Issue.find(1)
668 issue = Issue.find(1)
561
669
@@ -581,7 +689,7 class IssuesControllerTest < Test::Unit::TestCase
581 :id => 1,
689 :id => 1,
582 :notes => '',
690 :notes => '',
583 :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
691 :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
584 assert_redirected_to 'issues/show/1'
692 assert_redirected_to :action => 'show', :id => '1'
585 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
693 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
586 assert j.notes.blank?
694 assert j.notes.blank?
587 assert_equal 1, j.details.size
695 assert_equal 1, j.details.size
@@ -600,7 +708,7 class IssuesControllerTest < Test::Unit::TestCase
600 post :edit,
708 post :edit,
601 :id => 1,
709 :id => 1,
602 :notes => ''
710 :notes => ''
603 assert_redirected_to 'issues/show/1'
711 assert_redirected_to :action => 'show', :id => '1'
604
712
605 issue.reload
713 issue.reload
606 assert issue.journals.empty?
714 assert issue.journals.empty?
@@ -671,17 +779,28 class IssuesControllerTest < Test::Unit::TestCase
671 assert_nil Issue.find(2).assigned_to
779 assert_nil Issue.find(2).assigned_to
672 end
780 end
673
781
782 def test_move_routing
783 assert_routing(
784 {:method => :get, :path => '/issues/1/move'},
785 :controller => 'issues', :action => 'move', :id => '1'
786 )
787 assert_recognizes(
788 {:controller => 'issues', :action => 'move', :id => '1'},
789 {:method => :post, :path => '/issues/1/move'}
790 )
791 end
792
674 def test_move_one_issue_to_another_project
793 def test_move_one_issue_to_another_project
675 @request.session[:user_id] = 1
794 @request.session[:user_id] = 1
676 post :move, :id => 1, :new_project_id => 2
795 post :move, :id => 1, :new_project_id => 2
677 assert_redirected_to 'projects/ecookbook/issues'
796 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
678 assert_equal 2, Issue.find(1).project_id
797 assert_equal 2, Issue.find(1).project_id
679 end
798 end
680
799
681 def test_bulk_move_to_another_project
800 def test_bulk_move_to_another_project
682 @request.session[:user_id] = 1
801 @request.session[:user_id] = 1
683 post :move, :ids => [1, 2], :new_project_id => 2
802 post :move, :ids => [1, 2], :new_project_id => 2
684 assert_redirected_to 'projects/ecookbook/issues'
803 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
685 # Issues moved to project 2
804 # Issues moved to project 2
686 assert_equal 2, Issue.find(1).project_id
805 assert_equal 2, Issue.find(1).project_id
687 assert_equal 2, Issue.find(2).project_id
806 assert_equal 2, Issue.find(2).project_id
@@ -693,7 +812,7 class IssuesControllerTest < Test::Unit::TestCase
693 def test_bulk_move_to_another_tracker
812 def test_bulk_move_to_another_tracker
694 @request.session[:user_id] = 1
813 @request.session[:user_id] = 1
695 post :move, :ids => [1, 2], :new_tracker_id => 2
814 post :move, :ids => [1, 2], :new_tracker_id => 2
696 assert_redirected_to 'projects/ecookbook/issues'
815 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
697 assert_equal 2, Issue.find(1).tracker_id
816 assert_equal 2, Issue.find(1).tracker_id
698 assert_equal 2, Issue.find(2).tracker_id
817 assert_equal 2, Issue.find(2).tracker_id
699 end
818 end
@@ -714,10 +833,10 class IssuesControllerTest < Test::Unit::TestCase
714 assert_response :success
833 assert_response :success
715 assert_template 'context_menu'
834 assert_template 'context_menu'
716 assert_tag :tag => 'a', :content => 'Edit',
835 assert_tag :tag => 'a', :content => 'Edit',
717 :attributes => { :href => '/issues/edit/1',
836 :attributes => { :href => '/issues/1/edit',
718 :class => 'icon-edit' }
837 :class => 'icon-edit' }
719 assert_tag :tag => 'a', :content => 'Closed',
838 assert_tag :tag => 'a', :content => 'Closed',
720 :attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5',
839 :attributes => { :href => '/issues/1/edit?issue%5Bstatus_id%5D=5',
721 :class => '' }
840 :class => '' }
722 assert_tag :tag => 'a', :content => 'Immediate',
841 assert_tag :tag => 'a', :content => 'Immediate',
723 :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;priority_id=8',
842 :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;priority_id=8',
@@ -726,7 +845,7 class IssuesControllerTest < Test::Unit::TestCase
726 :attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&amp;ids%5B%5D=1',
845 :attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&amp;ids%5B%5D=1',
727 :class => '' }
846 :class => '' }
728 assert_tag :tag => 'a', :content => 'Copy',
847 assert_tag :tag => 'a', :content => 'Copy',
729 :attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1',
848 :attributes => { :href => '/projects/ecookbook/issues/1/copy',
730 :class => 'icon-copy' }
849 :class => 'icon-copy' }
731 assert_tag :tag => 'a', :content => 'Move',
850 assert_tag :tag => 'a', :content => 'Move',
732 :attributes => { :href => '/issues/move?ids%5B%5D=1',
851 :attributes => { :href => '/issues/move?ids%5B%5D=1',
@@ -777,11 +896,18 class IssuesControllerTest < Test::Unit::TestCase
777 :class => 'icon-del disabled' }
896 :class => 'icon-del disabled' }
778 end
897 end
779
898
899 def test_destroy_routing
900 assert_recognizes( #TODO: use DELETE on issue URI (need to change forms)
901 {:controller => 'issues', :action => 'destroy', :id => '1'},
902 {:method => :post, :path => '/issues/1/destroy'}
903 )
904 end
905
780 def test_destroy_issue_with_no_time_entries
906 def test_destroy_issue_with_no_time_entries
781 assert_nil TimeEntry.find_by_issue_id(2)
907 assert_nil TimeEntry.find_by_issue_id(2)
782 @request.session[:user_id] = 2
908 @request.session[:user_id] = 2
783 post :destroy, :id => 2
909 post :destroy, :id => 2
784 assert_redirected_to 'projects/ecookbook/issues'
910 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
785 assert_nil Issue.find_by_id(2)
911 assert_nil Issue.find_by_id(2)
786 end
912 end
787
913
@@ -797,7 +923,7 class IssuesControllerTest < Test::Unit::TestCase
797 def test_destroy_issues_and_destroy_time_entries
923 def test_destroy_issues_and_destroy_time_entries
798 @request.session[:user_id] = 2
924 @request.session[:user_id] = 2
799 post :destroy, :ids => [1, 3], :todo => 'destroy'
925 post :destroy, :ids => [1, 3], :todo => 'destroy'
800 assert_redirected_to 'projects/ecookbook/issues'
926 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
801 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
927 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
802 assert_nil TimeEntry.find_by_id([1, 2])
928 assert_nil TimeEntry.find_by_id([1, 2])
803 end
929 end
@@ -805,7 +931,7 class IssuesControllerTest < Test::Unit::TestCase
805 def test_destroy_issues_and_assign_time_entries_to_project
931 def test_destroy_issues_and_assign_time_entries_to_project
806 @request.session[:user_id] = 2
932 @request.session[:user_id] = 2
807 post :destroy, :ids => [1, 3], :todo => 'nullify'
933 post :destroy, :ids => [1, 3], :todo => 'nullify'
808 assert_redirected_to 'projects/ecookbook/issues'
934 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
809 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
935 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
810 assert_nil TimeEntry.find(1).issue_id
936 assert_nil TimeEntry.find(1).issue_id
811 assert_nil TimeEntry.find(2).issue_id
937 assert_nil TimeEntry.find(2).issue_id
@@ -814,7 +940,7 class IssuesControllerTest < Test::Unit::TestCase
814 def test_destroy_issues_and_reassign_time_entries_to_another_issue
940 def test_destroy_issues_and_reassign_time_entries_to_another_issue
815 @request.session[:user_id] = 2
941 @request.session[:user_id] = 2
816 post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
942 post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
817 assert_redirected_to 'projects/ecookbook/issues'
943 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
818 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
944 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
819 assert_equal 2, TimeEntry.find(1).issue_id
945 assert_equal 2, TimeEntry.find(1).issue_id
820 assert_equal 2, TimeEntry.find(2).issue_id
946 assert_equal 2, TimeEntry.find(2).issue_id
@@ -31,6 +31,13 class MessagesControllerTest < Test::Unit::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_show_routing
35 assert_routing(
36 {:method => :get, :path => '/boards/22/topics/2'},
37 :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
38 )
39 end
40
34 def test_show
41 def test_show
35 get :show, :board_id => 1, :id => 1
42 get :show, :board_id => 1, :id => 1
36 assert_response :success
43 assert_response :success
@@ -54,6 +61,17 class MessagesControllerTest < Test::Unit::TestCase
54 assert_response 404
61 assert_response 404
55 end
62 end
56
63
64 def test_new_routing
65 assert_routing(
66 {:method => :get, :path => '/boards/lala/topics/new'},
67 :controller => 'messages', :action => 'new', :board_id => 'lala'
68 )
69 assert_recognizes(#TODO: POST to collection, need to adjust form accordingly
70 {:controller => 'messages', :action => 'new', :board_id => 'lala'},
71 {:method => :post, :path => '/boards/lala/topics/new'}
72 )
73 end
74
57 def test_get_new
75 def test_get_new
58 @request.session[:user_id] = 2
76 @request.session[:user_id] = 2
59 get :new, :board_id => 1
77 get :new, :board_id => 1
@@ -86,6 +104,17 class MessagesControllerTest < Test::Unit::TestCase
86 assert mail.bcc.include?('dlopper@somenet.foo')
104 assert mail.bcc.include?('dlopper@somenet.foo')
87 end
105 end
88
106
107 def test_edit_routing
108 assert_routing(
109 {:method => :get, :path => '/boards/lala/topics/22/edit'},
110 :controller => 'messages', :action => 'edit', :board_id => 'lala', :id => '22'
111 )
112 assert_recognizes( #TODO: use PUT to topic_path, modify form accordingly
113 {:controller => 'messages', :action => 'edit', :board_id => 'lala', :id => '22'},
114 {:method => :post, :path => '/boards/lala/topics/22/edit'}
115 )
116 end
117
89 def test_get_edit
118 def test_get_edit
90 @request.session[:user_id] = 2
119 @request.session[:user_id] = 2
91 get :edit, :board_id => 1, :id => 1
120 get :edit, :board_id => 1, :id => 1
@@ -104,6 +133,13 class MessagesControllerTest < Test::Unit::TestCase
104 assert_equal 'New body', message.content
133 assert_equal 'New body', message.content
105 end
134 end
106
135
136 def test_reply_routing
137 assert_recognizes(
138 {:controller => 'messages', :action => 'reply', :board_id => '22', :id => '555'},
139 {:method => :post, :path => '/boards/22/topics/555/replies'}
140 )
141 end
142
107 def test_reply
143 def test_reply
108 @request.session[:user_id] = 2
144 @request.session[:user_id] = 2
109 post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
145 post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
@@ -111,6 +147,13 class MessagesControllerTest < Test::Unit::TestCase
111 assert Message.find_by_subject('Test reply')
147 assert Message.find_by_subject('Test reply')
112 end
148 end
113
149
150 def test_destroy_routing
151 assert_recognizes(#TODO: use DELETE to topic_path, adjust form accordingly
152 {:controller => 'messages', :action => 'destroy', :board_id => '22', :id => '555'},
153 {:method => :post, :path => '/boards/22/topics/555/destroy'}
154 )
155 end
156
114 def test_destroy_topic
157 def test_destroy_topic
115 @request.session[:user_id] = 2
158 @request.session[:user_id] = 2
116 post :destroy, :board_id => 1, :id => 1
159 post :destroy, :board_id => 1, :id => 1
@@ -31,6 +31,20 class NewsControllerTest < Test::Unit::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_index_routing
35 assert_routing(
36 {:method => :get, :path => '/news'},
37 :controller => 'news', :action => 'index'
38 )
39 end
40
41 def test_index_routing_formatted
42 assert_routing(
43 {:method => :get, :path => '/news.atom'},
44 :controller => 'news', :action => 'index', :format => 'atom'
45 )
46 end
47
34 def test_index
48 def test_index
35 get :index
49 get :index
36 assert_response :success
50 assert_response :success
@@ -38,6 +52,20 class NewsControllerTest < Test::Unit::TestCase
38 assert_not_nil assigns(:newss)
52 assert_not_nil assigns(:newss)
39 assert_nil assigns(:project)
53 assert_nil assigns(:project)
40 end
54 end
55
56 def test_index_with_project_routing
57 assert_routing(
58 {:method => :get, :path => '/projects/567/news'},
59 :controller => 'news', :action => 'index', :project_id => '567'
60 )
61 end
62
63 def test_index_with_project_routing_formatted
64 assert_routing(
65 {:method => :get, :path => '/projects/567/news.atom'},
66 :controller => 'news', :action => 'index', :project_id => '567', :format => 'atom'
67 )
68 end
41
69
42 def test_index_with_project
70 def test_index_with_project
43 get :index, :project_id => 1
71 get :index, :project_id => 1
@@ -46,6 +74,13 class NewsControllerTest < Test::Unit::TestCase
46 assert_not_nil assigns(:newss)
74 assert_not_nil assigns(:newss)
47 end
75 end
48
76
77 def test_show_routing
78 assert_routing(
79 {:method => :get, :path => '/news/2'},
80 :controller => 'news', :action => 'show', :id => '2'
81 )
82 end
83
49 def test_show
84 def test_show
50 get :show, :id => 1
85 get :show, :id => 1
51 assert_response :success
86 assert_response :success
@@ -58,6 +93,17 class NewsControllerTest < Test::Unit::TestCase
58 assert_response 404
93 assert_response 404
59 end
94 end
60
95
96 def test_new_routing
97 assert_routing(
98 {:method => :get, :path => '/projects/567/news/new'},
99 :controller => 'news', :action => 'new', :project_id => '567'
100 )
101 assert_recognizes(
102 {:controller => 'news', :action => 'new', :project_id => '567'},
103 {:method => :post, :path => '/projects/567/news'}
104 )
105 end
106
61 def test_get_new
107 def test_get_new
62 @request.session[:user_id] = 2
108 @request.session[:user_id] = 2
63 get :new, :project_id => 1
109 get :new, :project_id => 1
@@ -79,6 +125,17 class NewsControllerTest < Test::Unit::TestCase
79 assert_equal Project.find(1), news.project
125 assert_equal Project.find(1), news.project
80 end
126 end
81
127
128 def test_edit_routing
129 assert_routing(
130 {:method => :get, :path => '/news/234'},
131 :controller => 'news', :action => 'show', :id => '234'
132 )
133 assert_recognizes(#TODO: PUT to news URI instead, need to modify form
134 {:controller => 'news', :action => 'edit', :id => '567'},
135 {:method => :post, :path => '/news/567/edit'}
136 )
137 end
138
82 def test_get_edit
139 def test_get_edit
83 @request.session[:user_id] = 2
140 @request.session[:user_id] = 2
84 get :edit, :id => 1
141 get :edit, :id => 1
@@ -127,6 +184,13 class NewsControllerTest < Test::Unit::TestCase
127 assert_equal comments_count - 1, News.find(1).comments.size
184 assert_equal comments_count - 1, News.find(1).comments.size
128 end
185 end
129
186
187 def test_destroy_routing
188 assert_recognizes(#TODO: should use DELETE to news URI, need to change form
189 {:controller => 'news', :action => 'destroy', :id => '567'},
190 {:method => :post, :path => '/news/567/destroy'}
191 )
192 end
193
130 def test_destroy
194 def test_destroy
131 @request.session[:user_id] = 2
195 @request.session[:user_id] = 2
132 post :destroy, :id => 1
196 post :destroy, :id => 1
@@ -33,7 +33,14 class ProjectsControllerTest < Test::Unit::TestCase
33 @request.session[:user_id] = nil
33 @request.session[:user_id] = nil
34 Setting.default_language = 'en'
34 Setting.default_language = 'en'
35 end
35 end
36
36
37 def test_index_routing
38 assert_routing(
39 {:method => :get, :path => '/projects'},
40 :controller => 'projects', :action => 'index'
41 )
42 end
43
37 def test_index
44 def test_index
38 get :index
45 get :index
39 assert_response :success
46 assert_response :success
@@ -50,7 +57,14 class ProjectsControllerTest < Test::Unit::TestCase
50 }
57 }
51
58
52 assert_no_tag :a, :content => /Private child of eCookbook/
59 assert_no_tag :a, :content => /Private child of eCookbook/
53 end
60 end
61
62 def test_index_atom_routing
63 assert_routing(
64 {:method => :get, :path => '/projects.atom'},
65 :controller => 'projects', :action => 'index', :format => 'atom'
66 )
67 end
54
68
55 def test_index_atom
69 def test_index_atom
56 get :index, :format => 'atom'
70 get :index, :format => 'atom'
@@ -59,12 +73,34 class ProjectsControllerTest < Test::Unit::TestCase
59 assert_select 'feed>title', :text => 'Redmine: Latest projects'
73 assert_select 'feed>title', :text => 'Redmine: Latest projects'
60 assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
74 assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
61 end
75 end
62
76
63 def test_show_by_id
77 def test_add_routing
64 get :show, :id => 1
78 assert_routing(
79 {:method => :get, :path => '/projects/new'},
80 :controller => 'projects', :action => 'add'
81 )
82 assert_recognizes(
83 {:controller => 'projects', :action => 'add'},
84 {:method => :post, :path => '/projects/new'}
85 )
86 assert_recognizes(
87 {:controller => 'projects', :action => 'add'},
88 {:method => :post, :path => '/projects'}
89 )
90 end
91
92 def test_show_routing
93 assert_routing(
94 {:method => :get, :path => '/projects/test'},
95 :controller => 'projects', :action => 'show', :id => 'test'
96 )
97 end
98
99 def test_show_by_id
100 get :show, :id => 1
65 assert_response :success
101 assert_response :success
66 assert_template 'show'
102 assert_template 'show'
67 assert_not_nil assigns(:project)
103 assert_not_nil assigns(:project)
68 end
104 end
69
105
70 def test_show_by_identifier
106 def test_show_by_identifier
@@ -90,6 +126,17 class ProjectsControllerTest < Test::Unit::TestCase
90 assert_tag :tag => 'a', :content => /Private child/
126 assert_tag :tag => 'a', :content => /Private child/
91 end
127 end
92
128
129 def test_settings_routing
130 assert_routing(
131 {:method => :get, :path => '/projects/4223/settings'},
132 :controller => 'projects', :action => 'settings', :id => '4223'
133 )
134 assert_routing(
135 {:method => :get, :path => '/projects/4223/settings/members'},
136 :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
137 )
138 end
139
93 def test_settings
140 def test_settings
94 @request.session[:user_id] = 2 # manager
141 @request.session[:user_id] = 2 # manager
95 get :settings, :id => 1
142 get :settings, :id => 1
@@ -106,13 +153,49 class ProjectsControllerTest < Test::Unit::TestCase
106 assert_equal 'Test changed name', project.name
153 assert_equal 'Test changed name', project.name
107 end
154 end
108
155
156 def test_add_version_routing
157 assert_routing(
158 {:method => :get, :path => 'projects/64/versions/new'},
159 :controller => 'projects', :action => 'add_version', :id => '64'
160 )
161 assert_routing(
162 #TODO: use PUT
163 {:method => :post, :path => 'projects/64/versions/new'},
164 :controller => 'projects', :action => 'add_version', :id => '64'
165 )
166 end
167
168 def test_add_issue_category_routing
169 assert_routing(
170 {:method => :get, :path => 'projects/test/categories/new'},
171 :controller => 'projects', :action => 'add_issue_category', :id => 'test'
172 )
173 assert_routing(
174 #TODO: use PUT and update form
175 {:method => :post, :path => 'projects/64/categories/new'},
176 :controller => 'projects', :action => 'add_issue_category', :id => '64'
177 )
178 end
179
180 def test_destroy_routing
181 assert_routing(
182 {:method => :get, :path => '/projects/567/destroy'},
183 :controller => 'projects', :action => 'destroy', :id => '567'
184 )
185 assert_routing(
186 #TODO: use DELETE and update form
187 {:method => :post, :path => 'projects/64/destroy'},
188 :controller => 'projects', :action => 'destroy', :id => '64'
189 )
190 end
191
109 def test_get_destroy
192 def test_get_destroy
110 @request.session[:user_id] = 1 # admin
193 @request.session[:user_id] = 1 # admin
111 get :destroy, :id => 1
194 get :destroy, :id => 1
112 assert_response :success
195 assert_response :success
113 assert_template 'destroy'
196 assert_template 'destroy'
114 assert_not_nil Project.find_by_id(1)
197 assert_not_nil Project.find_by_id(1)
115 end
198 end
116
199
117 def test_post_destroy
200 def test_post_destroy
118 @request.session[:user_id] = 1 # admin
201 @request.session[:user_id] = 1 # admin
@@ -142,6 +225,17 class ProjectsControllerTest < Test::Unit::TestCase
142 assert mail.body.include?('testfile.txt')
225 assert mail.body.include?('testfile.txt')
143 end
226 end
144
227
228 def test_add_file_routing
229 assert_routing(
230 {:method => :get, :path => '/projects/33/files/new'},
231 :controller => 'projects', :action => 'add_file', :id => '33'
232 )
233 assert_routing(
234 {:method => :post, :path => '/projects/33/files/new'},
235 :controller => 'projects', :action => 'add_file', :id => '33'
236 )
237 end
238
145 def test_add_version_file
239 def test_add_version_file
146 set_tmp_attachments_directory
240 set_tmp_attachments_directory
147 @request.session[:user_id] = 2
241 @request.session[:user_id] = 2
@@ -156,27 +250,48 class ProjectsControllerTest < Test::Unit::TestCase
156 assert_equal 'testfile.txt', a.filename
250 assert_equal 'testfile.txt', a.filename
157 assert_equal Version.find(2), a.container
251 assert_equal Version.find(2), a.container
158 end
252 end
159
253
160 def test_list_files
254 def test_list_files
161 get :list_files, :id => 1
255 get :list_files, :id => 1
162 assert_response :success
256 assert_response :success
163 assert_template 'list_files'
257 assert_template 'list_files'
164 assert_not_nil assigns(:containers)
258 assert_not_nil assigns(:containers)
165
259
166 # file attached to the project
260 # file attached to the project
167 assert_tag :a, :content => 'project_file.zip',
261 assert_tag :a, :content => 'project_file.zip',
168 :attributes => { :href => '/attachments/download/8/project_file.zip' }
262 :attributes => { :href => '/attachments/download/8/project_file.zip' }
169
263
170 # file attached to a project's version
264 # file attached to a project's version
171 assert_tag :a, :content => 'version_file.zip',
265 assert_tag :a, :content => 'version_file.zip',
172 :attributes => { :href => '/attachments/download/9/version_file.zip' }
266 :attributes => { :href => '/attachments/download/9/version_file.zip' }
173 end
267 end
174
268
175 def test_changelog
269 def test_list_files_routing
176 get :changelog, :id => 1
270 assert_routing(
177 assert_response :success
271 {:method => :get, :path => '/projects/33/files'},
178 assert_template 'changelog'
272 :controller => 'projects', :action => 'list_files', :id => '33'
179 assert_not_nil assigns(:versions)
273 )
274 end
275
276 def test_changelog_routing
277 assert_routing(
278 {:method => :get, :path => '/projects/44/changelog'},
279 :controller => 'projects', :action => 'changelog', :id => '44'
280 )
281 end
282
283 def test_changelog
284 get :changelog, :id => 1
285 assert_response :success
286 assert_template 'changelog'
287 assert_not_nil assigns(:versions)
288 end
289
290 def test_roadmap_routing
291 assert_routing(
292 {:method => :get, :path => 'projects/33/roadmap'},
293 :controller => 'projects', :action => 'roadmap', :id => '33'
294 )
180 end
295 end
181
296
182 def test_roadmap
297 def test_roadmap
@@ -200,7 +315,21 class ProjectsControllerTest < Test::Unit::TestCase
200 # Completed version appears
315 # Completed version appears
201 assert assigns(:versions).include?(Version.find(1))
316 assert assigns(:versions).include?(Version.find(1))
202 end
317 end
203
318
319 def test_project_activity_routing
320 assert_routing(
321 {:method => :get, :path => '/projects/1/activity'},
322 :controller => 'projects', :action => 'activity', :id => '1'
323 )
324 end
325
326 def test_project_activity_atom_routing
327 assert_routing(
328 {:method => :get, :path => '/projects/1/activity.atom'},
329 :controller => 'projects', :action => 'activity', :id => '1', :format => 'atom'
330 )
331 end
332
204 def test_project_activity
333 def test_project_activity
205 get :activity, :id => 1, :with_subprojects => 0
334 get :activity, :id => 1, :with_subprojects => 0
206 assert_response :success
335 assert_response :success
@@ -237,6 +366,10 class ProjectsControllerTest < Test::Unit::TestCase
237 }
366 }
238 end
367 end
239
368
369 def test_global_activity_routing
370 assert_routing({:method => :get, :path => '/activity'}, :controller => 'projects', :action => 'activity')
371 end
372
240 def test_global_activity
373 def test_global_activity
241 get :activity
374 get :activity
242 assert_response :success
375 assert_response :success
@@ -273,19 +406,39 class ProjectsControllerTest < Test::Unit::TestCase
273 }
406 }
274 end
407 end
275
408
409 def test_global_activity_atom_routing
410 assert_routing({:method => :get, :path => '/activity.atom'}, :controller => 'projects', :action => 'activity', :format => 'atom')
411 end
412
276 def test_activity_atom_feed
413 def test_activity_atom_feed
277 get :activity, :format => 'atom'
414 get :activity, :format => 'atom'
278 assert_response :success
415 assert_response :success
279 assert_template 'common/feed.atom.rxml'
416 assert_template 'common/feed.atom.rxml'
280 end
417 end
281
418
282 def test_archive
419 def test_archive_routing
420 assert_routing(
421 #TODO: use PUT to project path and modify form
422 {:method => :post, :path => 'projects/64/archive'},
423 :controller => 'projects', :action => 'archive', :id => '64'
424 )
425 end
426
427 def test_archive
283 @request.session[:user_id] = 1 # admin
428 @request.session[:user_id] = 1 # admin
284 post :archive, :id => 1
429 post :archive, :id => 1
285 assert_redirected_to 'admin/projects'
430 assert_redirected_to 'admin/projects'
286 assert !Project.find(1).active?
431 assert !Project.find(1).active?
287 end
432 end
288
433
434 def test_unarchive_routing
435 assert_routing(
436 #TODO: use PUT to project path and modify form
437 {:method => :post, :path => '/projects/567/unarchive'},
438 :controller => 'projects', :action => 'unarchive', :id => '567'
439 )
440 end
441
289 def test_unarchive
442 def test_unarchive
290 @request.session[:user_id] = 1 # admin
443 @request.session[:user_id] = 1 # admin
291 Project.find(1).archive
444 Project.find(1).archive
@@ -31,25 +31,134 class RepositoriesControllerTest < Test::Unit::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_show_routing
35 assert_routing(
36 {:method => :get, :path => '/projects/redmine/repository'},
37 :controller => 'repositories', :action => 'show', :id => 'redmine'
38 )
39 end
40
41 def test_edit_routing
42 assert_routing(
43 {:method => :get, :path => '/projects/world_domination/repository/edit'},
44 :controller => 'repositories', :action => 'edit', :id => 'world_domination'
45 )
46 assert_routing(
47 {:method => :post, :path => '/projects/world_domination/repository/edit'},
48 :controller => 'repositories', :action => 'edit', :id => 'world_domination'
49 )
50 end
51
52 def test_revisions_routing
53 assert_routing(
54 {:method => :get, :path => '/projects/redmine/repository/revisions'},
55 :controller => 'repositories', :action => 'revisions', :id => 'redmine'
56 )
57 end
58
59 def test_revisions_atom_routing
60 assert_routing(
61 {:method => :get, :path => '/projects/redmine/repository/revisions.atom'},
62 :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
63 )
64 end
65
34 def test_revisions
66 def test_revisions
35 get :revisions, :id => 1
67 get :revisions, :id => 1
36 assert_response :success
68 assert_response :success
37 assert_template 'revisions'
69 assert_template 'revisions'
38 assert_not_nil assigns(:changesets)
70 assert_not_nil assigns(:changesets)
39 end
71 end
72
73 def test_revision_routing
74 assert_routing(
75 {:method => :get, :path => '/projects/restmine/repository/revisions/2457'},
76 :controller => 'repositories', :action => 'revision', :id => 'restmine', :rev => '2457'
77 )
78 end
40
79
41 def test_revision_with_before_nil_and_afer_normal
80 def test_revision_with_before_nil_and_afer_normal
42 get :revision, {:id => 1, :rev => 1}
81 get :revision, {:id => 1, :rev => 1}
43 assert_response :success
82 assert_response :success
44 assert_template 'revision'
83 assert_template 'revision'
45 assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
84 assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
46 :child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook/0'}
85 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/0'}
47 }
86 }
48 assert_tag :tag => "div", :attributes => { :class => "contextual" },
87 assert_tag :tag => "div", :attributes => { :class => "contextual" },
49 :child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook/2'}
88 :child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'}
50 }
89 }
51 end
90 end
91
92 def test_diff_routing
93 assert_routing(
94 {:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff'},
95 :controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457'
96 )
97 end
98
99 def test_unified_diff_routing
100 assert_routing(
101 {:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff.diff'},
102 :controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457', :format => 'diff'
103 )
104 end
105
106 def test_diff_path_routing
107 assert_routing(
108 {:method => :get, :path => '/projects/restmine/repository/diff/path/to/file.c'},
109 :controller => 'repositories', :action => 'diff', :id => 'restmine', :path => %w[path to file.c]
110 )
111 end
52
112
113 def test_diff_path_routing_with_revision
114 assert_routing(
115 {:method => :get, :path => '/projects/restmine/repository/revisions/2/diff/path/to/file.c'},
116 :controller => 'repositories', :action => 'diff', :id => 'restmine', :path => %w[path to file.c], :rev => '2'
117 )
118 end
119
120 def test_browse_routing
121 assert_routing(
122 {:method => :get, :path => '/projects/restmine/repository/browse/path/to/dir'},
123 :controller => 'repositories', :action => 'browse', :id => 'restmine', :path => %w[path to dir]
124 )
125 end
126
127 def test_entry_routing
128 assert_routing(
129 {:method => :get, :path => '/projects/restmine/repository/entry/path/to/file.c'},
130 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c]
131 )
132 end
133
134 def test_entry_routing_with_revision
135 assert_routing(
136 {:method => :get, :path => '/projects/restmine/repository/revisions/2/entry/path/to/file.c'},
137 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c], :rev => '2'
138 )
139 end
140
141 def test_annotate_routing
142 assert_routing(
143 {:method => :get, :path => '/projects/restmine/repository/annotate/path/to/file.c'},
144 :controller => 'repositories', :action => 'annotate', :id => 'restmine', :path => %w[path to file.c]
145 )
146 end
147
148 def test_changesrouting
149 assert_routing(
150 {:method => :get, :path => '/projects/restmine/repository/changes/path/to/file.c'},
151 :controller => 'repositories', :action => 'changes', :id => 'restmine', :path => %w[path to file.c]
152 )
153 end
154
155 def test_statistics_routing
156 assert_routing(
157 {:method => :get, :path => '/projects/restmine/repository/statistics'},
158 :controller => 'repositories', :action => 'stats', :id => 'restmine'
159 )
160 end
161
53 def test_graph_commits_per_month
162 def test_graph_commits_per_month
54 get :graph, :id => 1, :graph => 'commits_per_month'
163 get :graph, :id => 1, :graph => 'commits_per_month'
55 assert_response :success
164 assert_response :success
@@ -131,11 +131,11 class RepositoriesSubversionControllerTest < Test::Unit::TestCase
131 :child => { :tag => 'li',
131 :child => { :tag => 'li',
132 # link to the entry at rev 2
132 # link to the entry at rev 2
133 :child => { :tag => 'a',
133 :child => { :tag => 'a',
134 :attributes => {:href => '/repositories/entry/ecookbook/test/some/path/in/the/repo?rev=2'},
134 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'},
135 :content => 'repo',
135 :content => 'repo',
136 # link to partial diff
136 # link to partial diff
137 :sibling => { :tag => 'a',
137 :sibling => { :tag => 'a',
138 :attributes => { :href => '/repositories/diff/ecookbook/test/some/path/in/the/repo?rev=2' }
138 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' }
139 }
139 }
140 }
140 }
141 }
141 }
@@ -153,11 +153,11 class RepositoriesSubversionControllerTest < Test::Unit::TestCase
153 :child => { :tag => 'li',
153 :child => { :tag => 'li',
154 # link to the entry at rev 2
154 # link to the entry at rev 2
155 :child => { :tag => 'a',
155 :child => { :tag => 'a',
156 :attributes => {:href => '/repositories/entry/ecookbook/path/in/the/repo?rev=2'},
156 :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'},
157 :content => 'repo',
157 :content => 'repo',
158 # link to partial diff
158 # link to partial diff
159 :sibling => { :tag => 'a',
159 :sibling => { :tag => 'a',
160 :attributes => { :href => '/repositories/diff/ecookbook/path/in/the/repo?rev=2' }
160 :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' }
161 }
161 }
162 }
162 }
163 }
163 }
@@ -30,6 +30,28 class TimelogControllerTest < Test::Unit::TestCase
30 @response = ActionController::TestResponse.new
30 @response = ActionController::TestResponse.new
31 end
31 end
32
32
33 def test_edit_routing
34 assert_routing(
35 {:method => :get, :path => '/issues/567/time_entries/new'},
36 :controller => 'timelog', :action => 'edit', :issue_id => '567'
37 )
38 assert_routing(
39 {:method => :get, :path => '/projects/ecookbook/time_entries/new'},
40 :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook'
41 )
42 assert_routing(
43 {:method => :get, :path => '/projects/ecookbook/issues/567/time_entries/new'},
44 :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567'
45 )
46
47 #TODO: change new form to POST to issue_time_entries_path instead of to edit action
48 #TODO: change edit form to PUT to time_entry_path
49 assert_routing(
50 {:method => :get, :path => '/time_entries/22/edit'},
51 :controller => 'timelog', :action => 'edit', :id => '22'
52 )
53 end
54
33 def test_get_edit
55 def test_get_edit
34 @request.session[:user_id] = 3
56 @request.session[:user_id] = 3
35 get :edit, :project_id => 1
57 get :edit, :project_id => 1
@@ -41,6 +63,8 class TimelogControllerTest < Test::Unit::TestCase
41 end
63 end
42
64
43 def test_post_edit
65 def test_post_edit
66 # TODO: should POST to issues’ time log instead of project. change form
67 # and routing
44 @request.session[:user_id] = 3
68 @request.session[:user_id] = 3
45 post :edit, :project_id => 1,
69 post :edit, :project_id => 1,
46 :time_entry => {:comments => 'Some work on TimelogControllerTest',
70 :time_entry => {:comments => 'Some work on TimelogControllerTest',
@@ -49,7 +73,7 class TimelogControllerTest < Test::Unit::TestCase
49 :spent_on => '2008-03-14',
73 :spent_on => '2008-03-14',
50 :issue_id => '1',
74 :issue_id => '1',
51 :hours => '7.3'}
75 :hours => '7.3'}
52 assert_redirected_to 'projects/ecookbook/timelog/details'
76 assert_redirected_to :action => 'details', :project_id => 'ecookbook'
53
77
54 i = Issue.find(1)
78 i = Issue.find(1)
55 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
79 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
@@ -70,7 +94,7 class TimelogControllerTest < Test::Unit::TestCase
70 post :edit, :id => 1,
94 post :edit, :id => 1,
71 :time_entry => {:issue_id => '2',
95 :time_entry => {:issue_id => '2',
72 :hours => '8'}
96 :hours => '8'}
73 assert_redirected_to 'projects/ecookbook/timelog/details'
97 assert_redirected_to :action => 'details', :project_id => 'ecookbook'
74 entry.reload
98 entry.reload
75
99
76 assert_equal 8, entry.hours
100 assert_equal 8, entry.hours
@@ -78,18 +102,44 class TimelogControllerTest < Test::Unit::TestCase
78 assert_equal 2, entry.user_id
102 assert_equal 2, entry.user_id
79 end
103 end
80
104
105 def test_destroy_routing
106 #TODO: use DELETE to time_entry_path
107 assert_routing(
108 {:method => :post, :path => '/time_entries/55/destroy'},
109 :controller => 'timelog', :action => 'destroy', :id => '55'
110 )
111 end
112
81 def test_destroy
113 def test_destroy
82 @request.session[:user_id] = 2
114 @request.session[:user_id] = 2
83 post :destroy, :id => 1
115 post :destroy, :id => 1
84 assert_redirected_to 'projects/ecookbook/timelog/details'
116 assert_redirected_to :action => 'details', :project_id => 'ecookbook'
85 assert_nil TimeEntry.find_by_id(1)
117 assert_nil TimeEntry.find_by_id(1)
86 end
118 end
87
119
120 def test_report_routing
121 assert_routing(
122 {:method => :get, :path => '/projects/567/time_entries/report'},
123 :controller => 'timelog', :action => 'report', :project_id => '567'
124 )
125 assert_routing(
126 {:method => :get, :path => '/projects/567/time_entries/report.csv'},
127 :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
128 )
129 end
130
88 def test_report_no_criteria
131 def test_report_no_criteria
89 get :report, :project_id => 1
132 get :report, :project_id => 1
90 assert_response :success
133 assert_response :success
91 assert_template 'report'
134 assert_template 'report'
92 end
135 end
136
137 def test_report_routing_for_all_projects
138 assert_routing(
139 {:method => :get, :path => '/time_entries/report'},
140 :controller => 'timelog', :action => 'report'
141 )
142 end
93
143
94 def test_report_all_projects
144 def test_report_all_projects
95 get :report
145 get :report
@@ -103,7 +153,7 class TimelogControllerTest < Test::Unit::TestCase
103 r.permissions_will_change!
153 r.permissions_will_change!
104 r.save
154 r.save
105 get :report
155 get :report
106 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Ftimelog%2Freport'
156 assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Ftime_entries%2Freport'
107 end
157 end
108
158
109 def test_report_all_projects_one_criteria
159 def test_report_all_projects_one_criteria
@@ -201,7 +251,14 class TimelogControllerTest < Test::Unit::TestCase
201 assert_not_nil assigns(:total_hours)
251 assert_not_nil assigns(:total_hours)
202 assert_equal "162.90", "%.2f" % assigns(:total_hours)
252 assert_equal "162.90", "%.2f" % assigns(:total_hours)
203 end
253 end
204
254
255 def test_project_details_routing
256 assert_routing(
257 {:method => :get, :path => '/projects/567/time_entries'},
258 :controller => 'timelog', :action => 'details', :project_id => '567'
259 )
260 end
261
205 def test_details_at_project_level
262 def test_details_at_project_level
206 get :details, :project_id => 1
263 get :details, :project_id => 1
207 assert_response :success
264 assert_response :success
@@ -239,6 +296,23 class TimelogControllerTest < Test::Unit::TestCase
239 assert_equal Date.today, assigns(:to)
296 assert_equal Date.today, assigns(:to)
240 end
297 end
241
298
299 def test_issue_details_routing
300 assert_routing(
301 {:method => :get, :path => 'time_entries'},
302 :controller => 'timelog', :action => 'details'
303 )
304 assert_routing(
305 {:method => :get, :path => '/issues/234/time_entries'},
306 :controller => 'timelog', :action => 'details', :issue_id => '234'
307 )
308 # TODO: issue detail page shouldnt link to project_issue_time_entries_path but to normal issues one
309 # doesnt seem to have effect on resulting page so controller can be left untouched
310 assert_routing(
311 {:method => :get, :path => '/projects/ecookbook/issues/123/time_entries'},
312 :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123'
313 )
314 end
315
242 def test_details_at_issue_level
316 def test_details_at_issue_level
243 get :details, :issue_id => 1
317 get :details, :issue_id => 1
244 assert_response :success
318 assert_response :success
@@ -252,6 +326,39 class TimelogControllerTest < Test::Unit::TestCase
252 assert_equal '2007-04-22'.to_date, assigns(:to)
326 assert_equal '2007-04-22'.to_date, assigns(:to)
253 end
327 end
254
328
329 def test_details_formatted_routing
330 assert_routing(
331 {:method => :get, :path => 'time_entries.atom'},
332 :controller => 'timelog', :action => 'details', :format => 'atom'
333 )
334 assert_routing(
335 {:method => :get, :path => 'time_entries.csv'},
336 :controller => 'timelog', :action => 'details', :format => 'csv'
337 )
338 end
339
340 def test_details_for_project_formatted_routing
341 assert_routing(
342 {:method => :get, :path => '/projects/567/time_entries.atom'},
343 :controller => 'timelog', :action => 'details', :format => 'atom', :project_id => '567'
344 )
345 assert_routing(
346 {:method => :get, :path => '/projects/567/time_entries.csv'},
347 :controller => 'timelog', :action => 'details', :format => 'csv', :project_id => '567'
348 )
349 end
350
351 def test_details_for_issue_formatted_routing
352 assert_routing(
353 {:method => :get, :path => '/projects/ecookbook/issues/123/time_entries.atom'},
354 :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123', :format => 'atom'
355 )
356 assert_routing(
357 {:method => :get, :path => '/projects/ecookbook/issues/123/time_entries.csv'},
358 :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123', :format => 'csv'
359 )
360 end
361
255 def test_details_atom_feed
362 def test_details_atom_feed
256 get :details, :project_id => 1, :format => 'atom'
363 get :details, :project_id => 1, :format => 'atom'
257 assert_response :success
364 assert_response :success
@@ -32,11 +32,27 class UsersControllerTest < Test::Unit::TestCase
32 @request.session[:user_id] = 1 # admin
32 @request.session[:user_id] = 1 # admin
33 end
33 end
34
34
35 def test_index_routing
36 #TODO: unify with list
37 assert_generates(
38 '/users',
39 :controller => 'users', :action => 'index'
40 )
41 end
42
35 def test_index
43 def test_index
36 get :index
44 get :index
37 assert_response :success
45 assert_response :success
38 assert_template 'list'
46 assert_template 'list'
39 end
47 end
48
49 def test_list_routing
50 #TODO: rename action to index
51 assert_routing(
52 {:method => :get, :path => '/users'},
53 :controller => 'users', :action => 'list'
54 )
55 end
40
56
41 def test_list
57 def test_list
42 get :list
58 get :list
@@ -56,17 +72,71 class UsersControllerTest < Test::Unit::TestCase
56 assert_equal 1, users.size
72 assert_equal 1, users.size
57 assert_equal 'John', users.first.firstname
73 assert_equal 'John', users.first.firstname
58 end
74 end
75
76 def test_add_routing
77 assert_routing(
78 {:method => :get, :path => '/users/new'},
79 :controller => 'users', :action => 'add'
80 )
81 assert_recognizes(
82 #TODO: remove this and replace with POST to collection, need to modify form
83 {:controller => 'users', :action => 'add'},
84 {:method => :post, :path => '/users/new'}
85 )
86 assert_recognizes(
87 {:controller => 'users', :action => 'add'},
88 {:method => :post, :path => '/users'}
89 )
90 end
91
92 def test_edit_routing
93 assert_routing(
94 {:method => :get, :path => '/users/444/edit'},
95 :controller => 'users', :action => 'edit', :id => '444'
96 )
97 assert_routing(
98 {:method => :get, :path => '/users/222/edit/membership'},
99 :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
100 )
101 assert_recognizes(
102 #TODO: use PUT on user_path, modify form
103 {:controller => 'users', :action => 'edit', :id => '444'},
104 {:method => :post, :path => '/users/444/edit'}
105 )
106 end
107
108 def test_add_membership_routing
109 assert_routing(
110 {:method => :post, :path => '/users/123/memberships'},
111 :controller => 'users', :action => 'edit_membership', :id => '123'
112 )
113 end
114
115 def test_edit_membership_routing
116 assert_routing(
117 {:method => :post, :path => '/users/123/memberships/55'},
118 :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
119 )
120 end
59
121
60 def test_edit_membership
122 def test_edit_membership
61 post :edit_membership, :id => 2, :membership_id => 1,
123 post :edit_membership, :id => 2, :membership_id => 1,
62 :membership => { :role_id => 2}
124 :membership => { :role_id => 2}
63 assert_redirected_to '/users/edit/2?tab=memberships'
125 assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships'
64 assert_equal 2, Member.find(1).role_id
126 assert_equal 2, Member.find(1).role_id
65 end
127 end
66
128
67 def test_destroy_membership
129 def test_destroy_membership
130 assert_routing(
131 #TODO: use DELETE method on user_membership_path, modify form
132 {:method => :post, :path => '/users/567/memberships/12/destroy'},
133 :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
134 )
135 end
136
137 def test_destroy_membership
68 post :destroy_membership, :id => 2, :membership_id => 1
138 post :destroy_membership, :id => 2, :membership_id => 1
69 assert_redirected_to '/users/edit/2?tab=memberships'
139 assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships'
70 assert_nil Member.find_by_id(1)
140 assert_nil Member.find_by_id(1)
71 end
141 end
72 end
142 end
@@ -52,7 +52,7 class VersionsControllerTest < Test::Unit::TestCase
52 post :edit, :id => 2,
52 post :edit, :id => 2,
53 :version => { :name => 'New version name',
53 :version => { :name => 'New version name',
54 :effective_date => Date.today.strftime("%Y-%m-%d")}
54 :effective_date => Date.today.strftime("%Y-%m-%d")}
55 assert_redirected_to '/projects/settings/ecookbook?tab=versions'
55 assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
56 version = Version.find(2)
56 version = Version.find(2)
57 assert_equal 'New version name', version.name
57 assert_equal 'New version name', version.name
58 assert_equal Date.today, version.effective_date
58 assert_equal Date.today, version.effective_date
@@ -61,7 +61,7 class VersionsControllerTest < Test::Unit::TestCase
61 def test_destroy
61 def test_destroy
62 @request.session[:user_id] = 2
62 @request.session[:user_id] = 2
63 post :destroy, :id => 3
63 post :destroy, :id => 3
64 assert_redirected_to '/projects/settings/ecookbook?tab=versions'
64 assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
65 assert_nil Version.find_by_id(3)
65 assert_nil Version.find_by_id(3)
66 end
66 end
67
67
@@ -31,6 +31,21 class WikiControllerTest < Test::Unit::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_index_routing
35 assert_routing(
36 {:method => :get, :path => '/projects/567/wiki'},
37 :controller => 'wiki', :action => 'index', :id => '567'
38 )
39 assert_routing(
40 {:method => :get, :path => '/projects/567/wiki/lalala'},
41 :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
42 )
43 assert_generates(
44 '/projects/567/wiki',
45 :controller => 'wiki', :action => 'index', :id => '567', :page => nil
46 )
47 end
48
34 def test_show_start_page
49 def test_show_start_page
35 get :index, :id => 'ecookbook'
50 get :index, :id => 'ecookbook'
36 assert_response :success
51 assert_response :success
@@ -40,7 +55,7 class WikiControllerTest < Test::Unit::TestCase
40 # child_pages macro
55 # child_pages macro
41 assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
56 assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
42 :child => { :tag => 'li',
57 :child => { :tag => 'li',
43 :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
58 :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
44 :content => 'Page with an inline image' } }
59 :content => 'Page with an inline image' } }
45 end
60 end
46
61
@@ -67,6 +82,17 class WikiControllerTest < Test::Unit::TestCase
67 assert_template 'edit'
82 assert_template 'edit'
68 end
83 end
69
84
85 def test_edit_routing
86 assert_routing(
87 {:method => :get, :path => '/projects/567/wiki/my_page/edit'},
88 :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
89 )
90 assert_recognizes(#TODO: use PUT to page path, adjust forms accordingly
91 {:controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'},
92 {:method => :post, :path => '/projects/567/wiki/my_page/edit'}
93 )
94 end
95
70 def test_create_page
96 def test_create_page
71 @request.session[:user_id] = 2
97 @request.session[:user_id] = 2
72 post :edit, :id => 1,
98 post :edit, :id => 1,
@@ -74,13 +100,20 class WikiControllerTest < Test::Unit::TestCase
74 :content => {:comments => 'Created the page',
100 :content => {:comments => 'Created the page',
75 :text => "h1. New page\n\nThis is a new page",
101 :text => "h1. New page\n\nThis is a new page",
76 :version => 0}
102 :version => 0}
77 assert_redirected_to 'wiki/ecookbook/New_page'
103 assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'New_page'
78 page = Project.find(1).wiki.find_page('New page')
104 page = Project.find(1).wiki.find_page('New page')
79 assert !page.new_record?
105 assert !page.new_record?
80 assert_not_nil page.content
106 assert_not_nil page.content
81 assert_equal 'Created the page', page.content.comments
107 assert_equal 'Created the page', page.content.comments
82 end
108 end
83
109
110 def test_preview_routing
111 assert_routing(
112 {:method => :post, :path => '/projects/567/wiki/CookBook_documentation/preview'},
113 :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation'
114 )
115 end
116
84 def test_preview
117 def test_preview
85 @request.session[:user_id] = 2
118 @request.session[:user_id] = 2
86 xhr :post, :preview, :id => 1, :page => 'CookBook_documentation',
119 xhr :post, :preview, :id => 1, :page => 'CookBook_documentation',
@@ -103,6 +136,13 class WikiControllerTest < Test::Unit::TestCase
103 assert_tag :tag => 'h1', :content => /New page/
136 assert_tag :tag => 'h1', :content => /New page/
104 end
137 end
105
138
139 def test_history_routing
140 assert_routing(
141 {:method => :get, :path => '/projects/1/wiki/CookBook_documentation/history'},
142 :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation'
143 )
144 end
145
106 def test_history
146 def test_history
107 get :history, :id => 1, :page => 'CookBook_documentation'
147 get :history, :id => 1, :page => 'CookBook_documentation'
108 assert_response :success
148 assert_response :success
@@ -120,6 +160,13 class WikiControllerTest < Test::Unit::TestCase
120 assert_equal 1, assigns(:versions).size
160 assert_equal 1, assigns(:versions).size
121 assert_select "input[type=submit][name=commit]", false
161 assert_select "input[type=submit][name=commit]", false
122 end
162 end
163
164 def test_diff_routing
165 assert_routing(
166 {:method => :get, :path => '/projects/1/wiki/CookBook_documentation/diff/2/vs/1'},
167 :controller => 'wiki', :action => 'diff', :id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1'
168 )
169 end
123
170
124 def test_diff
171 def test_diff
125 get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
172 get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
@@ -129,6 +176,13 class WikiControllerTest < Test::Unit::TestCase
129 :content => /updated/
176 :content => /updated/
130 end
177 end
131
178
179 def test_annotate_routing
180 assert_routing(
181 {:method => :get, :path => '/projects/1/wiki/CookBook_documentation/annotate/2'},
182 :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2'
183 )
184 end
185
132 def test_annotate
186 def test_annotate
133 get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2
187 get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2
134 assert_response :success
188 assert_response :success
@@ -143,12 +197,24 class WikiControllerTest < Test::Unit::TestCase
143 :child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
197 :child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
144 end
198 end
145
199
200 def test_rename_routing
201 assert_routing(
202 {:method => :get, :path => '/projects/22/wiki/ladida/rename'},
203 :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
204 )
205 assert_recognizes(
206 #TODO: should be moved into a update action and use a PUT to the page URI
207 {:controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'},
208 {:method => :post, :path => '/projects/22/wiki/ladida/rename'}
209 )
210 end
211
146 def test_rename_with_redirect
212 def test_rename_with_redirect
147 @request.session[:user_id] = 2
213 @request.session[:user_id] = 2
148 post :rename, :id => 1, :page => 'Another_page',
214 post :rename, :id => 1, :page => 'Another_page',
149 :wiki_page => { :title => 'Another renamed page',
215 :wiki_page => { :title => 'Another renamed page',
150 :redirect_existing_links => 1 }
216 :redirect_existing_links => 1 }
151 assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
217 assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_renamed_page'
152 wiki = Project.find(1).wiki
218 wiki = Project.find(1).wiki
153 # Check redirects
219 # Check redirects
154 assert_not_nil wiki.find_page('Another page')
220 assert_not_nil wiki.find_page('Another page')
@@ -160,16 +226,43 class WikiControllerTest < Test::Unit::TestCase
160 post :rename, :id => 1, :page => 'Another_page',
226 post :rename, :id => 1, :page => 'Another_page',
161 :wiki_page => { :title => 'Another renamed page',
227 :wiki_page => { :title => 'Another renamed page',
162 :redirect_existing_links => "0" }
228 :redirect_existing_links => "0" }
163 assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
229 assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_renamed_page'
164 wiki = Project.find(1).wiki
230 wiki = Project.find(1).wiki
165 # Check that there's no redirects
231 # Check that there's no redirects
166 assert_nil wiki.find_page('Another page')
232 assert_nil wiki.find_page('Another page')
167 end
233 end
168
234
235 def test_destroy_routing
236 assert_recognizes(
237 #TODO: should use DELETE on page URI
238 {:controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida'},
239 {:method => :post, :path => 'projects/22/wiki/ladida/destroy'}
240 )
241 end
242
169 def test_destroy
243 def test_destroy
170 @request.session[:user_id] = 2
244 @request.session[:user_id] = 2
171 post :destroy, :id => 1, :page => 'CookBook_documentation'
245 post :destroy, :id => 1, :page => 'CookBook_documentation'
172 assert_redirected_to 'wiki/ecookbook/Page_index/special'
246 assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
247 end
248
249 def test_special_routing
250 assert_routing(
251 {:method => :get, :path => '/projects/567/wiki/page_index'},
252 :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
253 )
254 assert_routing(
255 {:method => :get, :path => '/projects/567/wiki/Page_Index'},
256 :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
257 )
258 assert_routing(
259 {:method => :get, :path => '/projects/567/wiki/date_index'},
260 :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
261 )
262 assert_routing(
263 {:method => :get, :path => '/projects/567/wiki/export'},
264 :controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
265 )
173 end
266 end
174
267
175 def test_page_index
268 def test_page_index
@@ -181,13 +274,13 class WikiControllerTest < Test::Unit::TestCase
181 assert_equal Project.find(1).wiki.pages.size, pages.size
274 assert_equal Project.find(1).wiki.pages.size, pages.size
182
275
183 assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
276 assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
184 :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
277 :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
185 :content => 'CookBook documentation' },
278 :content => 'CookBook documentation' },
186 :child => { :tag => 'ul',
279 :child => { :tag => 'ul',
187 :child => { :tag => 'li',
280 :child => { :tag => 'li',
188 :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
281 :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
189 :content => 'Page with an inline image' } } } },
282 :content => 'Page with an inline image' } } } },
190 :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Another_page' },
283 :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
191 :content => 'Another page' } }
284 :content => 'Another page' } }
192 end
285 end
193
286
@@ -196,12 +289,19 class WikiControllerTest < Test::Unit::TestCase
196 assert_response 404
289 assert_response 404
197 end
290 end
198
291
292 def test_protect_routing
293 assert_routing(
294 {:method => :post, :path => 'projects/22/wiki/ladida/protect'},
295 {:controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'}
296 )
297 end
298
199 def test_protect_page
299 def test_protect_page
200 page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
300 page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
201 assert !page.protected?
301 assert !page.protected?
202 @request.session[:user_id] = 2
302 @request.session[:user_id] = 2
203 post :protect, :id => 1, :page => page.title, :protected => '1'
303 post :protect, :id => 1, :page => page.title, :protected => '1'
204 assert_redirected_to 'wiki/ecookbook/Another_page'
304 assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_page'
205 assert page.reload.protected?
305 assert page.reload.protected?
206 end
306 end
207
307
@@ -210,7 +310,7 class WikiControllerTest < Test::Unit::TestCase
210 assert page.protected?
310 assert page.protected?
211 @request.session[:user_id] = 2
311 @request.session[:user_id] = 2
212 post :protect, :id => 1, :page => page.title, :protected => '0'
312 post :protect, :id => 1, :page => page.title, :protected => '0'
213 assert_redirected_to '/wiki/ecookbook/CookBook_documentation'
313 assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'CookBook_documentation'
214 assert !page.reload.protected?
314 assert !page.reload.protected?
215 end
315 end
216
316
@@ -219,7 +319,7 class WikiControllerTest < Test::Unit::TestCase
219 get :index, :id => 1
319 get :index, :id => 1
220 assert_response :success
320 assert_response :success
221 assert_template 'show'
321 assert_template 'show'
222 assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
322 assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
223 end
323 end
224
324
225 def test_show_page_without_edit_link
325 def test_show_page_without_edit_link
@@ -227,7 +327,7 class WikiControllerTest < Test::Unit::TestCase
227 get :index, :id => 1
327 get :index, :id => 1
228 assert_response :success
328 assert_response :success
229 assert_template 'show'
329 assert_template 'show'
230 assert_no_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
330 assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
231 end
331 end
232
332
233 def test_edit_unprotected_page
333 def test_edit_unprotected_page
@@ -31,6 +31,14 class WikisControllerTest < Test::Unit::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_edit_routing
35 assert_routing(
36 #TODO: use PUT
37 {:method => :post, :path => 'projects/ladida/wiki'},
38 :controller => 'wikis', :action => 'edit', :id => 'ladida'
39 )
40 end
41
34 def test_create
42 def test_create
35 @request.session[:user_id] = 1
43 @request.session[:user_id] = 1
36 assert_nil Project.find(3).wiki
44 assert_nil Project.find(3).wiki
@@ -41,10 +49,21 class WikisControllerTest < Test::Unit::TestCase
41 assert_equal 'Start page', wiki.start_page
49 assert_equal 'Start page', wiki.start_page
42 end
50 end
43
51
52 def test_destroy_routing
53 assert_routing(
54 {:method => :get, :path => 'projects/ladida/wiki/destroy'},
55 :controller => 'wikis', :action => 'destroy', :id => 'ladida'
56 )
57 assert_recognizes( #TODO: use DELETE and update form
58 {:controller => 'wikis', :action => 'destroy', :id => 'ladida'},
59 {:method => :post, :path => 'projects/ladida/wiki/destroy'}
60 )
61 end
62
44 def test_destroy
63 def test_destroy
45 @request.session[:user_id] = 1
64 @request.session[:user_id] = 1
46 post :destroy, :id => 1, :confirm => 1
65 post :destroy, :id => 1, :confirm => 1
47 assert_redirected_to '/projects/settings/ecookbook?tab=wiki'
66 assert_redirected_to :action => 'settings', :id => 'ecookbook', :tab => 'wiki'
48 assert_nil Project.find(1).wiki
67 assert_nil Project.find(1).wiki
49 end
68 end
50
69
@@ -53,4 +72,4 class WikisControllerTest < Test::Unit::TestCase
53 post :destroy, :id => 999, :confirm => 1
72 post :destroy, :id => 999, :confirm => 1
54 assert_response 404
73 assert_response 404
55 end
74 end
56 end
75 end
@@ -42,10 +42,10 class AdminTest < ActionController::IntegrationTest
42
42
43 def test_add_project
43 def test_add_project
44 log_user("admin", "admin")
44 log_user("admin", "admin")
45 get "projects/add"
45 get "projects/new"
46 assert_response :success
46 assert_response :success
47 assert_template "projects/add"
47 assert_template "projects/add"
48 post "projects/add", :project => { :name => "blog",
48 post "projects", :project => { :name => "blog",
49 :description => "weblog",
49 :description => "weblog",
50 :identifier => "blog",
50 :identifier => "blog",
51 :is_public => 1,
51 :is_public => 1,
@@ -39,7 +39,7 class IssuesTest < ActionController::IntegrationTest
39 assert_response :success
39 assert_response :success
40 assert_template 'issues/new'
40 assert_template 'issues/new'
41
41
42 post 'projects/1/issues/new', :tracker_id => "1",
42 post 'projects/1/issues', :tracker_id => "1",
43 :issue => { :start_date => "2006-12-26",
43 :issue => { :start_date => "2006-12-26",
44 :priority_id => "3",
44 :priority_id => "3",
45 :subject => "new test issue",
45 :subject => "new test issue",
@@ -54,7 +54,7 class IssuesTest < ActionController::IntegrationTest
54 assert_kind_of Issue, issue
54 assert_kind_of Issue, issue
55
55
56 # check redirection
56 # check redirection
57 assert_redirected_to "issues/show"
57 assert_redirected_to :controller => 'issues', :action => 'show'
58 follow_redirect!
58 follow_redirect!
59 assert_equal issue, assigns(:issue)
59 assert_equal issue, assigns(:issue)
60
60
@@ -69,10 +69,10 class IssuesTest < ActionController::IntegrationTest
69 log_user('jsmith', 'jsmith')
69 log_user('jsmith', 'jsmith')
70 set_tmp_attachments_directory
70 set_tmp_attachments_directory
71
71
72 post 'issues/edit/1',
72 post 'issues/1/edit',
73 :notes => 'Some notes',
73 :notes => 'Some notes',
74 :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
74 :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
75 assert_redirected_to "issues/show/1"
75 assert_redirected_to "issues/1"
76
76
77 # make sure attachment was saved
77 # make sure attachment was saved
78 attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
78 attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
@@ -27,18 +27,18 class ProjectsTest < ActionController::IntegrationTest
27 assert_response :success
27 assert_response :success
28 assert_template "admin/projects"
28 assert_template "admin/projects"
29 post "projects/archive", :id => 1
29 post "projects/archive", :id => 1
30 assert_redirected_to "admin/projects"
30 assert_redirected_to "admin/projects"
31 assert !Project.find(1).active?
31 assert !Project.find(1).active?
32
32
33 get "projects/show", :id => 1
33 get 'projects/1'
34 assert_response 403
34 assert_response 403
35 get "projects/show", :id => subproject.id
35 get "projects/#{subproject.id}"
36 assert_response 403
36 assert_response 403
37
37
38 post "projects/unarchive", :id => 1
38 post "projects/unarchive", :id => 1
39 assert_redirected_to "admin/projects"
39 assert_redirected_to "admin/projects"
40 assert Project.find(1).active?
40 assert Project.find(1).active?
41 get "projects/show", :id => 1
41 get "projects/1"
42 assert_response :success
42 assert_response :success
43 end
43 end
44 end
44 end
@@ -174,23 +174,23 class ApplicationHelperTest < HelperTestCase
174
174
175 def test_wiki_links
175 def test_wiki_links
176 to_test = {
176 to_test = {
177 '[[CookBook documentation]]' => '<a href="/wiki/ecookbook/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
177 '[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
178 '[[Another page|Page]]' => '<a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a>',
178 '[[Another page|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a>',
179 # link with anchor
179 # link with anchor
180 '[[CookBook documentation#One-section]]' => '<a href="/wiki/ecookbook/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>',
180 '[[CookBook documentation#One-section]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>',
181 '[[Another page#anchor|Page]]' => '<a href="/wiki/ecookbook/Another_page#anchor" class="wiki-page">Page</a>',
181 '[[Another page#anchor|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page#anchor" class="wiki-page">Page</a>',
182 # page that doesn't exist
182 # page that doesn't exist
183 '[[Unknown page]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">Unknown page</a>',
183 '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
184 '[[Unknown page|404]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">404</a>',
184 '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">404</a>',
185 # link to another project wiki
185 # link to another project wiki
186 '[[onlinestore:]]' => '<a href="/wiki/onlinestore/" class="wiki-page">onlinestore</a>',
186 '[[onlinestore:]]' => '<a href="/projects/onlinestore/wiki/" class="wiki-page">onlinestore</a>',
187 '[[onlinestore:|Wiki]]' => '<a href="/wiki/onlinestore/" class="wiki-page">Wiki</a>',
187 '[[onlinestore:|Wiki]]' => '<a href="/projects/onlinestore/wiki/" class="wiki-page">Wiki</a>',
188 '[[onlinestore:Start page]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Start page</a>',
188 '[[onlinestore:Start page]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Start page</a>',
189 '[[onlinestore:Start page|Text]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Text</a>',
189 '[[onlinestore:Start page|Text]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Text</a>',
190 '[[onlinestore:Unknown page]]' => '<a href="/wiki/onlinestore/Unknown_page" class="wiki-page new">Unknown page</a>',
190 '[[onlinestore:Unknown page]]' => '<a href="/projects/onlinestore/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
191 # striked through link
191 # striked through link
192 '-[[Another page|Page]]-' => '<del><a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a></del>',
192 '-[[Another page|Page]]-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a></del>',
193 '-[[Another page|Page]] link-' => '<del><a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a> link</del>',
193 '-[[Another page|Page]] link-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a> link</del>',
194 # escaping
194 # escaping
195 '![[Another page|Page]]' => '[[Another page|Page]]',
195 '![[Another page|Page]]' => '[[Another page|Page]]',
196 }
196 }
@@ -242,9 +242,9 EXPECTED
242
242
243 def test_wiki_links_in_tables
243 def test_wiki_links_in_tables
244 to_test = {"|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" =>
244 to_test = {"|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" =>
245 '<tr><td><a href="/wiki/ecookbook/Page" class="wiki-page new">Link title</a></td>' +
245 '<tr><td><a href="/projects/ecookbook/wiki/Page" class="wiki-page new">Link title</a></td>' +
246 '<td><a href="/wiki/ecookbook/Other_Page" class="wiki-page new">Other title</a></td>' +
246 '<td><a href="/projects/ecookbook/wiki/Other_Page" class="wiki-page new">Other title</a></td>' +
247 '</tr><tr><td>Cell 21</td><td><a href="/wiki/ecookbook/Last_page" class="wiki-page new">Last page</a></td></tr>'
247 '</tr><tr><td>Cell 21</td><td><a href="/projects/ecookbook/wiki/Last_page" class="wiki-page new">Last page</a></td></tr>'
248 }
248 }
249 @project = Project.find(1)
249 @project = Project.find(1)
250 to_test.each { |text, result| assert_equal "<table>#{result}</table>", textilizable(text).gsub(/[\t\n]/, '') }
250 to_test.each { |text, result| assert_equal "<table>#{result}</table>", textilizable(text).gsub(/[\t\n]/, '') }
@@ -64,8 +64,8 class Redmine::WikiFormatting::MacrosTest < HelperTestCase
64
64
65 def test_macro_child_pages
65 def test_macro_child_pages
66 expected = "<p><ul class=\"pages-hierarchy\">\n" +
66 expected = "<p><ul class=\"pages-hierarchy\">\n" +
67 "<li><a href=\"/wiki/ecookbook/Child_1\">Child 1</a></li>\n" +
67 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" +
68 "<li><a href=\"/wiki/ecookbook/Child_2\">Child 2</a></li>\n" +
68 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
69 "</ul>\n</p>"
69 "</ul>\n</p>"
70
70
71 @project = Project.find(1)
71 @project = Project.find(1)
@@ -80,10 +80,10 class Redmine::WikiFormatting::MacrosTest < HelperTestCase
80
80
81 def test_macro_child_pages_with_option
81 def test_macro_child_pages_with_option
82 expected = "<p><ul class=\"pages-hierarchy\">\n" +
82 expected = "<p><ul class=\"pages-hierarchy\">\n" +
83 "<li><a href=\"/wiki/ecookbook/Another_page\">Another page</a>\n" +
83 "<li><a href=\"/projects/ecookbook/wiki/Another_page\">Another page</a>\n" +
84 "<ul class=\"pages-hierarchy\">\n" +
84 "<ul class=\"pages-hierarchy\">\n" +
85 "<li><a href=\"/wiki/ecookbook/Child_1\">Child 1</a></li>\n" +
85 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" +
86 "<li><a href=\"/wiki/ecookbook/Child_2\">Child 2</a></li>\n" +
86 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
87 "</ul>\n</li>\n</ul>\n</p>"
87 "</ul>\n</li>\n</ul>\n</p>"
88
88
89 @project = Project.find(1)
89 @project = Project.find(1)
@@ -31,12 +31,12 class MailerTest < Test::Unit::TestCase
31 mail = ActionMailer::Base.deliveries.last
31 mail = ActionMailer::Base.deliveries.last
32 assert_kind_of TMail::Mail, mail
32 assert_kind_of TMail::Mail, mail
33 # link to the main ticket
33 # link to the main ticket
34 assert mail.body.include?('<a href="https://mydomain.foo/issues/show/1">Bug #1: Can\'t print recipes</a>')
34 assert mail.body.include?('<a href="https://mydomain.foo/issues/1">Bug #1: Can\'t print recipes</a>')
35
35
36 # link to a referenced ticket
36 # link to a referenced ticket
37 assert mail.body.include?('<a href="https://mydomain.foo/issues/show/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
37 assert mail.body.include?('<a href="https://mydomain.foo/issues/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
38 # link to a changeset
38 # link to a changeset
39 assert mail.body.include?('<a href="https://mydomain.foo/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
39 assert mail.body.include?('<a href="https://mydomain.foo/projects/ecookbook/repository/revisions/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
40 end
40 end
41
41
42 def test_generated_links_with_prefix
42 def test_generated_links_with_prefix
@@ -52,12 +52,12 class MailerTest < Test::Unit::TestCase
52 mail = ActionMailer::Base.deliveries.last
52 mail = ActionMailer::Base.deliveries.last
53 assert_kind_of TMail::Mail, mail
53 assert_kind_of TMail::Mail, mail
54 # link to the main ticket
54 # link to the main ticket
55 assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/show/1">Bug #1: Can\'t print recipes</a>')
55 assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/1">Bug #1: Can\'t print recipes</a>')
56
56
57 # link to a referenced ticket
57 # link to a referenced ticket
58 assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/show/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
58 assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
59 # link to a changeset
59 # link to a changeset
60 assert mail.body.include?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
60 assert mail.body.include?('<a href="http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
61 ensure
61 ensure
62 # restore it
62 # restore it
63 Redmine::Utils.relative_url_root = relative_url_root
63 Redmine::Utils.relative_url_root = relative_url_root
@@ -76,12 +76,12 class MailerTest < Test::Unit::TestCase
76 mail = ActionMailer::Base.deliveries.last
76 mail = ActionMailer::Base.deliveries.last
77 assert_kind_of TMail::Mail, mail
77 assert_kind_of TMail::Mail, mail
78 # link to the main ticket
78 # link to the main ticket
79 assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/show/1">Bug #1: Can\'t print recipes</a>')
79 assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/1">Bug #1: Can\'t print recipes</a>')
80
80
81 # link to a referenced ticket
81 # link to a referenced ticket
82 assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/show/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
82 assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
83 # link to a changeset
83 # link to a changeset
84 assert mail.body.include?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
84 assert mail.body.include?('<a href="http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
85 ensure
85 ensure
86 # restore it
86 # restore it
87 Redmine::Utils.relative_url_root = relative_url_root
87 Redmine::Utils.relative_url_root = relative_url_root
@@ -92,7 +92,7 class MailerTest < Test::Unit::TestCase
92 journal = Journal.find(2)
92 journal = Journal.find(2)
93 Mailer.deliver_issue_edit(journal)
93 Mailer.deliver_issue_edit(journal)
94 mail = ActionMailer::Base.deliveries.last
94 mail = ActionMailer::Base.deliveries.last
95 assert !mail.body.include?('<a href="https://mydomain.foo/issues/show/1">Bug #1: Can\'t print recipes</a>')
95 assert !mail.body.include?('<a href="https://mydomain.foo/issues/1">Bug #1: Can\'t print recipes</a>')
96 end
96 end
97
97
98 def test_issue_add_message_id
98 def test_issue_add_message_id
General Comments 0
You need to be logged in to leave comments. Login now