##// END OF EJS Templates
Refactor: Move the rest of the routing tests to RoutingTest....
Eric Davis -
r3573:9b595c689d06
parent child
Show More
@@ -34,21 +34,6 class AttachmentsControllerTest < ActionController::TestCase
34 User.current = nil
34 User.current = nil
35 end
35 end
36
36
37 def test_routing
38 assert_routing('/attachments/1', :controller => 'attachments', :action => 'show', :id => '1')
39 assert_routing('/attachments/1/filename.ext', :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext')
40 assert_routing('/attachments/download/1', :controller => 'attachments', :action => 'download', :id => '1')
41 assert_routing('/attachments/download/1/filename.ext', :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext')
42 end
43
44 def test_recognizes
45 assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1'}, '/attachments/1')
46 assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1'}, '/attachments/show/1')
47 assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'}, '/attachments/1/filename.ext')
48 assert_recognizes({:controller => 'attachments', :action => 'download', :id => '1'}, '/attachments/download/1')
49 assert_recognizes({:controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'},'/attachments/download/1/filename.ext')
50 end
51
52 def test_show_diff
37 def test_show_diff
53 get :show, :id => 5
38 get :show, :id => 5
54 assert_response :success
39 assert_response :success
@@ -31,13 +31,6 class BoardsControllerTest < ActionController::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_index_routing
35 assert_routing(
36 {:method => :get, :path => '/projects/world_domination/boards'},
37 :controller => 'boards', :action => 'index', :project_id => 'world_domination'
38 )
39 end
40
41 def test_index
34 def test_index
42 get :index, :project_id => 1
35 get :index, :project_id => 1
43 assert_response :success
36 assert_response :success
@@ -60,17 +53,6 class BoardsControllerTest < ActionController::TestCase
60 assert_not_nil assigns(:topics)
53 assert_not_nil assigns(:topics)
61 end
54 end
62
55
63 def test_new_routing
64 assert_routing(
65 {:method => :get, :path => '/projects/world_domination/boards/new'},
66 :controller => 'boards', :action => 'new', :project_id => 'world_domination'
67 )
68 assert_recognizes(
69 {:controller => 'boards', :action => 'new', :project_id => 'world_domination'},
70 {:method => :post, :path => '/projects/world_domination/boards'}
71 )
72 end
73
74 def test_post_new
56 def test_post_new
75 @request.session[:user_id] = 2
57 @request.session[:user_id] = 2
76 assert_difference 'Board.count' do
58 assert_difference 'Board.count' do
@@ -79,17 +61,6 class BoardsControllerTest < ActionController::TestCase
79 assert_redirected_to '/projects/ecookbook/settings/boards'
61 assert_redirected_to '/projects/ecookbook/settings/boards'
80 end
62 end
81
63
82 def test_show_routing
83 assert_routing(
84 {:method => :get, :path => '/projects/world_domination/boards/44'},
85 :controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination'
86 )
87 assert_routing(
88 {:method => :get, :path => '/projects/world_domination/boards/44.atom'},
89 :controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination', :format => 'atom'
90 )
91 end
92
93 def test_show
64 def test_show
94 get :show, :project_id => 1, :id => 1
65 get :show, :project_id => 1, :id => 1
95 assert_response :success
66 assert_response :success
@@ -108,17 +79,6 class BoardsControllerTest < ActionController::TestCase
108 assert_not_nil assigns(:messages)
79 assert_not_nil assigns(:messages)
109 end
80 end
110
81
111 def test_edit_routing
112 assert_routing(
113 {:method => :get, :path => '/projects/world_domination/boards/44/edit'},
114 :controller => 'boards', :action => 'edit', :id => '44', :project_id => 'world_domination'
115 )
116 assert_recognizes(#TODO: use PUT method to board_path, modify form accordingly
117 {:controller => 'boards', :action => 'edit', :id => '44', :project_id => 'world_domination'},
118 {:method => :post, :path => '/projects/world_domination/boards/44/edit'}
119 )
120 end
121
122 def test_post_edit
82 def test_post_edit
123 @request.session[:user_id] = 2
83 @request.session[:user_id] = 2
124 assert_no_difference 'Board.count' do
84 assert_no_difference 'Board.count' do
@@ -128,13 +88,6 class BoardsControllerTest < ActionController::TestCase
128 assert_equal 'Testing', Board.find(2).name
88 assert_equal 'Testing', Board.find(2).name
129 end
89 end
130
90
131 def test_destroy_routing
132 assert_routing(#TODO: use DELETE method to board_path, modify form accoringly
133 {:method => :post, :path => '/projects/world_domination/boards/44/destroy'},
134 :controller => 'boards', :action => 'destroy', :id => '44', :project_id => 'world_domination'
135 )
136 end
137
138 def test_post_destroy
91 def test_post_destroy
139 @request.session[:user_id] = 2
92 @request.session[:user_id] = 2
140 assert_difference 'Board.count', -1 do
93 assert_difference 'Board.count', -1 do
@@ -31,13 +31,6 class DocumentsControllerTest < ActionController::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_index_routing
35 assert_routing(
36 {:method => :get, :path => '/projects/567/documents'},
37 :controller => 'documents', :action => 'index', :project_id => '567'
38 )
39 end
40
41 def test_index
34 def test_index
42 # Sets a default category
35 # Sets a default category
43 e = Enumeration.find_by_name('Technical documentation')
36 e = Enumeration.find_by_name('Technical documentation')
@@ -54,17 +47,6 class DocumentsControllerTest < ActionController::TestCase
54 :content => 'Technical documentation'}
47 :content => 'Technical documentation'}
55 end
48 end
56
49
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
68 def test_new_with_one_attachment
50 def test_new_with_one_attachment
69 ActionMailer::Base.deliveries.clear
51 ActionMailer::Base.deliveries.clear
70 Setting.notified_events << 'document_added'
52 Setting.notified_events << 'document_added'
@@ -87,31 +69,6 class DocumentsControllerTest < ActionController::TestCase
87 assert_equal 1, ActionMailer::Base.deliveries.size
69 assert_equal 1, ActionMailer::Base.deliveries.size
88 end
70 end
89
71
90 def test_edit_routing
91 assert_routing(
92 {:method => :get, :path => '/documents/22/edit'},
93 :controller => 'documents', :action => 'edit', :id => '22'
94 )
95 assert_recognizes(#TODO: should be using PUT on document URI
96 {:controller => 'documents', :action => 'edit', :id => '567'},
97 {:method => :post, :path => '/documents/567/edit'}
98 )
99 end
100
101 def test_show_routing
102 assert_routing(
103 {:method => :get, :path => '/documents/22'},
104 :controller => 'documents', :action => 'show', :id => '22'
105 )
106 end
107
108 def test_destroy_routing
109 assert_recognizes(#TODO: should be using DELETE on document URI
110 {:controller => 'documents', :action => 'destroy', :id => '567'},
111 {:method => :post, :path => '/documents/567/destroy'}
112 )
113 end
114
115 def test_destroy
72 def test_destroy
116 @request.session[:user_id] = 2
73 @request.session[:user_id] = 2
117 post :destroy, :id => 1
74 post :destroy, :id => 1
@@ -32,17 +32,6 class IssueCategoriesControllerTest < ActionController::TestCase
32 @request.session[:user_id] = 2
32 @request.session[:user_id] = 2
33 end
33 end
34
34
35 def test_new_routing
36 assert_routing(
37 {:method => :get, :path => 'projects/test/issue_categories/new'},
38 :controller => 'issue_categories', :action => 'new', :project_id => 'test'
39 )
40 assert_routing(
41 {:method => :post, :path => 'projects/test/issue_categories/new'},
42 :controller => 'issue_categories', :action => 'new', :project_id => 'test'
43 )
44 end
45
46 def test_get_new
35 def test_get_new
47 @request.session[:user_id] = 2 # manager
36 @request.session[:user_id] = 2 # manager
48 get :new, :project_id => '1'
37 get :new, :project_id => '1'
@@ -25,13 +25,6 class IssueRelationsControllerTest < ActionController::TestCase
25 User.current = nil
25 User.current = nil
26 end
26 end
27
27
28 def test_new_routing
29 assert_routing(
30 {:method => :post, :path => '/issues/1/relations'},
31 {:controller => 'issue_relations', :action => 'new', :issue_id => '1'}
32 )
33 end
34
35 def test_new
28 def test_new
36 assert_difference 'IssueRelation.count' do
29 assert_difference 'IssueRelation.count' do
37 @request.session[:user_id] = 3
30 @request.session[:user_id] = 3
@@ -69,13 +62,6 class IssueRelationsControllerTest < ActionController::TestCase
69 end
62 end
70 end
63 end
71
64
72 def test_destroy_routing
73 assert_recognizes( #TODO: use DELETE on issue URI
74 {:controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'},
75 {:method => :post, :path => '/issues/1/relations/23/destroy'}
76 )
77 end
78
79 def test_destroy
65 def test_destroy
80 assert_difference 'IssueRelation.count', -1 do
66 assert_difference 'IssueRelation.count', -1 do
81 @request.session[:user_id] = 3
67 @request.session[:user_id] = 3
@@ -33,13 +33,6 class MembersControllerTest < ActionController::TestCase
33 @request.session[:user_id] = 2
33 @request.session[:user_id] = 2
34 end
34 end
35
35
36 def test_members_routing
37 assert_routing(
38 {:method => :post, :path => 'projects/5234/members/new'},
39 :controller => 'members', :action => 'new', :id => '5234'
40 )
41 end
42
43 def test_create
36 def test_create
44 assert_difference 'Member.count' do
37 assert_difference 'Member.count' do
45 post :new, :id => 1, :member => {:role_ids => [1], :user_id => 7}
38 post :new, :id => 1, :member => {:role_ids => [1], :user_id => 7}
@@ -31,13 +31,6 class MessagesControllerTest < ActionController::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_show_routing
35 assert_routing(
36 {:method => :get, :path => '/boards/22/topics/2'},
37 :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
38 )
39 end
40
41 def test_show
34 def test_show
42 get :show, :board_id => 1, :id => 1
35 get :show, :board_id => 1, :id => 1
43 assert_response :success
36 assert_response :success
@@ -77,17 +70,6 class MessagesControllerTest < ActionController::TestCase
77 assert_response 404
70 assert_response 404
78 end
71 end
79
72
80 def test_new_routing
81 assert_routing(
82 {:method => :get, :path => '/boards/lala/topics/new'},
83 :controller => 'messages', :action => 'new', :board_id => 'lala'
84 )
85 assert_recognizes(#TODO: POST to collection, need to adjust form accordingly
86 {:controller => 'messages', :action => 'new', :board_id => 'lala'},
87 {:method => :post, :path => '/boards/lala/topics/new'}
88 )
89 end
90
91 def test_get_new
73 def test_get_new
92 @request.session[:user_id] = 2
74 @request.session[:user_id] = 2
93 get :new, :board_id => 1
75 get :new, :board_id => 1
@@ -120,17 +102,6 class MessagesControllerTest < ActionController::TestCase
120 assert mail.bcc.include?('dlopper@somenet.foo')
102 assert mail.bcc.include?('dlopper@somenet.foo')
121 end
103 end
122
104
123 def test_edit_routing
124 assert_routing(
125 {:method => :get, :path => '/boards/lala/topics/22/edit'},
126 :controller => 'messages', :action => 'edit', :board_id => 'lala', :id => '22'
127 )
128 assert_recognizes( #TODO: use PUT to topic_path, modify form accordingly
129 {:controller => 'messages', :action => 'edit', :board_id => 'lala', :id => '22'},
130 {:method => :post, :path => '/boards/lala/topics/22/edit'}
131 )
132 end
133
134 def test_get_edit
105 def test_get_edit
135 @request.session[:user_id] = 2
106 @request.session[:user_id] = 2
136 get :edit, :board_id => 1, :id => 1
107 get :edit, :board_id => 1, :id => 1
@@ -149,13 +120,6 class MessagesControllerTest < ActionController::TestCase
149 assert_equal 'New body', message.content
120 assert_equal 'New body', message.content
150 end
121 end
151
122
152 def test_reply_routing
153 assert_recognizes(
154 {:controller => 'messages', :action => 'reply', :board_id => '22', :id => '555'},
155 {:method => :post, :path => '/boards/22/topics/555/replies'}
156 )
157 end
158
159 def test_reply
123 def test_reply
160 @request.session[:user_id] = 2
124 @request.session[:user_id] = 2
161 post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
125 post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
@@ -164,13 +128,6 class MessagesControllerTest < ActionController::TestCase
164 assert Message.find_by_subject('Test reply')
128 assert Message.find_by_subject('Test reply')
165 end
129 end
166
130
167 def test_destroy_routing
168 assert_recognizes(#TODO: use DELETE to topic_path, adjust form accordingly
169 {:controller => 'messages', :action => 'destroy', :board_id => '22', :id => '555'},
170 {:method => :post, :path => '/boards/22/topics/555/destroy'}
171 )
172 end
173
174 def test_destroy_topic
131 def test_destroy_topic
175 @request.session[:user_id] = 2
132 @request.session[:user_id] = 2
176 post :destroy, :board_id => 1, :id => 1
133 post :destroy, :board_id => 1, :id => 1
@@ -31,20 +31,6 class NewsControllerTest < ActionController::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_index_routing
35 assert_routing(
36 {:method => :get, :path => '/news'},
37 :controller => 'news', :action => 'index'
38 )
39 end
40
41 def test_index_routing_formatted
42 assert_routing(
43 {:method => :get, :path => '/news.atom'},
44 :controller => 'news', :action => 'index', :format => 'atom'
45 )
46 end
47
48 def test_index
34 def test_index
49 get :index
35 get :index
50 assert_response :success
36 assert_response :success
@@ -53,20 +39,6 class NewsControllerTest < ActionController::TestCase
53 assert_nil assigns(:project)
39 assert_nil assigns(:project)
54 end
40 end
55
41
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
70 def test_index_with_project
42 def test_index_with_project
71 get :index, :project_id => 1
43 get :index, :project_id => 1
72 assert_response :success
44 assert_response :success
@@ -74,13 +46,6 class NewsControllerTest < ActionController::TestCase
74 assert_not_nil assigns(:newss)
46 assert_not_nil assigns(:newss)
75 end
47 end
76
48
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
84 def test_show
49 def test_show
85 get :show, :id => 1
50 get :show, :id => 1
86 assert_response :success
51 assert_response :success
@@ -93,17 +58,6 class NewsControllerTest < ActionController::TestCase
93 assert_response 404
58 assert_response 404
94 end
59 end
95
60
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
107 def test_get_new
61 def test_get_new
108 @request.session[:user_id] = 2
62 @request.session[:user_id] = 2
109 get :new, :project_id => 1
63 get :new, :project_id => 1
@@ -129,17 +83,6 class NewsControllerTest < ActionController::TestCase
129 assert_equal 1, ActionMailer::Base.deliveries.size
83 assert_equal 1, ActionMailer::Base.deliveries.size
130 end
84 end
131
85
132 def test_edit_routing
133 assert_routing(
134 {:method => :get, :path => '/news/234'},
135 :controller => 'news', :action => 'show', :id => '234'
136 )
137 assert_recognizes(#TODO: PUT to news URI instead, need to modify form
138 {:controller => 'news', :action => 'edit', :id => '567'},
139 {:method => :post, :path => '/news/567/edit'}
140 )
141 end
142
143 def test_get_edit
86 def test_get_edit
144 @request.session[:user_id] = 2
87 @request.session[:user_id] = 2
145 get :edit, :id => 1
88 get :edit, :id => 1
@@ -197,13 +140,6 class NewsControllerTest < ActionController::TestCase
197 assert_equal comments_count - 1, News.find(1).comments.size
140 assert_equal comments_count - 1, News.find(1).comments.size
198 end
141 end
199
142
200 def test_destroy_routing
201 assert_recognizes(#TODO: should use DELETE to news URI, need to change form
202 {:controller => 'news', :action => 'destroy', :id => '567'},
203 {:method => :post, :path => '/news/567/destroy'}
204 )
205 end
206
207 def test_destroy
143 def test_destroy
208 @request.session[:user_id] = 2
144 @request.session[:user_id] = 2
209 post :destroy, :id => 1
145 post :destroy, :id => 1
@@ -34,13 +34,6 class ProjectsControllerTest < ActionController::TestCase
34 Setting.default_language = 'en'
34 Setting.default_language = 'en'
35 end
35 end
36
36
37 def test_index_routing
38 assert_routing(
39 {:method => :get, :path => '/projects'},
40 :controller => 'projects', :action => 'index'
41 )
42 end
43
44 def test_index
37 def test_index
45 get :index
38 get :index
46 assert_response :success
39 assert_response :success
@@ -59,13 +52,6 class ProjectsControllerTest < ActionController::TestCase
59 assert_no_tag :a, :content => /Private child of eCookbook/
52 assert_no_tag :a, :content => /Private child of eCookbook/
60 end
53 end
61
54
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
69 def test_index_atom
55 def test_index_atom
70 get :index, :format => 'atom'
56 get :index, :format => 'atom'
71 assert_response :success
57 assert_response :success
@@ -74,21 +60,6 class ProjectsControllerTest < ActionController::TestCase
74 assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
60 assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
75 end
61 end
76
62
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 context "#add" do
63 context "#add" do
93 context "by admin user" do
64 context "by admin user" do
94 setup do
65 setup do
@@ -248,13 +219,6 class ProjectsControllerTest < ActionController::TestCase
248 end
219 end
249 end
220 end
250
221
251 def test_show_routing
252 assert_routing(
253 {:method => :get, :path => '/projects/test'},
254 :controller => 'projects', :action => 'show', :id => 'test'
255 )
256 end
257
258 def test_show_by_id
222 def test_show_by_id
259 get :show, :id => 1
223 get :show, :id => 1
260 assert_response :success
224 assert_response :success
@@ -295,17 +259,6 class ProjectsControllerTest < ActionController::TestCase
295 assert_tag :tag => 'a', :content => /Private child/
259 assert_tag :tag => 'a', :content => /Private child/
296 end
260 end
297
261
298 def test_settings_routing
299 assert_routing(
300 {:method => :get, :path => '/projects/4223/settings'},
301 :controller => 'projects', :action => 'settings', :id => '4223'
302 )
303 assert_routing(
304 {:method => :get, :path => '/projects/4223/settings/members'},
305 :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
306 )
307 end
308
309 def test_settings
262 def test_settings
310 @request.session[:user_id] = 2 # manager
263 @request.session[:user_id] = 2 # manager
311 get :settings, :id => 1
264 get :settings, :id => 1
@@ -313,13 +266,6 class ProjectsControllerTest < ActionController::TestCase
313 assert_template 'settings'
266 assert_template 'settings'
314 end
267 end
315
268
316 def test_edit_routing
317 assert_routing(
318 {:method => :post, :path => '/projects/4223/edit'},
319 :controller => 'projects', :action => 'edit', :id => '4223'
320 )
321 end
322
323 def test_edit
269 def test_edit
324 @request.session[:user_id] = 2 # manager
270 @request.session[:user_id] = 2 # manager
325 post :edit, :id => 1, :project => {:name => 'Test changed name',
271 post :edit, :id => 1, :project => {:name => 'Test changed name',
@@ -329,18 +275,6 class ProjectsControllerTest < ActionController::TestCase
329 assert_equal 'Test changed name', project.name
275 assert_equal 'Test changed name', project.name
330 end
276 end
331
277
332 def test_destroy_routing
333 assert_routing(
334 {:method => :get, :path => '/projects/567/destroy'},
335 :controller => 'projects', :action => 'destroy', :id => '567'
336 )
337 assert_routing(
338 #TODO: use DELETE and update form
339 {:method => :post, :path => 'projects/64/destroy'},
340 :controller => 'projects', :action => 'destroy', :id => '64'
341 )
342 end
343
344 def test_get_destroy
278 def test_get_destroy
345 @request.session[:user_id] = 1 # admin
279 @request.session[:user_id] = 1 # admin
346 get :destroy, :id => 1
280 get :destroy, :id => 1
@@ -377,17 +311,6 class ProjectsControllerTest < ActionController::TestCase
377 assert mail.body.include?('testfile.txt')
311 assert mail.body.include?('testfile.txt')
378 end
312 end
379
313
380 def test_add_file_routing
381 assert_routing(
382 {:method => :get, :path => '/projects/33/files/new'},
383 :controller => 'projects', :action => 'add_file', :id => '33'
384 )
385 assert_routing(
386 {:method => :post, :path => '/projects/33/files/new'},
387 :controller => 'projects', :action => 'add_file', :id => '33'
388 )
389 end
390
391 def test_add_version_file
314 def test_add_version_file
392 set_tmp_attachments_directory
315 set_tmp_attachments_directory
393 @request.session[:user_id] = 2
316 @request.session[:user_id] = 2
@@ -418,20 +341,6 class ProjectsControllerTest < ActionController::TestCase
418 :attributes => { :href => '/attachments/download/9/version_file.zip' }
341 :attributes => { :href => '/attachments/download/9/version_file.zip' }
419 end
342 end
420
343
421 def test_list_files_routing
422 assert_routing(
423 {:method => :get, :path => '/projects/33/files'},
424 :controller => 'projects', :action => 'list_files', :id => '33'
425 )
426 end
427
428 def test_roadmap_routing
429 assert_routing(
430 {:method => :get, :path => 'projects/33/roadmap'},
431 :controller => 'projects', :action => 'roadmap', :id => '33'
432 )
433 end
434
435 def test_roadmap
344 def test_roadmap
436 get :roadmap, :id => 1
345 get :roadmap, :id => 1
437 assert_response :success
346 assert_response :success
@@ -462,21 +371,6 class ProjectsControllerTest < ActionController::TestCase
462 # Version on subproject appears
371 # Version on subproject appears
463 assert assigns(:versions).include?(Version.find(4))
372 assert assigns(:versions).include?(Version.find(4))
464 end
373 end
465
466 def test_project_activity_routing
467 assert_routing(
468 {:method => :get, :path => '/projects/1/activity'},
469 :controller => 'projects', :action => 'activity', :id => '1'
470 )
471 end
472
473 def test_project_activity_atom_routing
474 assert_routing(
475 {:method => :get, :path => '/projects/1/activity.atom'},
476 :controller => 'projects', :action => 'activity', :id => '1', :format => 'atom'
477 )
478 end
479
480 def test_project_activity
374 def test_project_activity
481 get :activity, :id => 1, :with_subprojects => 0
375 get :activity, :id => 1, :with_subprojects => 0
482 assert_response :success
376 assert_response :success
@@ -513,10 +407,6 class ProjectsControllerTest < ActionController::TestCase
513 }
407 }
514 end
408 end
515
409
516 def test_global_activity_routing
517 assert_routing({:method => :get, :path => '/activity'}, :controller => 'projects', :action => 'activity', :id => nil)
518 end
519
520 def test_global_activity
410 def test_global_activity
521 get :activity
411 get :activity
522 assert_response :success
412 assert_response :success
@@ -553,24 +443,12 class ProjectsControllerTest < ActionController::TestCase
553 }
443 }
554 end
444 end
555
445
556 def test_global_activity_atom_routing
557 assert_routing({:method => :get, :path => '/activity.atom'}, :controller => 'projects', :action => 'activity', :id => nil, :format => 'atom')
558 end
559
560 def test_activity_atom_feed
446 def test_activity_atom_feed
561 get :activity, :format => 'atom'
447 get :activity, :format => 'atom'
562 assert_response :success
448 assert_response :success
563 assert_template 'common/feed.atom.rxml'
449 assert_template 'common/feed.atom.rxml'
564 end
450 end
565
451
566 def test_archive_routing
567 assert_routing(
568 #TODO: use PUT to project path and modify form
569 {:method => :post, :path => 'projects/64/archive'},
570 :controller => 'projects', :action => 'archive', :id => '64'
571 )
572 end
573
574 def test_archive
452 def test_archive
575 @request.session[:user_id] = 1 # admin
453 @request.session[:user_id] = 1 # admin
576 post :archive, :id => 1
454 post :archive, :id => 1
@@ -578,14 +456,6 class ProjectsControllerTest < ActionController::TestCase
578 assert !Project.find(1).active?
456 assert !Project.find(1).active?
579 end
457 end
580
458
581 def test_unarchive_routing
582 assert_routing(
583 #TODO: use PUT to project path and modify form
584 {:method => :post, :path => '/projects/567/unarchive'},
585 :controller => 'projects', :action => 'unarchive', :id => '567'
586 )
587 end
588
589 def test_unarchive
459 def test_unarchive
590 @request.session[:user_id] = 1 # admin
460 @request.session[:user_id] = 1 # admin
591 Project.find(1).archive
461 Project.find(1).archive
@@ -643,11 +513,6 class ProjectsControllerTest < ActionController::TestCase
643 assert_template 'show'
513 assert_template 'show'
644 end
514 end
645
515
646 def test_reset_activities_routing
647 assert_routing({:method => :delete, :path => 'projects/64/reset_activities'},
648 :controller => 'projects', :action => 'reset_activities', :id => '64')
649 end
650
651 def test_reset_activities
516 def test_reset_activities
652 @request.session[:user_id] = 2 # manager
517 @request.session[:user_id] = 2 # manager
653 project_activity = TimeEntryActivity.new({
518 project_activity = TimeEntryActivity.new({
@@ -694,11 +559,6 class ProjectsControllerTest < ActionController::TestCase
694 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "TimeEntries still assigned to project specific activity"
559 assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "TimeEntries still assigned to project specific activity"
695 end
560 end
696
561
697 def test_save_activities_routing
698 assert_routing({:method => :post, :path => 'projects/64/activities/save'},
699 :controller => 'projects', :action => 'save_activities', :id => '64')
700 end
701
702 def test_save_activities_to_override_system_activities
562 def test_save_activities_to_override_system_activities
703 @request.session[:user_id] = 2 # manager
563 @request.session[:user_id] = 2 # manager
704 billable_field = TimeEntryActivityCustomField.find_by_name("Billable")
564 billable_field = TimeEntryActivityCustomField.find_by_name("Billable")
@@ -31,38 +31,6 class RepositoriesControllerTest < ActionController::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_show_routing
35 assert_routing(
36 {:method => :get, :path => '/projects/redmine/repository'},
37 :controller => 'repositories', :action => 'show', :id => 'redmine'
38 )
39 end
40
41 def test_edit_routing
42 assert_routing(
43 {:method => :get, :path => '/projects/world_domination/repository/edit'},
44 :controller => 'repositories', :action => 'edit', :id => 'world_domination'
45 )
46 assert_routing(
47 {:method => :post, :path => '/projects/world_domination/repository/edit'},
48 :controller => 'repositories', :action => 'edit', :id => 'world_domination'
49 )
50 end
51
52 def test_revisions_routing
53 assert_routing(
54 {:method => :get, :path => '/projects/redmine/repository/revisions'},
55 :controller => 'repositories', :action => 'revisions', :id => 'redmine'
56 )
57 end
58
59 def test_revisions_atom_routing
60 assert_routing(
61 {:method => :get, :path => '/projects/redmine/repository/revisions.atom'},
62 :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
63 )
64 end
65
66 def test_revisions
34 def test_revisions
67 get :revisions, :id => 1
35 get :revisions, :id => 1
68 assert_response :success
36 assert_response :success
@@ -70,13 +38,6 class RepositoriesControllerTest < ActionController::TestCase
70 assert_not_nil assigns(:changesets)
38 assert_not_nil assigns(:changesets)
71 end
39 end
72
40
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
80 def test_revision
41 def test_revision
81 get :revision, :id => 1, :rev => 1
42 get :revision, :id => 1, :rev => 1
82 assert_response :success
43 assert_response :success
@@ -96,90 +57,6 class RepositoriesControllerTest < ActionController::TestCase
96 }
57 }
97 end
58 end
98
59
99 def test_diff_routing
100 assert_routing(
101 {:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff'},
102 :controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457'
103 )
104 end
105
106 def test_unified_diff_routing
107 assert_routing(
108 {:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff.diff'},
109 :controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457', :format => 'diff'
110 )
111 end
112
113 def test_diff_path_routing
114 assert_routing(
115 {:method => :get, :path => '/projects/restmine/repository/diff/path/to/file.c'},
116 :controller => 'repositories', :action => 'diff', :id => 'restmine', :path => %w[path to file.c]
117 )
118 end
119
120 def test_diff_path_routing_with_revision
121 assert_routing(
122 {:method => :get, :path => '/projects/restmine/repository/revisions/2/diff/path/to/file.c'},
123 :controller => 'repositories', :action => 'diff', :id => 'restmine', :path => %w[path to file.c], :rev => '2'
124 )
125 end
126
127 def test_browse_routing
128 assert_routing(
129 {:method => :get, :path => '/projects/restmine/repository/browse/path/to/dir'},
130 :controller => 'repositories', :action => 'browse', :id => 'restmine', :path => %w[path to dir]
131 )
132 end
133
134 def test_entry_routing
135 assert_routing(
136 {:method => :get, :path => '/projects/restmine/repository/entry/path/to/file.c'},
137 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c]
138 )
139 end
140
141 def test_entry_routing_with_revision
142 assert_routing(
143 {:method => :get, :path => '/projects/restmine/repository/revisions/2/entry/path/to/file.c'},
144 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c], :rev => '2'
145 )
146 end
147
148 def test_raw_routing
149 assert_routing(
150 {:method => :get, :path => '/projects/restmine/repository/raw/path/to/file.c'},
151 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c], :format => 'raw'
152 )
153 end
154
155 def test_raw_routing_with_revision
156 assert_routing(
157 {:method => :get, :path => '/projects/restmine/repository/revisions/2/raw/path/to/file.c'},
158 :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c], :format => 'raw', :rev => '2'
159 )
160 end
161
162 def test_annotate_routing
163 assert_routing(
164 {:method => :get, :path => '/projects/restmine/repository/annotate/path/to/file.c'},
165 :controller => 'repositories', :action => 'annotate', :id => 'restmine', :path => %w[path to file.c]
166 )
167 end
168
169 def test_changesrouting
170 assert_routing(
171 {:method => :get, :path => '/projects/restmine/repository/changes/path/to/file.c'},
172 :controller => 'repositories', :action => 'changes', :id => 'restmine', :path => %w[path to file.c]
173 )
174 end
175
176 def test_statistics_routing
177 assert_routing(
178 {:method => :get, :path => '/projects/restmine/repository/statistics'},
179 :controller => 'repositories', :action => 'stats', :id => 'restmine'
180 )
181 end
182
183 def test_graph_commits_per_month
60 def test_graph_commits_per_month
184 get :graph, :id => 1, :graph => 'commits_per_month'
61 get :graph, :id => 1, :graph => 'commits_per_month'
185 assert_response :success
62 assert_response :success
@@ -31,28 +31,6 class TimelogControllerTest < ActionController::TestCase
31 @response = ActionController::TestResponse.new
31 @response = ActionController::TestResponse.new
32 end
32 end
33
33
34 def test_edit_routing
35 assert_routing(
36 {:method => :get, :path => '/issues/567/time_entries/new'},
37 :controller => 'timelog', :action => 'edit', :issue_id => '567'
38 )
39 assert_routing(
40 {:method => :get, :path => '/projects/ecookbook/time_entries/new'},
41 :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook'
42 )
43 assert_routing(
44 {:method => :get, :path => '/projects/ecookbook/issues/567/time_entries/new'},
45 :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567'
46 )
47
48 #TODO: change new form to POST to issue_time_entries_path instead of to edit action
49 #TODO: change edit form to PUT to time_entry_path
50 assert_routing(
51 {:method => :get, :path => '/time_entries/22/edit'},
52 :controller => 'timelog', :action => 'edit', :id => '22'
53 )
54 end
55
56 def test_get_edit
34 def test_get_edit
57 @request.session[:user_id] = 3
35 @request.session[:user_id] = 3
58 get :edit, :project_id => 1
36 get :edit, :project_id => 1
@@ -134,14 +112,6 class TimelogControllerTest < ActionController::TestCase
134 assert_equal 2, entry.user_id
112 assert_equal 2, entry.user_id
135 end
113 end
136
114
137 def test_destroy_routing
138 #TODO: use DELETE to time_entry_path
139 assert_routing(
140 {:method => :post, :path => '/time_entries/55/destroy'},
141 :controller => 'timelog', :action => 'destroy', :id => '55'
142 )
143 end
144
145 def test_destroy
115 def test_destroy
146 @request.session[:user_id] = 2
116 @request.session[:user_id] = 2
147 post :destroy, :id => 1
117 post :destroy, :id => 1
@@ -149,30 +119,12 class TimelogControllerTest < ActionController::TestCase
149 assert_nil TimeEntry.find_by_id(1)
119 assert_nil TimeEntry.find_by_id(1)
150 end
120 end
151
121
152 def test_report_routing
153 assert_routing(
154 {:method => :get, :path => '/projects/567/time_entries/report'},
155 :controller => 'timelog', :action => 'report', :project_id => '567'
156 )
157 assert_routing(
158 {:method => :get, :path => '/projects/567/time_entries/report.csv'},
159 :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
160 )
161 end
162
163 def test_report_no_criteria
122 def test_report_no_criteria
164 get :report, :project_id => 1
123 get :report, :project_id => 1
165 assert_response :success
124 assert_response :success
166 assert_template 'report'
125 assert_template 'report'
167 end
126 end
168
127
169 def test_report_routing_for_all_projects
170 assert_routing(
171 {:method => :get, :path => '/time_entries/report'},
172 :controller => 'timelog', :action => 'report'
173 )
174 end
175
176 def test_report_all_projects
128 def test_report_all_projects
177 get :report
129 get :report
178 assert_response :success
130 assert_response :success
@@ -302,13 +254,6 class TimelogControllerTest < ActionController::TestCase
302 assert_equal "162.90", "%.2f" % assigns(:total_hours)
254 assert_equal "162.90", "%.2f" % assigns(:total_hours)
303 end
255 end
304
256
305 def test_project_details_routing
306 assert_routing(
307 {:method => :get, :path => '/projects/567/time_entries'},
308 :controller => 'timelog', :action => 'details', :project_id => '567'
309 )
310 end
311
312 def test_details_at_project_level
257 def test_details_at_project_level
313 get :details, :project_id => 1
258 get :details, :project_id => 1
314 assert_response :success
259 assert_response :success
@@ -354,23 +299,6 class TimelogControllerTest < ActionController::TestCase
354 assert_equal "4.25", "%.2f" % assigns(:total_hours)
299 assert_equal "4.25", "%.2f" % assigns(:total_hours)
355 end
300 end
356
301
357 def test_issue_details_routing
358 assert_routing(
359 {:method => :get, :path => 'time_entries'},
360 :controller => 'timelog', :action => 'details'
361 )
362 assert_routing(
363 {:method => :get, :path => '/issues/234/time_entries'},
364 :controller => 'timelog', :action => 'details', :issue_id => '234'
365 )
366 # TODO: issue detail page shouldnt link to project_issue_time_entries_path but to normal issues one
367 # doesnt seem to have effect on resulting page so controller can be left untouched
368 assert_routing(
369 {:method => :get, :path => '/projects/ecookbook/issues/123/time_entries'},
370 :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123'
371 )
372 end
373
374 def test_details_at_issue_level
302 def test_details_at_issue_level
375 get :details, :issue_id => 1
303 get :details, :issue_id => 1
376 assert_response :success
304 assert_response :success
@@ -384,39 +312,6 class TimelogControllerTest < ActionController::TestCase
384 assert_equal '2007-04-22'.to_date, assigns(:to)
312 assert_equal '2007-04-22'.to_date, assigns(:to)
385 end
313 end
386
314
387 def test_details_formatted_routing
388 assert_routing(
389 {:method => :get, :path => 'time_entries.atom'},
390 :controller => 'timelog', :action => 'details', :format => 'atom'
391 )
392 assert_routing(
393 {:method => :get, :path => 'time_entries.csv'},
394 :controller => 'timelog', :action => 'details', :format => 'csv'
395 )
396 end
397
398 def test_details_for_project_formatted_routing
399 assert_routing(
400 {:method => :get, :path => '/projects/567/time_entries.atom'},
401 :controller => 'timelog', :action => 'details', :format => 'atom', :project_id => '567'
402 )
403 assert_routing(
404 {:method => :get, :path => '/projects/567/time_entries.csv'},
405 :controller => 'timelog', :action => 'details', :format => 'csv', :project_id => '567'
406 )
407 end
408
409 def test_details_for_issue_formatted_routing
410 assert_routing(
411 {:method => :get, :path => '/projects/ecookbook/issues/123/time_entries.atom'},
412 :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123', :format => 'atom'
413 )
414 assert_routing(
415 {:method => :get, :path => '/projects/ecookbook/issues/123/time_entries.csv'},
416 :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123', :format => 'csv'
417 )
418 end
419
420 def test_details_atom_feed
315 def test_details_atom_feed
421 get :details, :project_id => 1, :format => 'atom'
316 get :details, :project_id => 1, :format => 'atom'
422 assert_response :success
317 assert_response :success
@@ -31,14 +31,6 class WikisControllerTest < ActionController::TestCase
31 User.current = nil
31 User.current = nil
32 end
32 end
33
33
34 def test_edit_routing
35 assert_routing(
36 #TODO: use PUT
37 {:method => :post, :path => 'projects/ladida/wiki'},
38 :controller => 'wikis', :action => 'edit', :id => 'ladida'
39 )
40 end
41
42 def test_create
34 def test_create
43 @request.session[:user_id] = 1
35 @request.session[:user_id] = 1
44 assert_nil Project.find(3).wiki
36 assert_nil Project.find(3).wiki
@@ -49,17 +41,6 class WikisControllerTest < ActionController::TestCase
49 assert_equal 'Start page', wiki.start_page
41 assert_equal 'Start page', wiki.start_page
50 end
42 end
51
43
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
63 def test_destroy
44 def test_destroy
64 @request.session[:user_id] = 1
45 @request.session[:user_id] = 1
65 post :destroy, :id => 1, :confirm => 1
46 post :destroy, :id => 1, :confirm => 1
@@ -46,13 +46,6 class IssuesApiTest < ActionController::IntegrationTest
46 Setting.rest_api_enabled = '1'
46 Setting.rest_api_enabled = '1'
47 end
47 end
48
48
49 def test_index_routing
50 assert_routing(
51 {:method => :get, :path => '/issues.xml'},
52 :controller => 'issues', :action => 'index', :format => 'xml'
53 )
54 end
55
56 def test_index
49 def test_index
57 get '/issues.xml'
50 get '/issues.xml'
58 assert_response :success
51 assert_response :success
@@ -68,26 +61,12 class IssuesApiTest < ActionController::IntegrationTest
68 :only => { :tag => 'issue' } }
61 :only => { :tag => 'issue' } }
69 end
62 end
70
63
71 def test_show_routing
72 assert_routing(
73 {:method => :get, :path => '/issues/1.xml'},
74 :controller => 'issues', :action => 'show', :id => '1', :format => 'xml'
75 )
76 end
77
78 def test_show
64 def test_show
79 get '/issues/1.xml'
65 get '/issues/1.xml'
80 assert_response :success
66 assert_response :success
81 assert_equal 'application/xml', @response.content_type
67 assert_equal 'application/xml', @response.content_type
82 end
68 end
83
69
84 def test_create_routing
85 assert_routing(
86 {:method => :post, :path => '/issues.xml'},
87 :controller => 'issues', :action => 'new', :format => 'xml'
88 )
89 end
90
91 def test_create
70 def test_create
92 attributes = {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}
71 attributes = {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}
93 assert_difference 'Issue.count' do
72 assert_difference 'Issue.count' do
@@ -111,13 +90,6 class IssuesApiTest < ActionController::IntegrationTest
111 assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
90 assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
112 end
91 end
113
92
114 def test_update_routing
115 assert_routing(
116 {:method => :put, :path => '/issues/1.xml'},
117 :controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
118 )
119 end
120
121 def test_update
93 def test_update
122 attributes = {:subject => 'API update'}
94 attributes = {:subject => 'API update'}
123 assert_no_difference 'Issue.count' do
95 assert_no_difference 'Issue.count' do
@@ -145,13 +117,6 class IssuesApiTest < ActionController::IntegrationTest
145 assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
117 assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
146 end
118 end
147
119
148 def test_destroy_routing
149 assert_routing(
150 {:method => :delete, :path => '/issues/1.xml'},
151 :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml'
152 )
153 end
154
155 def test_destroy
120 def test_destroy
156 assert_difference 'Issue.count', -1 do
121 assert_difference 'Issue.count', -1 do
157 delete '/issues/1.xml', {}, :authorization => credentials('jsmith')
122 delete '/issues/1.xml', {}, :authorization => credentials('jsmith')
@@ -26,39 +26,18 class ProjectsApiTest < ActionController::IntegrationTest
26 Setting.rest_api_enabled = '1'
26 Setting.rest_api_enabled = '1'
27 end
27 end
28
28
29 def test_index_routing
30 assert_routing(
31 {:method => :get, :path => '/projects.xml'},
32 :controller => 'projects', :action => 'index', :format => 'xml'
33 )
34 end
35
36 def test_index
29 def test_index
37 get '/projects.xml'
30 get '/projects.xml'
38 assert_response :success
31 assert_response :success
39 assert_equal 'application/xml', @response.content_type
32 assert_equal 'application/xml', @response.content_type
40 end
33 end
41
34
42 def test_show_routing
43 assert_routing(
44 {:method => :get, :path => '/projects/1.xml'},
45 :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
46 )
47 end
48
49 def test_show
35 def test_show
50 get '/projects/1.xml'
36 get '/projects/1.xml'
51 assert_response :success
37 assert_response :success
52 assert_equal 'application/xml', @response.content_type
38 assert_equal 'application/xml', @response.content_type
53 end
39 end
54
40
55 def test_create_routing
56 assert_routing(
57 {:method => :post, :path => '/projects.xml'},
58 :controller => 'projects', :action => 'add', :format => 'xml'
59 )
60 end
61
62 def test_create
41 def test_create
63 attributes = {:name => 'API test', :identifier => 'api-test'}
42 attributes = {:name => 'API test', :identifier => 'api-test'}
64 assert_difference 'Project.count' do
43 assert_difference 'Project.count' do
@@ -82,13 +61,6 class ProjectsApiTest < ActionController::IntegrationTest
82 assert_tag :errors, :child => {:tag => 'error', :content => "Identifier can't be blank"}
61 assert_tag :errors, :child => {:tag => 'error', :content => "Identifier can't be blank"}
83 end
62 end
84
63
85 def test_update_routing
86 assert_routing(
87 {:method => :put, :path => '/projects/1.xml'},
88 :controller => 'projects', :action => 'edit', :id => '1', :format => 'xml'
89 )
90 end
91
92 def test_update
64 def test_update
93 attributes = {:name => 'API update'}
65 attributes = {:name => 'API update'}
94 assert_no_difference 'Project.count' do
66 assert_no_difference 'Project.count' do
@@ -112,13 +84,6 class ProjectsApiTest < ActionController::IntegrationTest
112 assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"}
84 assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"}
113 end
85 end
114
86
115 def test_destroy_routing
116 assert_routing(
117 {:method => :delete, :path => '/projects/1.xml'},
118 :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
119 )
120 end
121
122 def test_destroy
87 def test_destroy
123 assert_difference 'Project.count', -1 do
88 assert_difference 'Project.count', -1 do
124 delete '/projects/2.xml', {}, :authorization => credentials('admin')
89 delete '/projects/2.xml', {}, :authorization => credentials('admin')
@@ -18,6 +18,42
18 require "#{File.dirname(__FILE__)}/../test_helper"
18 require "#{File.dirname(__FILE__)}/../test_helper"
19
19
20 class RoutingTest < ActionController::IntegrationTest
20 class RoutingTest < ActionController::IntegrationTest
21 context "activities" do
22 should_route :get, "/activity", :controller => 'projects', :action => 'activity', :id => nil
23 should_route :get, "/activity.atom", :controller => 'projects', :action => 'activity', :id => nil, :format => 'atom'
24 end
25
26 context "attachments" do
27 should_route :get, "/attachments/1", :controller => 'attachments', :action => 'show', :id => '1'
28 should_route :get, "/attachments/1/filename.ext", :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'
29 should_route :get, "/attachments/download/1", :controller => 'attachments', :action => 'download', :id => '1'
30 should_route :get, "/attachments/download/1/filename.ext", :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'
31 end
32
33 context "boards" do
34 should_route :get, "/projects/world_domination/boards", :controller => 'boards', :action => 'index', :project_id => 'world_domination'
35 should_route :get, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
36 should_route :get, "/projects/world_domination/boards/44", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44'
37 should_route :get, "/projects/world_domination/boards/44.atom", :controller => 'boards', :action => 'show', :project_id => 'world_domination', :id => '44', :format => 'atom'
38 should_route :get, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
39
40 should_route :post, "/projects/world_domination/boards/new", :controller => 'boards', :action => 'new', :project_id => 'world_domination'
41 should_route :post, "/projects/world_domination/boards/44/edit", :controller => 'boards', :action => 'edit', :project_id => 'world_domination', :id => '44'
42 should_route :post, "/projects/world_domination/boards/44/destroy", :controller => 'boards', :action => 'destroy', :project_id => 'world_domination', :id => '44'
43
44 end
45
46 context "documents" do
47 should_route :get, "/projects/567/documents", :controller => 'documents', :action => 'index', :project_id => '567'
48 should_route :get, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
49 should_route :get, "/documents/22", :controller => 'documents', :action => 'show', :id => '22'
50 should_route :get, "/documents/22/edit", :controller => 'documents', :action => 'edit', :id => '22'
51
52 should_route :post, "/projects/567/documents/new", :controller => 'documents', :action => 'new', :project_id => '567'
53 should_route :post, "/documents/567/edit", :controller => 'documents', :action => 'edit', :id => '567'
54 should_route :post, "/documents/567/destroy", :controller => 'documents', :action => 'destroy', :id => '567'
55 end
56
21 context "issues" do
57 context "issues" do
22 # REST actions
58 # REST actions
23 should_route :get, "/issues", :controller => 'issues', :action => 'index'
59 should_route :get, "/issues", :controller => 'issues', :action => 'index'
@@ -34,13 +70,16 class RoutingTest < ActionController::IntegrationTest
34 should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml'
70 should_route :get, "/issues/64.xml", :controller => 'issues', :action => 'show', :id => '64', :format => 'xml'
35
71
36 should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23'
72 should_route :get, "/projects/23/issues/new", :controller => 'issues', :action => 'new', :project_id => '23'
73 should_route :post, "/issues.xml", :controller => 'issues', :action => 'new', :format => 'xml'
37
74
38 should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
75 should_route :get, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
39 # TODO: Should use PUT
76 # TODO: Should use PUT
40 should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
77 should_route :post, "/issues/64/edit", :controller => 'issues', :action => 'edit', :id => '64'
78 should_route :put, "/issues/1.xml", :controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
41
79
42 # TODO: Should use DELETE
80 # TODO: Should use DELETE
43 should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64'
81 should_route :post, "/issues/64/destroy", :controller => 'issues', :action => 'destroy', :id => '64'
82 should_route :delete, "/issues/1.xml", :controller => 'issues', :action => 'destroy', :id => '1', :format => 'xml'
44
83
45 # Extra actions
84 # Extra actions
46 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
85 should_route :get, "/projects/23/issues/64/copy", :controller => 'issues', :action => 'new', :project_id => '23', :copy_from => '64'
@@ -62,12 +101,132 class RoutingTest < ActionController::IntegrationTest
62
101
63 should_route :get, "/issues/auto_complete", :controller => 'issues', :action => 'auto_complete'
102 should_route :get, "/issues/auto_complete", :controller => 'issues', :action => 'auto_complete'
64 end
103 end
104
105 context "issue categories" do
106 should_route :get, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
107
108 should_route :post, "/projects/test/issue_categories/new", :controller => 'issue_categories', :action => 'new', :project_id => 'test'
109 end
110
111 context "issue relations" do
112 should_route :post, "/issues/1/relations", :controller => 'issue_relations', :action => 'new', :issue_id => '1'
113 should_route :post, "/issues/1/relations/23/destroy", :controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'
114 end
65
115
66 context "issue reports" do
116 context "issue reports" do
67 should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
117 should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
68 should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
118 should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
69 end
119 end
70
120
121 context "members" do
122 should_route :post, "/projects/5234/members/new", :controller => 'members', :action => 'new', :id => '5234'
123 end
124
125 context "messages" do
126 should_route :get, "/boards/22/topics/2", :controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
127 should_route :get, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
128 should_route :get, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
129
130 should_route :post, "/boards/lala/topics/new", :controller => 'messages', :action => 'new', :board_id => 'lala'
131 should_route :post, "/boards/lala/topics/22/edit", :controller => 'messages', :action => 'edit', :id => '22', :board_id => 'lala'
132 should_route :post, "/boards/22/topics/555/replies", :controller => 'messages', :action => 'reply', :id => '555', :board_id => '22'
133 should_route :post, "/boards/22/topics/555/destroy", :controller => 'messages', :action => 'destroy', :id => '555', :board_id => '22'
134 end
135
136 context "news" do
137 should_route :get, "/news", :controller => 'news', :action => 'index'
138 should_route :get, "/news.atom", :controller => 'news', :action => 'index', :format => 'atom'
139 should_route :get, "/news.xml", :controller => 'news', :action => 'index', :format => 'xml'
140 should_route :get, "/news.json", :controller => 'news', :action => 'index', :format => 'json'
141 should_route :get, "/projects/567/news", :controller => 'news', :action => 'index', :project_id => '567'
142 should_route :get, "/projects/567/news.atom", :controller => 'news', :action => 'index', :format => 'atom', :project_id => '567'
143 should_route :get, "/projects/567/news.xml", :controller => 'news', :action => 'index', :format => 'xml', :project_id => '567'
144 should_route :get, "/projects/567/news.json", :controller => 'news', :action => 'index', :format => 'json', :project_id => '567'
145 should_route :get, "/news/2", :controller => 'news', :action => 'show', :id => '2'
146 should_route :get, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
147 should_route :get, "/news/234", :controller => 'news', :action => 'show', :id => '234'
148
149 should_route :post, "/projects/567/news/new", :controller => 'news', :action => 'new', :project_id => '567'
150 should_route :post, "/news/567/edit", :controller => 'news', :action => 'edit', :id => '567'
151 should_route :post, "/news/567/destroy", :controller => 'news', :action => 'destroy', :id => '567'
152 end
153
154 context "projects" do
155 should_route :get, "/projects", :controller => 'projects', :action => 'index'
156 should_route :get, "/projects.atom", :controller => 'projects', :action => 'index', :format => 'atom'
157 should_route :get, "/projects.xml", :controller => 'projects', :action => 'index', :format => 'xml'
158 should_route :get, "/projects/new", :controller => 'projects', :action => 'add'
159 should_route :get, "/projects/test", :controller => 'projects', :action => 'show', :id => 'test'
160 should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml'
161 should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223'
162 should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
163 should_route :get, "/projects/567/destroy", :controller => 'projects', :action => 'destroy', :id => '567'
164 should_route :get, "/projects/33/files", :controller => 'projects', :action => 'list_files', :id => '33'
165 should_route :get, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33'
166 should_route :get, "/projects/33/roadmap", :controller => 'projects', :action => 'roadmap', :id => '33'
167 should_route :get, "/projects/33/activity", :controller => 'projects', :action => 'activity', :id => '33'
168 should_route :get, "/projects/33/activity.atom", :controller => 'projects', :action => 'activity', :id => '33', :format => 'atom'
169
170 should_route :post, "/projects/new", :controller => 'projects', :action => 'add'
171 should_route :post, "/projects.xml", :controller => 'projects', :action => 'add', :format => 'xml'
172 should_route :post, "/projects/4223/edit", :controller => 'projects', :action => 'edit', :id => '4223'
173 should_route :post, "/projects/64/destroy", :controller => 'projects', :action => 'destroy', :id => '64'
174 should_route :post, "/projects/33/files/new", :controller => 'projects', :action => 'add_file', :id => '33'
175 should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64'
176 should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64'
177 should_route :post, "/projects/64/activities/save", :controller => 'projects', :action => 'save_activities', :id => '64'
178
179 should_route :put, "/projects/1.xml", :controller => 'projects', :action => 'edit', :id => '1', :format => 'xml'
180
181 should_route :delete, "/projects/1.xml", :controller => 'projects', :action => 'destroy', :id => '1', :format => 'xml'
182 should_route :delete, "/projects/64/reset_activities", :controller => 'projects', :action => 'reset_activities', :id => '64'
183 end
184
185 context "repositories" do
186 should_route :get, "/projects/redmine/repository", :controller => 'repositories', :action => 'show', :id => 'redmine'
187 should_route :get, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
188 should_route :get, "/projects/redmine/repository/revisions", :controller => 'repositories', :action => 'revisions', :id => 'redmine'
189 should_route :get, "/projects/redmine/repository/revisions.atom", :controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
190 should_route :get, "/projects/redmine/repository/revisions/2457", :controller => 'repositories', :action => 'revision', :id => 'redmine', :rev => '2457'
191 should_route :get, "/projects/redmine/repository/revisions/2457/diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457'
192 should_route :get, "/projects/redmine/repository/revisions/2457/diff.diff", :controller => 'repositories', :action => 'diff', :id => 'redmine', :rev => '2457', :format => 'diff'
193 should_route :get, "/projects/redmine/repository/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c]
194 should_route :get, "/projects/redmine/repository/revisions/2/diff/path/to/file.c", :controller => 'repositories', :action => 'diff', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
195 should_route :get, "/projects/redmine/repository/browse/path/to/file.c", :controller => 'repositories', :action => 'browse', :id => 'redmine', :path => %w[path to file.c]
196 should_route :get, "/projects/redmine/repository/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c]
197 should_route :get, "/projects/redmine/repository/revisions/2/entry/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2'
198 should_route :get, "/projects/redmine/repository/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :format => 'raw'
199 should_route :get, "/projects/redmine/repository/revisions/2/raw/path/to/file.c", :controller => 'repositories', :action => 'entry', :id => 'redmine', :path => %w[path to file.c], :rev => '2', :format => 'raw'
200 should_route :get, "/projects/redmine/repository/annotate/path/to/file.c", :controller => 'repositories', :action => 'annotate', :id => 'redmine', :path => %w[path to file.c]
201 should_route :get, "/projects/redmine/repository/changes/path/to/file.c", :controller => 'repositories', :action => 'changes', :id => 'redmine', :path => %w[path to file.c]
202 should_route :get, "/projects/redmine/repository/statistics", :controller => 'repositories', :action => 'stats', :id => 'redmine'
203
204
205 should_route :post, "/projects/redmine/repository/edit", :controller => 'repositories', :action => 'edit', :id => 'redmine'
206 end
207
208 context "timelogs" do
209 should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :issue_id => '567'
210 should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook'
211 should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567'
212 should_route :get, "/time_entries/22/edit", :controller => 'timelog', :action => 'edit', :id => '22'
213 should_route :get, "/time_entries/report", :controller => 'timelog', :action => 'report'
214 should_route :get, "/projects/567/time_entries/report", :controller => 'timelog', :action => 'report', :project_id => '567'
215 should_route :get, "/projects/567/time_entries/report.csv", :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
216 should_route :get, "/time_entries", :controller => 'timelog', :action => 'details'
217 should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'details', :format => 'csv'
218 should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'details', :format => 'atom'
219 should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'details', :project_id => '567'
220 should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'csv'
221 should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'atom'
222 should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'details', :issue_id => '234'
223 should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'csv'
224 should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'atom'
225 should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123'
226
227 should_route :post, "/time_entries/55/destroy", :controller => 'timelog', :action => 'destroy', :id => '55'
228 end
229
71 context "users" do
230 context "users" do
72 should_route :get, "/users", :controller => 'users', :action => 'index'
231 should_route :get, "/users", :controller => 'users', :action => 'index'
73 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
232 should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
@@ -88,7 +247,7 class RoutingTest < ActionController::IntegrationTest
88 should_route :post, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
247 should_route :post, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
89 end
248 end
90
249
91 context "wikis" do
250 context "wiki (singular, project's pages)" do
92 should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567'
251 should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567'
93 should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
252 should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
94 should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
253 should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
@@ -108,6 +267,13 class RoutingTest < ActionController::IntegrationTest
108 should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'
267 should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'
109 end
268 end
110
269
270 context "wikis (plural, admin setup)" do
271 should_route :get, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
272
273 should_route :post, "/projects/ladida/wiki", :controller => 'wikis', :action => 'edit', :id => 'ladida'
274 should_route :post, "/projects/ladida/wiki/destroy", :controller => 'wikis', :action => 'destroy', :id => 'ladida'
275 end
276
111 context "administration panel" do
277 context "administration panel" do
112 should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects'
278 should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects'
113 end
279 end
General Comments 0
You need to be logged in to leave comments. Login now