annotate .svn/pristine/b3/b313db558eec0f33b4606021ff7dbfce33600948.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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