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:
@@ -33,7 +33,14 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
@request.session[:user_id] = nil
|
||||
Setting.default_language = 'en'
|
||||
end
|
||||
|
||||
|
||||
def test_index_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects'},
|
||||
:controller => 'projects', :action => 'index'
|
||||
)
|
||||
end
|
||||
|
||||
def test_index
|
||||
get :index
|
||||
assert_response :success
|
||||
@@ -50,7 +57,14 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
}
|
||||
|
||||
assert_no_tag :a, :content => /Private child of eCookbook/
|
||||
end
|
||||
end
|
||||
|
||||
def test_index_atom_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects.atom'},
|
||||
:controller => 'projects', :action => 'index', :format => 'atom'
|
||||
)
|
||||
end
|
||||
|
||||
def test_index_atom
|
||||
get :index, :format => 'atom'
|
||||
@@ -59,12 +73,34 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
assert_select 'feed>title', :text => 'Redmine: Latest projects'
|
||||
assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
|
||||
end
|
||||
|
||||
def test_show_by_id
|
||||
get :show, :id => 1
|
||||
|
||||
def test_add_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/new'},
|
||||
:controller => 'projects', :action => 'add'
|
||||
)
|
||||
assert_recognizes(
|
||||
{:controller => 'projects', :action => 'add'},
|
||||
{:method => :post, :path => '/projects/new'}
|
||||
)
|
||||
assert_recognizes(
|
||||
{:controller => 'projects', :action => 'add'},
|
||||
{:method => :post, :path => '/projects'}
|
||||
)
|
||||
end
|
||||
|
||||
def test_show_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/test'},
|
||||
:controller => 'projects', :action => 'show', :id => 'test'
|
||||
)
|
||||
end
|
||||
|
||||
def test_show_by_id
|
||||
get :show, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
assert_template 'show'
|
||||
assert_not_nil assigns(:project)
|
||||
end
|
||||
|
||||
def test_show_by_identifier
|
||||
@@ -90,6 +126,17 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
assert_tag :tag => 'a', :content => /Private child/
|
||||
end
|
||||
|
||||
def test_settings_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/4223/settings'},
|
||||
:controller => 'projects', :action => 'settings', :id => '4223'
|
||||
)
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/4223/settings/members'},
|
||||
:controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
|
||||
)
|
||||
end
|
||||
|
||||
def test_settings
|
||||
@request.session[:user_id] = 2 # manager
|
||||
get :settings, :id => 1
|
||||
@@ -106,13 +153,49 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
assert_equal 'Test changed name', project.name
|
||||
end
|
||||
|
||||
def test_add_version_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => 'projects/64/versions/new'},
|
||||
:controller => 'projects', :action => 'add_version', :id => '64'
|
||||
)
|
||||
assert_routing(
|
||||
#TODO: use PUT
|
||||
{:method => :post, :path => 'projects/64/versions/new'},
|
||||
:controller => 'projects', :action => 'add_version', :id => '64'
|
||||
)
|
||||
end
|
||||
|
||||
def test_add_issue_category_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => 'projects/test/categories/new'},
|
||||
:controller => 'projects', :action => 'add_issue_category', :id => 'test'
|
||||
)
|
||||
assert_routing(
|
||||
#TODO: use PUT and update form
|
||||
{:method => :post, :path => 'projects/64/categories/new'},
|
||||
:controller => 'projects', :action => 'add_issue_category', :id => '64'
|
||||
)
|
||||
end
|
||||
|
||||
def test_destroy_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/567/destroy'},
|
||||
:controller => 'projects', :action => 'destroy', :id => '567'
|
||||
)
|
||||
assert_routing(
|
||||
#TODO: use DELETE and update form
|
||||
{:method => :post, :path => 'projects/64/destroy'},
|
||||
:controller => 'projects', :action => 'destroy', :id => '64'
|
||||
)
|
||||
end
|
||||
|
||||
def test_get_destroy
|
||||
@request.session[:user_id] = 1 # admin
|
||||
get :destroy, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'destroy'
|
||||
assert_not_nil Project.find_by_id(1)
|
||||
end
|
||||
end
|
||||
|
||||
def test_post_destroy
|
||||
@request.session[:user_id] = 1 # admin
|
||||
@@ -142,6 +225,17 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
assert mail.body.include?('testfile.txt')
|
||||
end
|
||||
|
||||
def test_add_file_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/33/files/new'},
|
||||
:controller => 'projects', :action => 'add_file', :id => '33'
|
||||
)
|
||||
assert_routing(
|
||||
{:method => :post, :path => '/projects/33/files/new'},
|
||||
:controller => 'projects', :action => 'add_file', :id => '33'
|
||||
)
|
||||
end
|
||||
|
||||
def test_add_version_file
|
||||
set_tmp_attachments_directory
|
||||
@request.session[:user_id] = 2
|
||||
@@ -156,27 +250,48 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
assert_equal 'testfile.txt', a.filename
|
||||
assert_equal Version.find(2), a.container
|
||||
end
|
||||
|
||||
def test_list_files
|
||||
get :list_files, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'list_files'
|
||||
|
||||
def test_list_files
|
||||
get :list_files, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'list_files'
|
||||
assert_not_nil assigns(:containers)
|
||||
|
||||
# file attached to the project
|
||||
assert_tag :a, :content => 'project_file.zip',
|
||||
:attributes => { :href => '/attachments/download/8/project_file.zip' }
|
||||
|
||||
|
||||
# file attached to a project's version
|
||||
assert_tag :a, :content => 'version_file.zip',
|
||||
:attributes => { :href => '/attachments/download/9/version_file.zip' }
|
||||
end
|
||||
|
||||
def test_changelog
|
||||
get :changelog, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'changelog'
|
||||
assert_not_nil assigns(:versions)
|
||||
end
|
||||
|
||||
def test_list_files_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/33/files'},
|
||||
:controller => 'projects', :action => 'list_files', :id => '33'
|
||||
)
|
||||
end
|
||||
|
||||
def test_changelog_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/44/changelog'},
|
||||
:controller => 'projects', :action => 'changelog', :id => '44'
|
||||
)
|
||||
end
|
||||
|
||||
def test_changelog
|
||||
get :changelog, :id => 1
|
||||
assert_response :success
|
||||
assert_template 'changelog'
|
||||
assert_not_nil assigns(:versions)
|
||||
end
|
||||
|
||||
def test_roadmap_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => 'projects/33/roadmap'},
|
||||
:controller => 'projects', :action => 'roadmap', :id => '33'
|
||||
)
|
||||
end
|
||||
|
||||
def test_roadmap
|
||||
@@ -200,7 +315,21 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
# Completed version appears
|
||||
assert assigns(:versions).include?(Version.find(1))
|
||||
end
|
||||
|
||||
|
||||
def test_project_activity_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/1/activity'},
|
||||
:controller => 'projects', :action => 'activity', :id => '1'
|
||||
)
|
||||
end
|
||||
|
||||
def test_project_activity_atom_routing
|
||||
assert_routing(
|
||||
{:method => :get, :path => '/projects/1/activity.atom'},
|
||||
:controller => 'projects', :action => 'activity', :id => '1', :format => 'atom'
|
||||
)
|
||||
end
|
||||
|
||||
def test_project_activity
|
||||
get :activity, :id => 1, :with_subprojects => 0
|
||||
assert_response :success
|
||||
@@ -237,6 +366,10 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
}
|
||||
end
|
||||
|
||||
def test_global_activity_routing
|
||||
assert_routing({:method => :get, :path => '/activity'}, :controller => 'projects', :action => 'activity')
|
||||
end
|
||||
|
||||
def test_global_activity
|
||||
get :activity
|
||||
assert_response :success
|
||||
@@ -273,19 +406,39 @@ class ProjectsControllerTest < Test::Unit::TestCase
|
||||
}
|
||||
end
|
||||
|
||||
def test_global_activity_atom_routing
|
||||
assert_routing({:method => :get, :path => '/activity.atom'}, :controller => 'projects', :action => 'activity', :format => 'atom')
|
||||
end
|
||||
|
||||
def test_activity_atom_feed
|
||||
get :activity, :format => 'atom'
|
||||
assert_response :success
|
||||
assert_template 'common/feed.atom.rxml'
|
||||
end
|
||||
|
||||
def test_archive
|
||||
def test_archive_routing
|
||||
assert_routing(
|
||||
#TODO: use PUT to project path and modify form
|
||||
{:method => :post, :path => 'projects/64/archive'},
|
||||
:controller => 'projects', :action => 'archive', :id => '64'
|
||||
)
|
||||
end
|
||||
|
||||
def test_archive
|
||||
@request.session[:user_id] = 1 # admin
|
||||
post :archive, :id => 1
|
||||
assert_redirected_to 'admin/projects'
|
||||
assert !Project.find(1).active?
|
||||
end
|
||||
|
||||
def test_unarchive_routing
|
||||
assert_routing(
|
||||
#TODO: use PUT to project path and modify form
|
||||
{:method => :post, :path => '/projects/567/unarchive'},
|
||||
:controller => 'projects', :action => 'unarchive', :id => '567'
|
||||
)
|
||||
end
|
||||
|
||||
def test_unarchive
|
||||
@request.session[:user_id] = 1 # admin
|
||||
Project.find(1).archive
|
||||
|
||||
Reference in New Issue
Block a user