annotate .svn/pristine/d9/d98764f99d236520bd5f6ca42381f61878a79847.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
rev   line source
Chris@1295 1 # Redmine - project management software
Chris@1295 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
Chris@1295 3 #
Chris@1295 4 # This program is free software; you can redistribute it and/or
Chris@1295 5 # modify it under the terms of the GNU General Public License
Chris@1295 6 # as published by the Free Software Foundation; either version 2
Chris@1295 7 # of the License, or (at your option) any later version.
Chris@1295 8 #
Chris@1295 9 # This program is distributed in the hope that it will be useful,
Chris@1295 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1295 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1295 12 # GNU General Public License for more details.
Chris@1295 13 #
Chris@1295 14 # You should have received a copy of the GNU General Public License
Chris@1295 15 # along with this program; if not, write to the Free Software
Chris@1295 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1295 17
Chris@1295 18 require File.expand_path('../../../test_helper', __FILE__)
Chris@1295 19
Chris@1295 20 class RoutingWikiTest < ActionController::IntegrationTest
Chris@1295 21 def test_wiki_matching
Chris@1295 22 assert_routing(
Chris@1295 23 { :method => 'get', :path => "/projects/567/wiki" },
Chris@1295 24 { :controller => 'wiki', :action => 'show', :project_id => '567' }
Chris@1295 25 )
Chris@1295 26 assert_routing(
Chris@1295 27 { :method => 'get', :path => "/projects/567/wiki/lalala" },
Chris@1295 28 { :controller => 'wiki', :action => 'show', :project_id => '567',
Chris@1295 29 :id => 'lalala' }
Chris@1295 30 )
Chris@1295 31 assert_routing(
Chris@1295 32 { :method => 'get', :path => "/projects/567/wiki/lalala.pdf" },
Chris@1295 33 { :controller => 'wiki', :action => 'show', :project_id => '567',
Chris@1295 34 :id => 'lalala', :format => 'pdf' }
Chris@1295 35 )
Chris@1295 36 assert_routing(
Chris@1295 37 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" },
Chris@1295 38 { :controller => 'wiki', :action => 'diff', :project_id => '1',
Chris@1295 39 :id => 'CookBook_documentation' }
Chris@1295 40 )
Chris@1295 41 assert_routing(
Chris@1295 42 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2" },
Chris@1295 43 { :controller => 'wiki', :action => 'show', :project_id => '1',
Chris@1295 44 :id => 'CookBook_documentation', :version => '2' }
Chris@1295 45 )
Chris@1295 46 assert_routing(
Chris@1295 47 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/diff" },
Chris@1295 48 { :controller => 'wiki', :action => 'diff', :project_id => '1',
Chris@1295 49 :id => 'CookBook_documentation', :version => '2' }
Chris@1295 50 )
Chris@1295 51 assert_routing(
Chris@1295 52 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2/annotate" },
Chris@1295 53 { :controller => 'wiki', :action => 'annotate', :project_id => '1',
Chris@1295 54 :id => 'CookBook_documentation', :version => '2' }
Chris@1295 55 )
Chris@1295 56 # Make sure we don't route wiki page sub-uris to let plugins handle them
Chris@1295 57 assert_raise(ActionController::RoutingError) do
Chris@1295 58 assert_recognizes({}, {:method => 'get', :path => "/projects/1/wiki/CookBook_documentation/whatever"})
Chris@1295 59 end
Chris@1295 60 end
Chris@1295 61
Chris@1295 62 def test_wiki_misc
Chris@1295 63 assert_routing(
Chris@1295 64 { :method => 'get', :path => "/projects/567/wiki/date_index" },
Chris@1295 65 { :controller => 'wiki', :action => 'date_index', :project_id => '567' }
Chris@1295 66 )
Chris@1295 67 assert_routing(
Chris@1295 68 { :method => 'get', :path => "/projects/567/wiki/export" },
Chris@1295 69 { :controller => 'wiki', :action => 'export', :project_id => '567' }
Chris@1295 70 )
Chris@1295 71 assert_routing(
Chris@1295 72 { :method => 'get', :path => "/projects/567/wiki/export.pdf" },
Chris@1295 73 { :controller => 'wiki', :action => 'export', :project_id => '567', :format => 'pdf' }
Chris@1295 74 )
Chris@1295 75 assert_routing(
Chris@1295 76 { :method => 'get', :path => "/projects/567/wiki/index" },
Chris@1295 77 { :controller => 'wiki', :action => 'index', :project_id => '567' }
Chris@1295 78 )
Chris@1295 79 end
Chris@1295 80
Chris@1295 81 def test_wiki_resources
Chris@1295 82 assert_routing(
Chris@1295 83 { :method => 'get', :path => "/projects/567/wiki/my_page/edit" },
Chris@1295 84 { :controller => 'wiki', :action => 'edit', :project_id => '567',
Chris@1295 85 :id => 'my_page' }
Chris@1295 86 )
Chris@1295 87 assert_routing(
Chris@1295 88 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/history" },
Chris@1295 89 { :controller => 'wiki', :action => 'history', :project_id => '1',
Chris@1295 90 :id => 'CookBook_documentation' }
Chris@1295 91 )
Chris@1295 92 assert_routing(
Chris@1295 93 { :method => 'get', :path => "/projects/22/wiki/ladida/rename" },
Chris@1295 94 { :controller => 'wiki', :action => 'rename', :project_id => '22',
Chris@1295 95 :id => 'ladida' }
Chris@1295 96 )
Chris@1295 97 ["post", "put"].each do |method|
Chris@1295 98 assert_routing(
Chris@1295 99 { :method => method, :path => "/projects/567/wiki/CookBook_documentation/preview" },
Chris@1295 100 { :controller => 'wiki', :action => 'preview', :project_id => '567',
Chris@1295 101 :id => 'CookBook_documentation' }
Chris@1295 102 )
Chris@1295 103 end
Chris@1295 104 assert_routing(
Chris@1295 105 { :method => 'post', :path => "/projects/22/wiki/ladida/rename" },
Chris@1295 106 { :controller => 'wiki', :action => 'rename', :project_id => '22',
Chris@1295 107 :id => 'ladida' }
Chris@1295 108 )
Chris@1295 109 assert_routing(
Chris@1295 110 { :method => 'post', :path => "/projects/22/wiki/ladida/protect" },
Chris@1295 111 { :controller => 'wiki', :action => 'protect', :project_id => '22',
Chris@1295 112 :id => 'ladida' }
Chris@1295 113 )
Chris@1295 114 assert_routing(
Chris@1295 115 { :method => 'post', :path => "/projects/22/wiki/ladida/add_attachment" },
Chris@1295 116 { :controller => 'wiki', :action => 'add_attachment', :project_id => '22',
Chris@1295 117 :id => 'ladida' }
Chris@1295 118 )
Chris@1295 119 assert_routing(
Chris@1295 120 { :method => 'put', :path => "/projects/567/wiki/my_page" },
Chris@1295 121 { :controller => 'wiki', :action => 'update', :project_id => '567',
Chris@1295 122 :id => 'my_page' }
Chris@1295 123 )
Chris@1295 124 assert_routing(
Chris@1295 125 { :method => 'delete', :path => "/projects/22/wiki/ladida" },
Chris@1295 126 { :controller => 'wiki', :action => 'destroy', :project_id => '22',
Chris@1295 127 :id => 'ladida' }
Chris@1295 128 )
Chris@1295 129 assert_routing(
Chris@1295 130 { :method => 'delete', :path => "/projects/22/wiki/ladida/3" },
Chris@1295 131 { :controller => 'wiki', :action => 'destroy_version', :project_id => '22',
Chris@1295 132 :id => 'ladida', :version => '3' }
Chris@1295 133 )
Chris@1295 134 end
Chris@1295 135
Chris@1295 136 def test_api
Chris@1295 137 assert_routing(
Chris@1295 138 { :method => 'get', :path => "/projects/567/wiki/my_page.xml" },
Chris@1295 139 { :controller => 'wiki', :action => 'show', :project_id => '567',
Chris@1295 140 :id => 'my_page', :format => 'xml' }
Chris@1295 141 )
Chris@1295 142 assert_routing(
Chris@1295 143 { :method => 'get', :path => "/projects/567/wiki/my_page.json" },
Chris@1295 144 { :controller => 'wiki', :action => 'show', :project_id => '567',
Chris@1295 145 :id => 'my_page', :format => 'json' }
Chris@1295 146 )
Chris@1295 147 assert_routing(
Chris@1295 148 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.xml" },
Chris@1295 149 { :controller => 'wiki', :action => 'show', :project_id => '1',
Chris@1295 150 :id => 'CookBook_documentation', :version => '2', :format => 'xml' }
Chris@1295 151 )
Chris@1295 152 assert_routing(
Chris@1295 153 { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/2.json" },
Chris@1295 154 { :controller => 'wiki', :action => 'show', :project_id => '1',
Chris@1295 155 :id => 'CookBook_documentation', :version => '2', :format => 'json' }
Chris@1295 156 )
Chris@1295 157 assert_routing(
Chris@1295 158 { :method => 'get', :path => "/projects/567/wiki/index.xml" },
Chris@1295 159 { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'xml' }
Chris@1295 160 )
Chris@1295 161 assert_routing(
Chris@1295 162 { :method => 'get', :path => "/projects/567/wiki/index.json" },
Chris@1295 163 { :controller => 'wiki', :action => 'index', :project_id => '567', :format => 'json' }
Chris@1295 164 )
Chris@1295 165 assert_routing(
Chris@1295 166 { :method => 'put', :path => "/projects/567/wiki/my_page.xml" },
Chris@1295 167 { :controller => 'wiki', :action => 'update', :project_id => '567',
Chris@1295 168 :id => 'my_page', :format => 'xml' }
Chris@1295 169 )
Chris@1295 170 assert_routing(
Chris@1295 171 { :method => 'put', :path => "/projects/567/wiki/my_page.json" },
Chris@1295 172 { :controller => 'wiki', :action => 'update', :project_id => '567',
Chris@1295 173 :id => 'my_page', :format => 'json' }
Chris@1295 174 )
Chris@1295 175 assert_routing(
Chris@1295 176 { :method => 'delete', :path => "/projects/567/wiki/my_page.xml" },
Chris@1295 177 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
Chris@1295 178 :id => 'my_page', :format => 'xml' }
Chris@1295 179 )
Chris@1295 180 assert_routing(
Chris@1295 181 { :method => 'delete', :path => "/projects/567/wiki/my_page.json" },
Chris@1295 182 { :controller => 'wiki', :action => 'destroy', :project_id => '567',
Chris@1295 183 :id => 'my_page', :format => 'json' }
Chris@1295 184 )
Chris@1295 185 end
Chris@1295 186 end