Converted routing and urls to follow the Rails REST convention.
Patch supplied by commits from Gerrit Kaiser on Github. Existing routes will still work (backwards compatible) but any new urls will be generated using the new routing rules. Changes listed below: * made the URLs for some project tabs and project settings follow the new rails RESTful conventions of /collection/:id/subcollection/:sub_id * prettier URL for project roadmap * more nice project URLs * use GET for filtering form * prettified URLs used on issues tab * custom route for activity atom feeds * prettier repository urls * fixed broken route definition * fixed failing tests for issuecontroller that were hardcoding the url string * more RESTful routes for boards and messages * RESTful routes for wiki pages * RESTful routes for documents * moved old routes that are retained for compatibility to the bottom and grouped them together * added RESTful URIs for issues * RESTfulness for the news section * fixed route order * changed hardcoded URLs in tests * fixed badly written tests * fixed forgotten parameter in routes * changed hardcoded URLS to new scheme * changed project add url to the standard POST to collection * create new issue by POSTing to collection * changed hardcoded URLs in integrations tests * made project add form work again * restful routes for project deletion * prettier routes for project (un)archival * made routes table more readable * fixed note quoting * user routing * fixed bug * always sort by GET * Fixed: cross-project issue list should not show issues of projects for which the issue tracking module was disabled. * prettified URLs used on issues tab * urls for time log * fixed reply routing * eliminate revision query paremeter for diff and entry actions * fixed test failures with hard-coded urls * ensure ajax links always use get * refactored ajax link generation into separate method #1901 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2317 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -31,6 +31,21 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
User.current = nil
|
||||
end
|
||||
|
||||
def test_index_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/567/wiki'},
|
||||
:controller => 'wiki', :action => 'index', :id => '567'
|
||||
)
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/567/wiki/lalala'},
|
||||
:controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
|
||||
)
|
||||
assert_generates(
|
||||
'/projects/567/wiki',
|
||||
:controller => 'wiki', :action => 'index', :id => '567', :page => nil
|
||||
)
|
||||
end
|
||||
|
||||
def test_show_start_page
|
||||
get :index, :id => 'ecookbook'
|
||||
assert_response :success
|
||||
@@ -40,7 +55,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
# child_pages macro
|
||||
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
||||
:child => { :tag => 'li',
|
||||
:child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
|
||||
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
||||
:content => 'Page with an inline image' } }
|
||||
end
|
||||
|
||||
@@ -67,6 +82,17 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
assert_template 'edit'
|
||||
end
|
||||
|
||||
def test_edit_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/567/wiki/my_page/edit'},
|
||||
:controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
|
||||
)
|
||||
assert_recognizes(#TODO: use PUT to page path, adjust forms accordingly
|
||||
{:controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'},
|
||||
{:method => :post, :path => '/projects/567/wiki/my_page/edit'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_create_page
|
||||
@request.session[:user_id] = 2
|
||||
post :edit, :id => 1,
|
||||
@@ -74,13 +100,20 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
:content => {:comments => 'Created the page',
|
||||
:text => "h1. New page\n\nThis is a new page",
|
||||
:version => 0}
|
||||
assert_redirected_to 'wiki/ecookbook/New_page'
|
||||
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'New_page'
|
||||
page = Project.find(1).wiki.find_page('New page')
|
||||
assert !page.new_record?
|
||||
assert_not_nil page.content
|
||||
assert_equal 'Created the page', page.content.comments
|
||||
end
|
||||
|
||||
def test_preview_routing
|
||||
assert_routing(
|
||||
{:method => :post, :path => '/projects/567/wiki/CookBook_documentation/preview'},
|
||||
:controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation'
|
||||
)
|
||||
end
|
||||
|
||||
def test_preview
|
||||
@request.session[:user_id] = 2
|
||||
xhr :post, :preview, :id => 1, :page => 'CookBook_documentation',
|
||||
@@ -103,6 +136,13 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
assert_tag :tag => 'h1', :content => /New page/
|
||||
end
|
||||
|
||||
def test_history_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/1/wiki/CookBook_documentation/history'},
|
||||
:controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation'
|
||||
)
|
||||
end
|
||||
|
||||
def test_history
|
||||
get :history, :id => 1, :page => 'CookBook_documentation'
|
||||
assert_response :success
|
||||
@@ -120,6 +160,13 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
assert_equal 1, assigns(:versions).size
|
||||
assert_select "input[type=submit][name=commit]", false
|
||||
end
|
||||
|
||||
def test_diff_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/1/wiki/CookBook_documentation/diff/2/vs/1'},
|
||||
:controller => 'wiki', :action => 'diff', :id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1'
|
||||
)
|
||||
end
|
||||
|
||||
def test_diff
|
||||
get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
|
||||
@@ -129,6 +176,13 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
:content => /updated/
|
||||
end
|
||||
|
||||
def test_annotate_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/1/wiki/CookBook_documentation/annotate/2'},
|
||||
:controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2'
|
||||
)
|
||||
end
|
||||
|
||||
def test_annotate
|
||||
get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2
|
||||
assert_response :success
|
||||
@@ -143,12 +197,24 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
:child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
|
||||
end
|
||||
|
||||
def test_rename_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/22/wiki/ladida/rename'},
|
||||
:controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
|
||||
)
|
||||
assert_recognizes(
|
||||
#TODO: should be moved into a update action and use a PUT to the page URI
|
||||
{:controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'},
|
||||
{:method => :post, :path => '/projects/22/wiki/ladida/rename'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_rename_with_redirect
|
||||
@request.session[:user_id] = 2
|
||||
post :rename, :id => 1, :page => 'Another_page',
|
||||
:wiki_page => { :title => 'Another renamed page',
|
||||
:redirect_existing_links => 1 }
|
||||
assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
|
||||
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_renamed_page'
|
||||
wiki = Project.find(1).wiki
|
||||
# Check redirects
|
||||
assert_not_nil wiki.find_page('Another page')
|
||||
@@ -160,16 +226,43 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
post :rename, :id => 1, :page => 'Another_page',
|
||||
:wiki_page => { :title => 'Another renamed page',
|
||||
:redirect_existing_links => "0" }
|
||||
assert_redirected_to 'wiki/ecookbook/Another_renamed_page'
|
||||
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_renamed_page'
|
||||
wiki = Project.find(1).wiki
|
||||
# Check that there's no redirects
|
||||
assert_nil wiki.find_page('Another page')
|
||||
end
|
||||
|
||||
def test_destroy_routing
|
||||
assert_recognizes(
|
||||
#TODO: should use DELETE on page URI
|
||||
{:controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida'},
|
||||
{:method => :post, :path => 'projects/22/wiki/ladida/destroy'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_destroy
|
||||
@request.session[:user_id] = 2
|
||||
post :destroy, :id => 1, :page => 'CookBook_documentation'
|
||||
assert_redirected_to 'wiki/ecookbook/Page_index/special'
|
||||
assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
|
||||
end
|
||||
|
||||
def test_special_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/567/wiki/page_index'},
|
||||
:controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
|
||||
)
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/567/wiki/Page_Index'},
|
||||
:controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
|
||||
)
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/567/wiki/date_index'},
|
||||
:controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
|
||||
)
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/567/wiki/export'},
|
||||
:controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
|
||||
)
|
||||
end
|
||||
|
||||
def test_page_index
|
||||
@@ -181,13 +274,13 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
assert_equal Project.find(1).wiki.pages.size, pages.size
|
||||
|
||||
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
|
||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
|
||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
|
||||
:content => 'CookBook documentation' },
|
||||
:child => { :tag => 'ul',
|
||||
:child => { :tag => 'li',
|
||||
:child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Page_with_an_inline_image' },
|
||||
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
||||
:content => 'Page with an inline image' } } } },
|
||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Another_page' },
|
||||
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
|
||||
:content => 'Another page' } }
|
||||
end
|
||||
|
||||
@@ -196,12 +289,19 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
def test_protect_routing
|
||||
assert_routing(
|
||||
{:method => :post, :path => 'projects/22/wiki/ladida/protect'},
|
||||
{:controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_protect_page
|
||||
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
|
||||
assert !page.protected?
|
||||
@request.session[:user_id] = 2
|
||||
post :protect, :id => 1, :page => page.title, :protected => '1'
|
||||
assert_redirected_to 'wiki/ecookbook/Another_page'
|
||||
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_page'
|
||||
assert page.reload.protected?
|
||||
end
|
||||
|
||||
@@ -210,7 +310,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
assert page.protected?
|
||||
@request.session[:user_id] = 2
|
||||
post :protect, :id => 1, :page => page.title, :protected => '0'
|
||||
assert_redirected_to '/wiki/ecookbook/CookBook_documentation'
|
||||
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'CookBook_documentation'
|
||||
assert !page.reload.protected?
|
||||
end
|
||||
|
||||
@@ -219,7 +319,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
get :index, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
|
||||
assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
||||
end
|
||||
|
||||
def test_show_page_without_edit_link
|
||||
@@ -227,7 +327,7 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||
get :index, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_no_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
|
||||
assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
|
||||
end
|
||||
|
||||
def test_edit_unprotected_page
|
||||
|
||||
Reference in New Issue
Block a user