##// END OF EJS Templates
test: route: split news tests whether scoped under project or not...
Toshi MARUYAMA -
r8312:1b252d68f3da
parent child
Show More
@@ -1,86 +1,89
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
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 assert_routing(
38 assert_routing(
39 { :method => 'get', :path => "/news/2" },
40 { :controller => 'news', :action => 'show', :id => '2' }
41 )
42 assert_routing(
43 { :method => 'get', :path => "/news/234" },
44 { :controller => 'news', :action => 'show', :id => '234' }
45 )
46 assert_routing(
47 { :method => 'get', :path => "/news/567/edit" },
48 { :controller => 'news', :action => 'edit', :id => '567' }
49 )
50 assert_routing(
51 { :method => 'put', :path => "/news/567" },
52 { :controller => 'news', :action => 'update', :id => '567' }
53 )
54 assert_routing(
55 { :method => 'delete', :path => "/news/567" },
56 { :controller => 'news', :action => 'destroy', :id => '567' }
57 )
58 end
59
60 def test_news_scoped_under_project
61 assert_routing(
39 { :method => 'get', :path => "/projects/567/news" },
62 { :method => 'get', :path => "/projects/567/news" },
40 { :controller => 'news', :action => 'index', :project_id => '567' }
63 { :controller => 'news', :action => 'index', :project_id => '567' }
41 )
64 )
42 assert_routing(
65 assert_routing(
43 { :method => 'get', :path => "/projects/567/news.atom" },
66 { :method => 'get', :path => "/projects/567/news.atom" },
44 { :controller => 'news', :action => 'index', :format => 'atom',
67 { :controller => 'news', :action => 'index', :format => 'atom',
45 :project_id => '567' }
68 :project_id => '567' }
46 )
69 )
47 assert_routing(
70 assert_routing(
48 { :method => 'get', :path => "/projects/567/news.xml" },
71 { :method => 'get', :path => "/projects/567/news.xml" },
49 { :controller => 'news', :action => 'index', :format => 'xml',
72 { :controller => 'news', :action => 'index', :format => 'xml',
50 :project_id => '567' }
73 :project_id => '567' }
51 )
74 )
52 assert_routing(
75 assert_routing(
53 { :method => 'get', :path => "/projects/567/news.json" },
76 { :method => 'get', :path => "/projects/567/news.json" },
54 { :controller => 'news', :action => 'index', :format => 'json',
77 { :controller => 'news', :action => 'index', :format => 'json',
55 :project_id => '567' }
78 :project_id => '567' }
56 )
79 )
57 assert_routing(
80 assert_routing(
58 { :method => 'get', :path => "/news/2" },
59 { :controller => 'news', :action => 'show', :id => '2' }
60 )
61 assert_routing(
62 { :method => 'get', :path => "/projects/567/news/new" },
81 { :method => 'get', :path => "/projects/567/news/new" },
63 { :controller => 'news', :action => 'new', :project_id => '567' }
82 { :controller => 'news', :action => 'new', :project_id => '567' }
64 )
83 )
65 assert_routing(
84 assert_routing(
66 { :method => 'get', :path => "/news/234" },
67 { :controller => 'news', :action => 'show', :id => '234' }
68 )
69 assert_routing(
70 { :method => 'get', :path => "/news/567/edit" },
71 { :controller => 'news', :action => 'edit', :id => '567' }
72 )
73 assert_routing(
74 { :method => 'post', :path => "/projects/567/news" },
85 { :method => 'post', :path => "/projects/567/news" },
75 { :controller => 'news', :action => 'create', :project_id => '567' }
86 { :controller => 'news', :action => 'create', :project_id => '567' }
76 )
87 )
77 assert_routing(
78 { :method => 'put', :path => "/news/567" },
79 { :controller => 'news', :action => 'update', :id => '567' }
80 )
81 assert_routing(
82 { :method => 'delete', :path => "/news/567" },
83 { :controller => 'news', :action => 'destroy', :id => '567' }
84 )
85 end
88 end
86 end
89 end
General Comments 0
You need to be logged in to leave comments. Login now