##// END OF EJS Templates
test: route: split news tests...
Toshi MARUYAMA -
r8427:c5f41baa945f
parent child
Show More
@@ -1,89 +1,92
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../../test_helper', __FILE__)
18 require File.expand_path('../../../test_helper', __FILE__)
19
19
20 class RoutingNewsTest < ActionController::IntegrationTest
20 class RoutingNewsTest < ActionController::IntegrationTest
21 def test_news
21 def test_news_index
22 assert_routing(
22 assert_routing(
23 { :method => 'get', :path => "/news" },
23 { :method => 'get', :path => "/news" },
24 { :controller => 'news', :action => 'index' }
24 { :controller => 'news', :action => 'index' }
25 )
25 )
26 assert_routing(
26 assert_routing(
27 { :method => 'get', :path => "/news.atom" },
27 { :method => 'get', :path => "/news.atom" },
28 { :controller => 'news', :action => 'index', :format => 'atom' }
28 { :controller => 'news', :action => 'index', :format => 'atom' }
29 )
29 )
30 assert_routing(
30 assert_routing(
31 { :method => 'get', :path => "/news.xml" },
31 { :method => 'get', :path => "/news.xml" },
32 { :controller => 'news', :action => 'index', :format => 'xml' }
32 { :controller => 'news', :action => 'index', :format => 'xml' }
33 )
33 )
34 assert_routing(
34 assert_routing(
35 { :method => 'get', :path => "/news.json" },
35 { :method => 'get', :path => "/news.json" },
36 { :controller => 'news', :action => 'index', :format => 'json' }
36 { :controller => 'news', :action => 'index', :format => 'json' }
37 )
37 )
38 end
39
40 def test_news
38 assert_routing(
41 assert_routing(
39 { :method => 'get', :path => "/news/2" },
42 { :method => 'get', :path => "/news/2" },
40 { :controller => 'news', :action => 'show', :id => '2' }
43 { :controller => 'news', :action => 'show', :id => '2' }
41 )
44 )
42 assert_routing(
45 assert_routing(
43 { :method => 'get', :path => "/news/234" },
46 { :method => 'get', :path => "/news/234" },
44 { :controller => 'news', :action => 'show', :id => '234' }
47 { :controller => 'news', :action => 'show', :id => '234' }
45 )
48 )
46 assert_routing(
49 assert_routing(
47 { :method => 'get', :path => "/news/567/edit" },
50 { :method => 'get', :path => "/news/567/edit" },
48 { :controller => 'news', :action => 'edit', :id => '567' }
51 { :controller => 'news', :action => 'edit', :id => '567' }
49 )
52 )
50 assert_routing(
53 assert_routing(
51 { :method => 'put', :path => "/news/567" },
54 { :method => 'put', :path => "/news/567" },
52 { :controller => 'news', :action => 'update', :id => '567' }
55 { :controller => 'news', :action => 'update', :id => '567' }
53 )
56 )
54 assert_routing(
57 assert_routing(
55 { :method => 'delete', :path => "/news/567" },
58 { :method => 'delete', :path => "/news/567" },
56 { :controller => 'news', :action => 'destroy', :id => '567' }
59 { :controller => 'news', :action => 'destroy', :id => '567' }
57 )
60 )
58 end
61 end
59
62
60 def test_news_scoped_under_project
63 def test_news_scoped_under_project
61 assert_routing(
64 assert_routing(
62 { :method => 'get', :path => "/projects/567/news" },
65 { :method => 'get', :path => "/projects/567/news" },
63 { :controller => 'news', :action => 'index', :project_id => '567' }
66 { :controller => 'news', :action => 'index', :project_id => '567' }
64 )
67 )
65 assert_routing(
68 assert_routing(
66 { :method => 'get', :path => "/projects/567/news.atom" },
69 { :method => 'get', :path => "/projects/567/news.atom" },
67 { :controller => 'news', :action => 'index', :format => 'atom',
70 { :controller => 'news', :action => 'index', :format => 'atom',
68 :project_id => '567' }
71 :project_id => '567' }
69 )
72 )
70 assert_routing(
73 assert_routing(
71 { :method => 'get', :path => "/projects/567/news.xml" },
74 { :method => 'get', :path => "/projects/567/news.xml" },
72 { :controller => 'news', :action => 'index', :format => 'xml',
75 { :controller => 'news', :action => 'index', :format => 'xml',
73 :project_id => '567' }
76 :project_id => '567' }
74 )
77 )
75 assert_routing(
78 assert_routing(
76 { :method => 'get', :path => "/projects/567/news.json" },
79 { :method => 'get', :path => "/projects/567/news.json" },
77 { :controller => 'news', :action => 'index', :format => 'json',
80 { :controller => 'news', :action => 'index', :format => 'json',
78 :project_id => '567' }
81 :project_id => '567' }
79 )
82 )
80 assert_routing(
83 assert_routing(
81 { :method => 'get', :path => "/projects/567/news/new" },
84 { :method => 'get', :path => "/projects/567/news/new" },
82 { :controller => 'news', :action => 'new', :project_id => '567' }
85 { :controller => 'news', :action => 'new', :project_id => '567' }
83 )
86 )
84 assert_routing(
87 assert_routing(
85 { :method => 'post', :path => "/projects/567/news" },
88 { :method => 'post', :path => "/projects/567/news" },
86 { :controller => 'news', :action => 'create', :project_id => '567' }
89 { :controller => 'news', :action => 'create', :project_id => '567' }
87 )
90 )
88 end
91 end
89 end
92 end
General Comments 0
You need to be logged in to leave comments. Login now