##// END OF EJS Templates
Adds tests for new routes....
Jean-Philippe Lang -
r13221:cd6b2f2268d3
parent child
Show More
@@ -1,63 +1,67
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
2 # Copyright (C) 2006-2014 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 RoutingMembersTest < ActionDispatch::IntegrationTest
20 class RoutingMembersTest < ActionDispatch::IntegrationTest
21 def test_members
21 def test_members
22 assert_routing(
22 assert_routing(
23 { :method => 'get', :path => "/projects/5234/memberships.xml" },
23 { :method => 'get', :path => "/projects/5234/memberships.xml" },
24 { :controller => 'members', :action => 'index', :project_id => '5234', :format => 'xml' }
24 { :controller => 'members', :action => 'index', :project_id => '5234', :format => 'xml' }
25 )
25 )
26 assert_routing(
26 assert_routing(
27 { :method => 'get', :path => "/memberships/5234.xml" },
27 { :method => 'get', :path => "/memberships/5234.xml" },
28 { :controller => 'members', :action => 'show', :id => '5234', :format => 'xml' }
28 { :controller => 'members', :action => 'show', :id => '5234', :format => 'xml' }
29 )
29 )
30 assert_routing(
30 assert_routing(
31 { :method => 'post', :path => "/projects/5234/memberships" },
31 { :method => 'post', :path => "/projects/5234/memberships" },
32 { :controller => 'members', :action => 'create', :project_id => '5234' }
32 { :controller => 'members', :action => 'create', :project_id => '5234' }
33 )
33 )
34 assert_routing(
34 assert_routing(
35 { :method => 'post', :path => "/projects/5234/memberships.xml" },
35 { :method => 'post', :path => "/projects/5234/memberships.xml" },
36 { :controller => 'members', :action => 'create', :project_id => '5234', :format => 'xml' }
36 { :controller => 'members', :action => 'create', :project_id => '5234', :format => 'xml' }
37 )
37 )
38 assert_routing(
38 assert_routing(
39 { :method => 'get', :path => "/projects/5234/memberships/new" },
40 { :controller => 'members', :action => 'new', :project_id => '5234' }
41 )
42 assert_routing(
39 { :method => 'put', :path => "/memberships/5234" },
43 { :method => 'put', :path => "/memberships/5234" },
40 { :controller => 'members', :action => 'update', :id => '5234' }
44 { :controller => 'members', :action => 'update', :id => '5234' }
41 )
45 )
42 assert_routing(
46 assert_routing(
43 { :method => 'put', :path => "/memberships/5234.xml" },
47 { :method => 'put', :path => "/memberships/5234.xml" },
44 { :controller => 'members', :action => 'update', :id => '5234', :format => 'xml' }
48 { :controller => 'members', :action => 'update', :id => '5234', :format => 'xml' }
45 )
49 )
46 assert_routing(
50 assert_routing(
47 { :method => 'delete', :path => "/memberships/5234" },
51 { :method => 'delete', :path => "/memberships/5234" },
48 { :controller => 'members', :action => 'destroy', :id => '5234' }
52 { :controller => 'members', :action => 'destroy', :id => '5234' }
49 )
53 )
50 assert_routing(
54 assert_routing(
51 { :method => 'delete', :path => "/memberships/5234.xml" },
55 { :method => 'delete', :path => "/memberships/5234.xml" },
52 { :controller => 'members', :action => 'destroy', :id => '5234', :format => 'xml' }
56 { :controller => 'members', :action => 'destroy', :id => '5234', :format => 'xml' }
53 )
57 )
54 assert_routing(
58 assert_routing(
55 { :method => 'get', :path => "/projects/5234/memberships/autocomplete" },
59 { :method => 'get', :path => "/projects/5234/memberships/autocomplete" },
56 { :controller => 'members', :action => 'autocomplete', :project_id => '5234' }
60 { :controller => 'members', :action => 'autocomplete', :project_id => '5234' }
57 )
61 )
58 assert_routing(
62 assert_routing(
59 { :method => 'get', :path => "/projects/5234/memberships/autocomplete.js" },
63 { :method => 'get', :path => "/projects/5234/memberships/autocomplete.js" },
60 { :controller => 'members', :action => 'autocomplete', :project_id => '5234', :format => 'js' }
64 { :controller => 'members', :action => 'autocomplete', :project_id => '5234', :format => 'js' }
61 )
65 )
62 end
66 end
63 end
67 end
@@ -1,56 +1,66
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
2 # Copyright (C) 2006-2014 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 RoutingPrincipalMembershipsTest < ActionDispatch::IntegrationTest
20 class RoutingPrincipalMembershipsTest < ActionDispatch::IntegrationTest
21 def test_user_memberships
21 def test_user_memberships
22 assert_routing(
22 assert_routing(
23 { :method => 'get', :path => "/users/123/memberships/new" },
24 { :controller => 'principal_memberships', :action => 'new',
25 :user_id => '123' }
26 )
27 assert_routing(
23 { :method => 'post', :path => "/users/123/memberships" },
28 { :method => 'post', :path => "/users/123/memberships" },
24 { :controller => 'principal_memberships', :action => 'create',
29 { :controller => 'principal_memberships', :action => 'create',
25 :user_id => '123' }
30 :user_id => '123' }
26 )
31 )
27 assert_routing(
32 assert_routing(
28 { :method => 'put', :path => "/users/123/memberships/55" },
33 { :method => 'put', :path => "/users/123/memberships/55" },
29 { :controller => 'principal_memberships', :action => 'update',
34 { :controller => 'principal_memberships', :action => 'update',
30 :user_id => '123', :id => '55' }
35 :user_id => '123', :id => '55' }
31 )
36 )
32 assert_routing(
37 assert_routing(
33 { :method => 'delete', :path => "/users/123/memberships/55" },
38 { :method => 'delete', :path => "/users/123/memberships/55" },
34 { :controller => 'principal_memberships', :action => 'destroy',
39 { :controller => 'principal_memberships', :action => 'destroy',
35 :user_id => '123', :id => '55' }
40 :user_id => '123', :id => '55' }
36 )
41 )
37 end
42 end
38
43
39 def test_group_memberships
44 def test_group_memberships
40 assert_routing(
45 assert_routing(
46 { :method => 'get', :path => "/groups/123/memberships/new" },
47 { :controller => 'principal_memberships', :action => 'new',
48 :group_id => '123' }
49 )
50 assert_routing(
41 { :method => 'post', :path => "/groups/123/memberships" },
51 { :method => 'post', :path => "/groups/123/memberships" },
42 { :controller => 'principal_memberships', :action => 'create',
52 { :controller => 'principal_memberships', :action => 'create',
43 :group_id => '123' }
53 :group_id => '123' }
44 )
54 )
45 assert_routing(
55 assert_routing(
46 { :method => 'put', :path => "/groups/123/memberships/55" },
56 { :method => 'put', :path => "/groups/123/memberships/55" },
47 { :controller => 'principal_memberships', :action => 'update',
57 { :controller => 'principal_memberships', :action => 'update',
48 :group_id => '123', :id => '55' }
58 :group_id => '123', :id => '55' }
49 )
59 )
50 assert_routing(
60 assert_routing(
51 { :method => 'delete', :path => "/groups/123/memberships/55" },
61 { :method => 'delete', :path => "/groups/123/memberships/55" },
52 { :controller => 'principal_memberships', :action => 'destroy',
62 { :controller => 'principal_memberships', :action => 'destroy',
53 :group_id => '123', :id => '55' }
63 :group_id => '123', :id => '55' }
54 )
64 )
55 end
65 end
56 end
66 end
General Comments 0
You need to be logged in to leave comments. Login now