##// 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,28 +243,23 module ApplicationHelper
243 243 url_param.clear if url_param.has_key?(:set_filter)
244 244
245 245 html = ''
246 html << link_to_remote(('&#171; ' + l(:label_previous)),
247 {:update => 'content',
248 :url => url_param.merge(page_param => paginator.current.previous),
249 :complete => 'window.scrollTo(0,0)'},
250 {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
246 if paginator.current.previous
247 html << link_to_remote_content_update('&#171; ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' '
248 end
251 249
252 250 html << (pagination_links_each(paginator, options) do |n|
253 link_to_remote(n.to_s,
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))})
251 link_to_remote_content_update(n.to_s, url_param.merge(page_param => n))
258 252 end || '')
259 253
260 html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
261 {:update => 'content',
262 :url => url_param.merge(page_param => paginator.current.next),
263 :complete => 'window.scrollTo(0,0)'},
264 {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next
254 if paginator.current.next
255 html << ' ' + link_to_remote_content_update((l(:label_next) + ' &#187;'), url_param.merge(page_param => paginator.current.next))
256 end
265 257
266 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 263 end
269 264
270 265 html
@@ -275,7 +270,9 module ApplicationHelper
275 270 url_param.clear if url_param.has_key?(:set_filter)
276 271
277 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 276 {:href => url_for(url_param.merge(:per_page => n))})
280 277 end
281 278 links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
@@ -664,4 +661,12 module ApplicationHelper
664 661 extend helper
665 662 return self
666 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 672 end
@@ -121,7 +121,7 module SortHelper
121 121 url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
122 122
123 123 link_to_remote(caption,
124 {:update => "content", :url => url_options},
124 {:update => "content", :url => url_options, :method => :get},
125 125 {:href => url_for(url_options)}) +
126 126 (icon ? nbsp(2) + image_tag(icon) : '')
127 127 end
@@ -26,7 +26,7
26 26 <% end %>
27 27
28 28 <% content_for :sidebar do %>
29 <% form_tag do %>
29 <% form_tag({},:method => :get) do %>
30 30 <h3><%= l(:label_change_log) %></h3>
31 31 <% @trackers.each do |tracker| %>
32 32 <label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
@@ -6,7 +6,9
6 6
7 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 12 <%= hidden_field_tag 'project_id', params[:project_id] %>
11 13 <%= hidden_field_tag 'issue_id', params[:issue_id] if @issue %>
12 14 <%= render :partial => 'date_range' %>
@@ -6,10 +6,11
6 6
7 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 10 <% @criterias.each do |criteria| %>
11 11 <%= hidden_field_tag 'criterias[]', criteria, :id => nil %>
12 12 <% end %>
13 <%# TODO: get rid of the project_id field, that should already be in the URL %>
13 14 <%= hidden_field_tag 'project_id', params[:project_id] %>
14 15 <%= render :partial => 'date_range' %>
15 16
@@ -25,6 +26,7
25 26 :id => nil,
26 27 :disabled => (@criterias.length >= 3)) %>
27 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 30 :update => 'content'
29 31 }, :class => 'icon icon-reload' %></p>
30 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 2 <%= render :partial => 'form', :locals => { :f => f } %>
3 3 <%= submit_tag l(:button_save) %>
4 4 <% end %>
@@ -12,40 +12,242 ActionController::Routing::Routes.draw do |map|
12 12 end
13 13
14 14 map.home '', :controller => 'welcome'
15
15 16 map.signin 'login', :controller => 'account', :action => 'login'
16 17 map.signout 'logout', :controller => 'account', :action => 'logout'
17 18
18 map.connect 'wiki/:id/:page/:action', :controller => 'wiki', :page => nil
19 19 map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
20 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 230 map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
25 map.connect 'projects/:project_id/news/:action', :controller => 'news'
26 231 map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
27 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 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 238 map.with_options :controller => 'repositories' do |omap|
32 239 omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
33 240 omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
34 241 omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
35 242 omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
36 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 245 end
39 246
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
44 247 # Allow downloading Web Service WSDL as a file with an extension
45 248 # instead of a file named 'wsdl'
46 249 map.connect ':controller/service.wsdl', :action => 'wsdl'
47 250
48
49 251 # Install the default route as the lowest priority.
50 252 map.connect ':controller/:action/:id'
51 253 end
@@ -38,6 +38,13 class AdminControllerTest < Test::Unit::TestCase
38 38 :attributes => { :class => /nodata/ }
39 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 48 def test_index_with_no_configuration_data
42 49 delete_configuration_data
43 50 get :index
@@ -31,6 +31,13 class BoardsControllerTest < Test::Unit::TestCase
31 31 User.current = nil
32 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 41 def test_index
35 42 get :index, :project_id => 1
36 43 assert_response :success
@@ -39,6 +46,24 class BoardsControllerTest < Test::Unit::TestCase
39 46 assert_not_nil assigns(:project)
40 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 67 def test_show
43 68 get :show, :project_id => 1, :id => 1
44 69 assert_response :success
@@ -47,4 +72,22 class BoardsControllerTest < Test::Unit::TestCase
47 72 assert_not_nil assigns(:project)
48 73 assert_not_nil assigns(:topics)
49 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 93 end
@@ -31,6 +31,13 class DocumentsControllerTest < Test::Unit::TestCase
31 31 User.current = nil
32 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 41 def test_index
35 42 # Sets a default category
36 43 e = Enumeration.find_by_name('Technical documentation')
@@ -47,6 +54,17 class DocumentsControllerTest < Test::Unit::TestCase
47 54 :content => 'Technical documentation'}
48 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 68 def test_new_with_one_attachment
51 69 @request.session[:user_id] = 2
52 70 set_tmp_attachments_directory
@@ -66,6 +84,31 class DocumentsControllerTest < Test::Unit::TestCase
66 84 assert_equal 'testfile.txt', document.attachments.first.filename
67 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 112 def test_destroy
70 113 @request.session[:user_id] = 2
71 114 post :destroy, :id => 1
@@ -50,6 +50,13 class IssuesControllerTest < Test::Unit::TestCase
50 50 User.current = nil
51 51 end
52 52
53 def test_index_routing
54 assert_routing(
55 {:method => :get, :path => '/issues'},
56 :controller => 'issues', :action => 'index'
57 )
58 end
59
53 60 def test_index
54 61 get :index
55 62 assert_response :success
@@ -74,6 +81,31 class IssuesControllerTest < Test::Unit::TestCase
74 81 assert_tag :tag => 'a', :content => /Subproject issue/
75 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 109 def test_index_with_project
78 110 Setting.display_subprojects_issues = 0
79 111 get :index, :project_id => 1
@@ -107,6 +139,17 class IssuesControllerTest < Test::Unit::TestCase
107 139 assert_tag :tag => 'a', :content => /Issue of a private subproject/
108 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 153 def test_index_with_project_and_filter
111 154 get :index, :project_id => 1, :set_filter => 1
112 155 assert_response :success
@@ -126,6 +169,17 class IssuesControllerTest < Test::Unit::TestCase
126 169 assert_equal 'text/csv', @response.content_type
127 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 183 def test_index_pdf
130 184 get :index, :format => 'pdf'
131 185 assert_response :success
@@ -221,6 +275,24 class IssuesControllerTest < Test::Unit::TestCase
221 275 assert_equal 'application/atom+xml', @response.content_type
222 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 296 def test_show_by_anonymous
225 297 get :show, :id => 1
226 298 assert_response :success
@@ -252,6 +324,17 class IssuesControllerTest < Test::Unit::TestCase
252 324 :content => /Notes/ } }
253 325 end
254 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
337
255 338 def test_show_export_to_pdf
256 339 get :show, :id => 3, :format => 'pdf'
257 340 assert_response :success
@@ -301,7 +384,7 class IssuesControllerTest < Test::Unit::TestCase
301 384 :priority_id => 5,
302 385 :estimated_hours => '',
303 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 389 issue = Issue.find_by_subject('This is the test_new issue')
307 390 assert_not_nil issue
@@ -330,7 +413,7 class IssuesControllerTest < Test::Unit::TestCase
330 413 :subject => 'This is the test_new issue',
331 414 :description => 'This is the description',
332 415 :priority_id => 5}
333 assert_redirected_to :controller => 'issues', :action => 'show'
416 assert_redirected_to :action => 'show'
334 417 end
335 418
336 419 def test_post_new_with_required_custom_field_and_without_custom_fields_param
@@ -402,6 +485,13 class IssuesControllerTest < Test::Unit::TestCase
402 485 :value => 'Value for field 2'}
403 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 495 def test_copy_issue
406 496 @request.session[:user_id] = 2
407 497 get :new, :project_id => 1, :copy_from => 1
@@ -411,6 +501,17 class IssuesControllerTest < Test::Unit::TestCase
411 501 assert_equal orig.subject, assigns(:issue).subject
412 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 515 def test_get_edit
415 516 @request.session[:user_id] = 2
416 517 get :edit, :id => 1
@@ -442,6 +543,13 class IssuesControllerTest < Test::Unit::TestCase
442 543 :attributes => { :selected => 'selected' } }
443 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 553 def test_reply_to_issue
446 554 @request.session[:user_id] = 2
447 555 get :reply, :id => 1
@@ -473,7 +581,7 class IssuesControllerTest < Test::Unit::TestCase
473 581 }
474 582 end
475 583 end
476 assert_redirected_to 'issues/show/1'
584 assert_redirected_to :action => 'show', :id => '1'
477 585 issue.reload
478 586 assert_equal new_subject, issue.subject
479 587 # Make sure custom fields were not cleared
@@ -499,7 +607,7 class IssuesControllerTest < Test::Unit::TestCase
499 607 }
500 608 end
501 609 end
502 assert_redirected_to 'issues/show/1'
610 assert_redirected_to :action => 'show', :id => '1'
503 611 issue.reload
504 612 assert_equal 'New custom value', issue.custom_value_for(2).value
505 613
@@ -519,7 +627,7 class IssuesControllerTest < Test::Unit::TestCase
519 627 :notes => 'Assigned to dlopper',
520 628 :time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
521 629 end
522 assert_redirected_to 'issues/show/1'
630 assert_redirected_to :action => 'show', :id => '1'
523 631 issue.reload
524 632 assert_equal 2, issue.status_id
525 633 j = issue.journals.find(:first, :order => 'id DESC')
@@ -536,7 +644,7 class IssuesControllerTest < Test::Unit::TestCase
536 644 post :edit,
537 645 :id => 1,
538 646 :notes => notes
539 assert_redirected_to 'issues/show/1'
647 assert_redirected_to :action => 'show', :id => '1'
540 648 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
541 649 assert_equal notes, j.notes
542 650 assert_equal 0, j.details.size
@@ -555,7 +663,7 class IssuesControllerTest < Test::Unit::TestCase
555 663 :notes => '2.5 hours added',
556 664 :time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
557 665 end
558 assert_redirected_to 'issues/show/1'
666 assert_redirected_to :action => 'show', :id => '1'
559 667
560 668 issue = Issue.find(1)
561 669
@@ -581,7 +689,7 class IssuesControllerTest < Test::Unit::TestCase
581 689 :id => 1,
582 690 :notes => '',
583 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 693 j = Issue.find(1).journals.find(:first, :order => 'id DESC')
586 694 assert j.notes.blank?
587 695 assert_equal 1, j.details.size
@@ -600,7 +708,7 class IssuesControllerTest < Test::Unit::TestCase
600 708 post :edit,
601 709 :id => 1,
602 710 :notes => ''
603 assert_redirected_to 'issues/show/1'
711 assert_redirected_to :action => 'show', :id => '1'
604 712
605 713 issue.reload
606 714 assert issue.journals.empty?
@@ -671,17 +779,28 class IssuesControllerTest < Test::Unit::TestCase
671 779 assert_nil Issue.find(2).assigned_to
672 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 793 def test_move_one_issue_to_another_project
675 794 @request.session[:user_id] = 1
676 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 797 assert_equal 2, Issue.find(1).project_id
679 798 end
680 799
681 800 def test_bulk_move_to_another_project
682 801 @request.session[:user_id] = 1
683 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 804 # Issues moved to project 2
686 805 assert_equal 2, Issue.find(1).project_id
687 806 assert_equal 2, Issue.find(2).project_id
@@ -693,7 +812,7 class IssuesControllerTest < Test::Unit::TestCase
693 812 def test_bulk_move_to_another_tracker
694 813 @request.session[:user_id] = 1
695 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 816 assert_equal 2, Issue.find(1).tracker_id
698 817 assert_equal 2, Issue.find(2).tracker_id
699 818 end
@@ -714,10 +833,10 class IssuesControllerTest < Test::Unit::TestCase
714 833 assert_response :success
715 834 assert_template 'context_menu'
716 835 assert_tag :tag => 'a', :content => 'Edit',
717 :attributes => { :href => '/issues/edit/1',
836 :attributes => { :href => '/issues/1/edit',
718 837 :class => 'icon-edit' }
719 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 840 :class => '' }
722 841 assert_tag :tag => 'a', :content => 'Immediate',
723 842 :attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;priority_id=8',
@@ -726,7 +845,7 class IssuesControllerTest < Test::Unit::TestCase
726 845 :attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&amp;ids%5B%5D=1',
727 846 :class => '' }
728 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 849 :class => 'icon-copy' }
731 850 assert_tag :tag => 'a', :content => 'Move',
732 851 :attributes => { :href => '/issues/move?ids%5B%5D=1',
@@ -777,11 +896,18 class IssuesControllerTest < Test::Unit::TestCase
777 896 :class => 'icon-del disabled' }
778 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 906 def test_destroy_issue_with_no_time_entries
781 907 assert_nil TimeEntry.find_by_issue_id(2)
782 908 @request.session[:user_id] = 2
783 909 post :destroy, :id => 2
784 assert_redirected_to 'projects/ecookbook/issues'
910 assert_redirected_to :action => 'index', :project_id => 'ecookbook'
785 911 assert_nil Issue.find_by_id(2)
786 912 end
787 913
@@ -797,7 +923,7 class IssuesControllerTest < Test::Unit::TestCase
797 923 def test_destroy_issues_and_destroy_time_entries
798 924 @request.session[:user_id] = 2
799 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 927 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
802 928 assert_nil TimeEntry.find_by_id([1, 2])
803 929 end
@@ -805,7 +931,7 class IssuesControllerTest < Test::Unit::TestCase
805 931 def test_destroy_issues_and_assign_time_entries_to_project
806 932 @request.session[:user_id] = 2
807 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 935 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
810 936 assert_nil TimeEntry.find(1).issue_id
811 937 assert_nil TimeEntry.find(2).issue_id
@@ -814,7 +940,7 class IssuesControllerTest < Test::Unit::TestCase
814 940 def test_destroy_issues_and_reassign_time_entries_to_another_issue
815 941 @request.session[:user_id] = 2
816 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 944 assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
819 945 assert_equal 2, TimeEntry.find(1).issue_id
820 946 assert_equal 2, TimeEntry.find(2).issue_id
@@ -31,6 +31,13 class MessagesControllerTest < Test::Unit::TestCase
31 31 User.current = nil
32 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 41 def test_show
35 42 get :show, :board_id => 1, :id => 1
36 43 assert_response :success
@@ -54,6 +61,17 class MessagesControllerTest < Test::Unit::TestCase
54 61 assert_response 404
55 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 75 def test_get_new
58 76 @request.session[:user_id] = 2
59 77 get :new, :board_id => 1
@@ -86,6 +104,17 class MessagesControllerTest < Test::Unit::TestCase
86 104 assert mail.bcc.include?('dlopper@somenet.foo')
87 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 118 def test_get_edit
90 119 @request.session[:user_id] = 2
91 120 get :edit, :board_id => 1, :id => 1
@@ -104,6 +133,13 class MessagesControllerTest < Test::Unit::TestCase
104 133 assert_equal 'New body', message.content
105 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 143 def test_reply
108 144 @request.session[:user_id] = 2
109 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 147 assert Message.find_by_subject('Test reply')
112 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 157 def test_destroy_topic
115 158 @request.session[:user_id] = 2
116 159 post :destroy, :board_id => 1, :id => 1
@@ -31,6 +31,20 class NewsControllerTest < Test::Unit::TestCase
31 31 User.current = nil
32 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 48 def test_index
35 49 get :index
36 50 assert_response :success
@@ -39,6 +53,20 class NewsControllerTest < Test::Unit::TestCase
39 53 assert_nil assigns(:project)
40 54 end
41 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
69
42 70 def test_index_with_project
43 71 get :index, :project_id => 1
44 72 assert_response :success
@@ -46,6 +74,13 class NewsControllerTest < Test::Unit::TestCase
46 74 assert_not_nil assigns(:newss)
47 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 84 def test_show
50 85 get :show, :id => 1
51 86 assert_response :success
@@ -58,6 +93,17 class NewsControllerTest < Test::Unit::TestCase
58 93 assert_response 404
59 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 107 def test_get_new
62 108 @request.session[:user_id] = 2
63 109 get :new, :project_id => 1
@@ -79,6 +125,17 class NewsControllerTest < Test::Unit::TestCase
79 125 assert_equal Project.find(1), news.project
80 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 139 def test_get_edit
83 140 @request.session[:user_id] = 2
84 141 get :edit, :id => 1
@@ -127,6 +184,13 class NewsControllerTest < Test::Unit::TestCase
127 184 assert_equal comments_count - 1, News.find(1).comments.size
128 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 194 def test_destroy
131 195 @request.session[:user_id] = 2
132 196 post :destroy, :id => 1
@@ -34,6 +34,13 class ProjectsControllerTest < Test::Unit::TestCase
34 34 Setting.default_language = 'en'
35 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 44 def test_index
38 45 get :index
39 46 assert_response :success
@@ -52,6 +59,13 class ProjectsControllerTest < Test::Unit::TestCase
52 59 assert_no_tag :a, :content => /Private child of eCookbook/
53 60 end
54 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
68
55 69 def test_index_atom
56 70 get :index, :format => 'atom'
57 71 assert_response :success
@@ -60,6 +74,28 class ProjectsControllerTest < Test::Unit::TestCase
60 74 assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
61 75 end
62 76
77 def test_add_routing
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
63 99 def test_show_by_id
64 100 get :show, :id => 1
65 101 assert_response :success
@@ -90,6 +126,17 class ProjectsControllerTest < Test::Unit::TestCase
90 126 assert_tag :tag => 'a', :content => /Private child/
91 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 140 def test_settings
94 141 @request.session[:user_id] = 2 # manager
95 142 get :settings, :id => 1
@@ -106,6 +153,42 class ProjectsControllerTest < Test::Unit::TestCase
106 153 assert_equal 'Test changed name', project.name
107 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 192 def test_get_destroy
110 193 @request.session[:user_id] = 1 # admin
111 194 get :destroy, :id => 1
@@ -142,6 +225,17 class ProjectsControllerTest < Test::Unit::TestCase
142 225 assert mail.body.include?('testfile.txt')
143 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 239 def test_add_version_file
146 240 set_tmp_attachments_directory
147 241 @request.session[:user_id] = 2
@@ -172,6 +266,20 class ProjectsControllerTest < Test::Unit::TestCase
172 266 :attributes => { :href => '/attachments/download/9/version_file.zip' }
173 267 end
174 268
269 def test_list_files_routing
270 assert_routing(
271 {:method => :get, :path => '/projects/33/files'},
272 :controller => 'projects', :action => 'list_files', :id => '33'
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
175 283 def test_changelog
176 284 get :changelog, :id => 1
177 285 assert_response :success
@@ -179,6 +287,13 class ProjectsControllerTest < Test::Unit::TestCase
179 287 assert_not_nil assigns(:versions)
180 288 end
181 289
290 def test_roadmap_routing
291 assert_routing(
292 {:method => :get, :path => 'projects/33/roadmap'},
293 :controller => 'projects', :action => 'roadmap', :id => '33'
294 )
295 end
296
182 297 def test_roadmap
183 298 get :roadmap, :id => 1
184 299 assert_response :success
@@ -201,6 +316,20 class ProjectsControllerTest < Test::Unit::TestCase
201 316 assert assigns(:versions).include?(Version.find(1))
202 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 333 def test_project_activity
205 334 get :activity, :id => 1, :with_subprojects => 0
206 335 assert_response :success
@@ -237,6 +366,10 class ProjectsControllerTest < Test::Unit::TestCase
237 366 }
238 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 373 def test_global_activity
241 374 get :activity
242 375 assert_response :success
@@ -273,12 +406,24 class ProjectsControllerTest < Test::Unit::TestCase
273 406 }
274 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 413 def test_activity_atom_feed
277 414 get :activity, :format => 'atom'
278 415 assert_response :success
279 416 assert_template 'common/feed.atom.rxml'
280 417 end
281 418
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
282 427 def test_archive
283 428 @request.session[:user_id] = 1 # admin
284 429 post :archive, :id => 1
@@ -286,6 +431,14 class ProjectsControllerTest < Test::Unit::TestCase
286 431 assert !Project.find(1).active?
287 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 442 def test_unarchive
290 443 @request.session[:user_id] = 1 # admin
291 444 Project.find(1).archive
@@ -31,6 +31,38 class RepositoriesControllerTest < Test::Unit::TestCase
31 31 User.current = nil
32 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 66 def test_revisions
35 67 get :revisions, :id => 1
36 68 assert_response :success
@@ -38,18 +70,95 class RepositoriesControllerTest < Test::Unit::TestCase
38 70 assert_not_nil assigns(:changesets)
39 71 end
40 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
79
41 80 def test_revision_with_before_nil_and_afer_normal
42 81 get :revision, {:id => 1, :rev => 1}
43 82 assert_response :success
44 83 assert_template 'revision'
45 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 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 90 end
52 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
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 162 def test_graph_commits_per_month
54 163 get :graph, :id => 1, :graph => 'commits_per_month'
55 164 assert_response :success
@@ -131,11 +131,11 class RepositoriesSubversionControllerTest < Test::Unit::TestCase
131 131 :child => { :tag => 'li',
132 132 # link to the entry at rev 2
133 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 135 :content => 'repo',
136 136 # link to partial diff
137 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 153 :child => { :tag => 'li',
154 154 # link to the entry at rev 2
155 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 157 :content => 'repo',
158 158 # link to partial diff
159 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 30 @response = ActionController::TestResponse.new
31 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 55 def test_get_edit
34 56 @request.session[:user_id] = 3
35 57 get :edit, :project_id => 1
@@ -41,6 +63,8 class TimelogControllerTest < Test::Unit::TestCase
41 63 end
42 64
43 65 def test_post_edit
66 # TODO: should POST to issues’ time log instead of project. change form
67 # and routing
44 68 @request.session[:user_id] = 3
45 69 post :edit, :project_id => 1,
46 70 :time_entry => {:comments => 'Some work on TimelogControllerTest',
@@ -49,7 +73,7 class TimelogControllerTest < Test::Unit::TestCase
49 73 :spent_on => '2008-03-14',
50 74 :issue_id => '1',
51 75 :hours => '7.3'}
52 assert_redirected_to 'projects/ecookbook/timelog/details'
76 assert_redirected_to :action => 'details', :project_id => 'ecookbook'
53 77
54 78 i = Issue.find(1)
55 79 t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
@@ -70,7 +94,7 class TimelogControllerTest < Test::Unit::TestCase
70 94 post :edit, :id => 1,
71 95 :time_entry => {:issue_id => '2',
72 96 :hours => '8'}
73 assert_redirected_to 'projects/ecookbook/timelog/details'
97 assert_redirected_to :action => 'details', :project_id => 'ecookbook'
74 98 entry.reload
75 99
76 100 assert_equal 8, entry.hours
@@ -78,19 +102,45 class TimelogControllerTest < Test::Unit::TestCase
78 102 assert_equal 2, entry.user_id
79 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 113 def test_destroy
82 114 @request.session[:user_id] = 2
83 115 post :destroy, :id => 1
84 assert_redirected_to 'projects/ecookbook/timelog/details'
116 assert_redirected_to :action => 'details', :project_id => 'ecookbook'
85 117 assert_nil TimeEntry.find_by_id(1)
86 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 131 def test_report_no_criteria
89 132 get :report, :project_id => 1
90 133 assert_response :success
91 134 assert_template 'report'
92 135 end
93 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
143
94 144 def test_report_all_projects
95 145 get :report
96 146 assert_response :success
@@ -103,7 +153,7 class TimelogControllerTest < Test::Unit::TestCase
103 153 r.permissions_will_change!
104 154 r.save
105 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 157 end
108 158
109 159 def test_report_all_projects_one_criteria
@@ -202,6 +252,13 class TimelogControllerTest < Test::Unit::TestCase
202 252 assert_equal "162.90", "%.2f" % assigns(:total_hours)
203 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 262 def test_details_at_project_level
206 263 get :details, :project_id => 1
207 264 assert_response :success
@@ -239,6 +296,23 class TimelogControllerTest < Test::Unit::TestCase
239 296 assert_equal Date.today, assigns(:to)
240 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 316 def test_details_at_issue_level
243 317 get :details, :issue_id => 1
244 318 assert_response :success
@@ -252,6 +326,39 class TimelogControllerTest < Test::Unit::TestCase
252 326 assert_equal '2007-04-22'.to_date, assigns(:to)
253 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 362 def test_details_atom_feed
256 363 get :details, :project_id => 1, :format => 'atom'
257 364 assert_response :success
@@ -32,12 +32,28 class UsersControllerTest < Test::Unit::TestCase
32 32 @request.session[:user_id] = 1 # admin
33 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 43 def test_index
36 44 get :index
37 45 assert_response :success
38 46 assert_template 'list'
39 47 end
40 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
56
41 57 def test_list
42 58 get :list
43 59 assert_response :success
@@ -57,16 +73,70 class UsersControllerTest < Test::Unit::TestCase
57 73 assert_equal 'John', users.first.firstname
58 74 end
59 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
121
60 122 def test_edit_membership
61 123 post :edit_membership, :id => 2, :membership_id => 1,
62 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 126 assert_equal 2, Member.find(1).role_id
65 127 end
66 128
67 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 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 140 assert_nil Member.find_by_id(1)
71 141 end
72 142 end
@@ -52,7 +52,7 class VersionsControllerTest < Test::Unit::TestCase
52 52 post :edit, :id => 2,
53 53 :version => { :name => 'New version name',
54 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 56 version = Version.find(2)
57 57 assert_equal 'New version name', version.name
58 58 assert_equal Date.today, version.effective_date
@@ -61,7 +61,7 class VersionsControllerTest < Test::Unit::TestCase
61 61 def test_destroy
62 62 @request.session[:user_id] = 2
63 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 65 assert_nil Version.find_by_id(3)
66 66 end
67 67
@@ -31,6 +31,21 class WikiControllerTest < Test::Unit::TestCase
31 31 User.current = nil
32 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 49 def test_show_start_page
35 50 get :index, :id => 'ecookbook'
36 51 assert_response :success
@@ -40,7 +55,7 class WikiControllerTest < Test::Unit::TestCase
40 55 # child_pages macro
41 56 assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
42 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 59 :content => 'Page with an inline image' } }
45 60 end
46 61
@@ -67,6 +82,17 class WikiControllerTest < Test::Unit::TestCase
67 82 assert_template 'edit'
68 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 96 def test_create_page
71 97 @request.session[:user_id] = 2
72 98 post :edit, :id => 1,
@@ -74,13 +100,20 class WikiControllerTest < Test::Unit::TestCase
74 100 :content => {:comments => 'Created the page',
75 101 :text => "h1. New page\n\nThis is a new page",
76 102 :version => 0}
77 assert_redirected_to 'wiki/ecookbook/New_page'
103 assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'New_page'
78 104 page = Project.find(1).wiki.find_page('New page')
79 105 assert !page.new_record?
80 106 assert_not_nil page.content
81 107 assert_equal 'Created the page', page.content.comments
82 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 117 def test_preview
85 118 @request.session[:user_id] = 2
86 119 xhr :post, :preview, :id => 1, :page => 'CookBook_documentation',
@@ -103,6 +136,13 class WikiControllerTest < Test::Unit::TestCase
103 136 assert_tag :tag => 'h1', :content => /New page/
104 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 146 def test_history
107 147 get :history, :id => 1, :page => 'CookBook_documentation'
108 148 assert_response :success
@@ -121,6 +161,13 class WikiControllerTest < Test::Unit::TestCase
121 161 assert_select "input[type=submit][name=commit]", false
122 162 end
123 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
170
124 171 def test_diff
125 172 get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
126 173 assert_response :success
@@ -129,6 +176,13 class WikiControllerTest < Test::Unit::TestCase
129 176 :content => /updated/
130 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 186 def test_annotate
133 187 get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2
134 188 assert_response :success
@@ -143,12 +197,24 class WikiControllerTest < Test::Unit::TestCase
143 197 :child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
144 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 212 def test_rename_with_redirect
147 213 @request.session[:user_id] = 2
148 214 post :rename, :id => 1, :page => 'Another_page',
149 215 :wiki_page => { :title => 'Another renamed page',
150 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 218 wiki = Project.find(1).wiki
153 219 # Check redirects
154 220 assert_not_nil wiki.find_page('Another page')
@@ -160,16 +226,43 class WikiControllerTest < Test::Unit::TestCase
160 226 post :rename, :id => 1, :page => 'Another_page',
161 227 :wiki_page => { :title => 'Another renamed page',
162 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 230 wiki = Project.find(1).wiki
165 231 # Check that there's no redirects
166 232 assert_nil wiki.find_page('Another page')
167 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 243 def test_destroy
170 244 @request.session[:user_id] = 2
171 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 266 end
174 267
175 268 def test_page_index
@@ -181,13 +274,13 class WikiControllerTest < Test::Unit::TestCase
181 274 assert_equal Project.find(1).wiki.pages.size, pages.size
182 275
183 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 278 :content => 'CookBook documentation' },
186 279 :child => { :tag => 'ul',
187 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 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 284 :content => 'Another page' } }
192 285 end
193 286
@@ -196,12 +289,19 class WikiControllerTest < Test::Unit::TestCase
196 289 assert_response 404
197 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 299 def test_protect_page
200 300 page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
201 301 assert !page.protected?
202 302 @request.session[:user_id] = 2
203 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 305 assert page.reload.protected?
206 306 end
207 307
@@ -210,7 +310,7 class WikiControllerTest < Test::Unit::TestCase
210 310 assert page.protected?
211 311 @request.session[:user_id] = 2
212 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 314 assert !page.reload.protected?
215 315 end
216 316
@@ -219,7 +319,7 class WikiControllerTest < Test::Unit::TestCase
219 319 get :index, :id => 1
220 320 assert_response :success
221 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 323 end
224 324
225 325 def test_show_page_without_edit_link
@@ -227,7 +327,7 class WikiControllerTest < Test::Unit::TestCase
227 327 get :index, :id => 1
228 328 assert_response :success
229 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 331 end
232 332
233 333 def test_edit_unprotected_page
@@ -31,6 +31,14 class WikisControllerTest < Test::Unit::TestCase
31 31 User.current = nil
32 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 42 def test_create
35 43 @request.session[:user_id] = 1
36 44 assert_nil Project.find(3).wiki
@@ -41,10 +49,21 class WikisControllerTest < Test::Unit::TestCase
41 49 assert_equal 'Start page', wiki.start_page
42 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 63 def test_destroy
45 64 @request.session[:user_id] = 1
46 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 67 assert_nil Project.find(1).wiki
49 68 end
50 69
@@ -42,10 +42,10 class AdminTest < ActionController::IntegrationTest
42 42
43 43 def test_add_project
44 44 log_user("admin", "admin")
45 get "projects/add"
45 get "projects/new"
46 46 assert_response :success
47 47 assert_template "projects/add"
48 post "projects/add", :project => { :name => "blog",
48 post "projects", :project => { :name => "blog",
49 49 :description => "weblog",
50 50 :identifier => "blog",
51 51 :is_public => 1,
@@ -39,7 +39,7 class IssuesTest < ActionController::IntegrationTest
39 39 assert_response :success
40 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 43 :issue => { :start_date => "2006-12-26",
44 44 :priority_id => "3",
45 45 :subject => "new test issue",
@@ -54,7 +54,7 class IssuesTest < ActionController::IntegrationTest
54 54 assert_kind_of Issue, issue
55 55
56 56 # check redirection
57 assert_redirected_to "issues/show"
57 assert_redirected_to :controller => 'issues', :action => 'show'
58 58 follow_redirect!
59 59 assert_equal issue, assigns(:issue)
60 60
@@ -69,10 +69,10 class IssuesTest < ActionController::IntegrationTest
69 69 log_user('jsmith', 'jsmith')
70 70 set_tmp_attachments_directory
71 71
72 post 'issues/edit/1',
72 post 'issues/1/edit',
73 73 :notes => 'Some notes',
74 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 77 # make sure attachment was saved
78 78 attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
@@ -30,15 +30,15 class ProjectsTest < ActionController::IntegrationTest
30 30 assert_redirected_to "admin/projects"
31 31 assert !Project.find(1).active?
32 32
33 get "projects/show", :id => 1
33 get 'projects/1'
34 34 assert_response 403
35 get "projects/show", :id => subproject.id
35 get "projects/#{subproject.id}"
36 36 assert_response 403
37 37
38 38 post "projects/unarchive", :id => 1
39 39 assert_redirected_to "admin/projects"
40 40 assert Project.find(1).active?
41 get "projects/show", :id => 1
41 get "projects/1"
42 42 assert_response :success
43 43 end
44 44 end
@@ -174,23 +174,23 class ApplicationHelperTest < HelperTestCase
174 174
175 175 def test_wiki_links
176 176 to_test = {
177 '[[CookBook documentation]]' => '<a href="/wiki/ecookbook/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
178 '[[Another page|Page]]' => '<a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a>',
177 '[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
178 '[[Another page|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a>',
179 179 # link with anchor
180 '[[CookBook documentation#One-section]]' => '<a href="/wiki/ecookbook/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>',
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="/projects/ecookbook/wiki/Another_page#anchor" class="wiki-page">Page</a>',
182 182 # page that doesn't exist
183 '[[Unknown page]]' => '<a href="/wiki/ecookbook/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>',
183 '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
184 '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">404</a>',
185 185 # link to another project wiki
186 '[[onlinestore:]]' => '<a href="/wiki/onlinestore/" class="wiki-page">onlinestore</a>',
187 '[[onlinestore:|Wiki]]' => '<a href="/wiki/onlinestore/" class="wiki-page">Wiki</a>',
188 '[[onlinestore:Start page]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Start page</a>',
189 '[[onlinestore:Start page|Text]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Text</a>',
190 '[[onlinestore:Unknown page]]' => '<a href="/wiki/onlinestore/Unknown_page" class="wiki-page new">Unknown page</a>',
186 '[[onlinestore:]]' => '<a href="/projects/onlinestore/wiki/" class="wiki-page">onlinestore</a>',
187 '[[onlinestore:|Wiki]]' => '<a href="/projects/onlinestore/wiki/" class="wiki-page">Wiki</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="/projects/onlinestore/wiki/Start_page" class="wiki-page">Text</a>',
190 '[[onlinestore:Unknown page]]' => '<a href="/projects/onlinestore/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
191 191 # striked through link
192 '-[[Another page|Page]]-' => '<del><a href="/wiki/ecookbook/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>',
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="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a> link</del>',
194 194 # escaping
195 195 '![[Another page|Page]]' => '[[Another page|Page]]',
196 196 }
@@ -242,9 +242,9 EXPECTED
242 242
243 243 def test_wiki_links_in_tables
244 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>' +
246 '<td><a href="/wiki/ecookbook/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>'
245 '<tr><td><a href="/projects/ecookbook/wiki/Page" class="wiki-page new">Link 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="/projects/ecookbook/wiki/Last_page" class="wiki-page new">Last page</a></td></tr>'
248 248 }
249 249 @project = Project.find(1)
250 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 65 def test_macro_child_pages
66 66 expected = "<p><ul class=\"pages-hierarchy\">\n" +
67 "<li><a href=\"/wiki/ecookbook/Child_1\">Child 1</a></li>\n" +
68 "<li><a href=\"/wiki/ecookbook/Child_2\">Child 2</a></li>\n" +
67 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" +
68 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
69 69 "</ul>\n</p>"
70 70
71 71 @project = Project.find(1)
@@ -80,10 +80,10 class Redmine::WikiFormatting::MacrosTest < HelperTestCase
80 80
81 81 def test_macro_child_pages_with_option
82 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 84 "<ul class=\"pages-hierarchy\">\n" +
85 "<li><a href=\"/wiki/ecookbook/Child_1\">Child 1</a></li>\n" +
86 "<li><a href=\"/wiki/ecookbook/Child_2\">Child 2</a></li>\n" +
85 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" +
86 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
87 87 "</ul>\n</li>\n</ul>\n</p>"
88 88
89 89 @project = Project.find(1)
@@ -31,12 +31,12 class MailerTest < Test::Unit::TestCase
31 31 mail = ActionMailer::Base.deliveries.last
32 32 assert_kind_of TMail::Mail, mail
33 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 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 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 40 end
41 41
42 42 def test_generated_links_with_prefix
@@ -52,12 +52,12 class MailerTest < Test::Unit::TestCase
52 52 mail = ActionMailer::Base.deliveries.last
53 53 assert_kind_of TMail::Mail, mail
54 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 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 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 61 ensure
62 62 # restore it
63 63 Redmine::Utils.relative_url_root = relative_url_root
@@ -76,12 +76,12 class MailerTest < Test::Unit::TestCase
76 76 mail = ActionMailer::Base.deliveries.last
77 77 assert_kind_of TMail::Mail, mail
78 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 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 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 85 ensure
86 86 # restore it
87 87 Redmine::Utils.relative_url_root = relative_url_root
@@ -92,7 +92,7 class MailerTest < Test::Unit::TestCase
92 92 journal = Journal.find(2)
93 93 Mailer.deliver_issue_edit(journal)
94 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 96 end
97 97
98 98 def test_issue_add_message_id
General Comments 0
You need to be logged in to leave comments. Login now