Move more routing tests into the routing integration test.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3686 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis 2010-04-20 15:42:57 +00:00
parent 657aa624a4
commit 0fc884cf42
6 changed files with 46 additions and 212 deletions

View File

@ -38,13 +38,6 @@ class AdminControllerTest < ActionController::TestCase
:attributes => { :class => /nodata/ }
end
def test_projects_routing
assert_routing(
{:method => :get, :path => '/admin/projects'},
:controller => 'admin', :action => 'projects'
)
end
def test_index_with_no_configuration_data
delete_configuration_data
get :index

View File

@ -1288,13 +1288,6 @@ class IssuesControllerTest < ActionController::TestCase
assert_not_nil assigns(:notes)
end
def test_auto_complete_routing
assert_routing(
{:method => :get, :path => '/issues/auto_complete'},
:controller => 'issues', :action => 'auto_complete'
)
end
def test_auto_complete_should_not_be_case_sensitive
get :auto_complete, :project_id => 'ecookbook', :q => 'ReCiPe'
assert_response :success
@ -1309,13 +1302,6 @@ class IssuesControllerTest < ActionController::TestCase
assert assigns(:issues).include?(Issue.find(13))
end
def test_destroy_routing
assert_recognizes( #TODO: use DELETE on issue URI (need to change forms)
{:controller => 'issues', :action => 'destroy', :id => '1'},
{:method => :post, :path => '/issues/1/destroy'}
)
end
def test_destroy_issue_with_no_time_entries
assert_nil TimeEntry.find_by_issue_id(2)
@request.session[:user_id] = 2

View File

@ -34,21 +34,6 @@ class UsersControllerTest < ActionController::TestCase
@request.session[:user_id] = 1 # admin
end
def test_index_routing
assert_generates(
'/users',
:controller => 'users', :action => 'index'
)
assert_routing(
{:method => :get, :path => '/users'},
:controller => 'users', :action => 'index'
)
assert_recognizes(
{:controller => 'users', :action => 'index'},
{:method => :get, :path => '/users'}
)
end
def test_index
get :index
assert_response :success
@ -74,17 +59,6 @@ class UsersControllerTest < ActionController::TestCase
assert_equal 'John', users.first.firstname
end
def test_show_routing
assert_routing(
{:method => :get, :path => '/users/44'},
:controller => 'users', :action => 'show', :id => '44'
)
assert_recognizes(
{:controller => 'users', :action => 'show', :id => '44'},
{:method => :get, :path => '/users/44'}
)
end
def test_show
@request.session[:user_id] = nil
get :show, :id => 2
@ -123,38 +97,6 @@ class UsersControllerTest < ActionController::TestCase
assert_not_nil assigns(:user)
end
def test_add_routing
assert_routing(
{:method => :get, :path => '/users/new'},
:controller => 'users', :action => 'add'
)
assert_recognizes(
#TODO: remove this and replace with POST to collection, need to modify form
{:controller => 'users', :action => 'add'},
{:method => :post, :path => '/users/new'}
)
assert_recognizes(
{:controller => 'users', :action => 'add'},
{:method => :post, :path => '/users'}
)
end
def test_edit_routing
assert_routing(
{:method => :get, :path => '/users/444/edit'},
:controller => 'users', :action => 'edit', :id => '444'
)
assert_routing(
{:method => :get, :path => '/users/222/edit/membership'},
:controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
)
assert_recognizes(
#TODO: use PUT on user_path, modify form
{:controller => 'users', :action => 'edit', :id => '444'},
{:method => :post, :path => '/users/444/edit'}
)
end
def test_edit
ActionMailer::Base.deliveries.clear
post :edit, :id => 2, :user => {:firstname => 'Changed'}
@ -192,20 +134,6 @@ class UsersControllerTest < ActionController::TestCase
assert mail.body.include?('newpass')
end
def test_add_membership_routing
assert_routing(
{:method => :post, :path => '/users/123/memberships'},
:controller => 'users', :action => 'edit_membership', :id => '123'
)
end
def test_edit_membership_routing
assert_routing(
{:method => :post, :path => '/users/123/memberships/55'},
:controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
)
end
def test_edit_membership
post :edit_membership, :id => 2, :membership_id => 1,
:membership => { :role_ids => [2]}
@ -213,14 +141,6 @@ class UsersControllerTest < ActionController::TestCase
assert_equal [2], Member.find(1).role_ids
end
def test_destroy_membership
assert_routing(
#TODO: use DELETE method on user_membership_path, modify form
{:method => :post, :path => '/users/567/memberships/12/destroy'},
:controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
)
end
def test_destroy_membership
post :destroy_membership, :id => 2, :membership_id => 1
assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships'

View File

@ -40,17 +40,6 @@ class VersionsControllerTest < ActionController::TestCase
assert_tag :tag => 'h2', :content => /1.0/
end
def test_new_routing
assert_routing(
{:method => :get, :path => 'projects/foo/versions/new'},
:controller => 'versions', :action => 'new', :project_id => 'foo'
)
assert_routing(
{:method => :post, :path => 'projects/foo/versions/new'},
:controller => 'versions', :action => 'new', :project_id => 'foo'
)
end
def test_new
@request.session[:user_id] = 2 # manager
assert_difference 'Version.count' do

View File

@ -31,21 +31,6 @@ class WikiControllerTest < ActionController::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
@ -93,17 +78,6 @@ class WikiControllerTest < ActionController::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,
@ -135,13 +109,6 @@ class WikiControllerTest < ActionController::TestCase
assert_equal 'testfile.txt', page.attachments.first.filename
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',
@ -164,13 +131,6 @@ class WikiControllerTest < ActionController::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
@ -189,13 +149,6 @@ class WikiControllerTest < ActionController::TestCase
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
assert_response :success
@ -204,13 +157,6 @@ class WikiControllerTest < ActionController::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
@ -225,18 +171,6 @@ class WikiControllerTest < ActionController::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',
@ -260,14 +194,6 @@ class WikiControllerTest < ActionController::TestCase
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_child
@request.session[:user_id] = 2
post :destroy, :id => 1, :page => 'Child_1'
@ -312,25 +238,6 @@ class WikiControllerTest < ActionController::TestCase
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
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
get :special, :id => 'ecookbook', :page => 'Page_index'
assert_response :success
@ -355,13 +262,6 @@ class WikiControllerTest < ActionController::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?

View File

@ -59,10 +59,56 @@ class RoutingTest < ActionController::IntegrationTest
should_route :post, "/issues/gantt", :controller => 'issues', :action => 'gantt'
should_route :get, "/projects/project-name/issues/gantt", :controller => 'issues', :action => 'gantt', :project_id => 'project-name'
should_route :post, "/projects/project-name/issues/gantt", :controller => 'issues', :action => 'gantt', :project_id => 'project-name'
should_route :get, "/issues/auto_complete", :controller => 'issues', :action => 'auto_complete'
end
context "issue reports" do
should_route :get, "/projects/567/issues/report", :controller => 'reports', :action => 'issue_report', :id => '567'
should_route :get, "/projects/567/issues/report/assigned_to", :controller => 'reports', :action => 'issue_report_details', :id => '567', :detail => 'assigned_to'
end
context "users" do
should_route :get, "/users", :controller => 'users', :action => 'index'
should_route :get, "/users/44", :controller => 'users', :action => 'show', :id => '44'
should_route :get, "/users/new", :controller => 'users', :action => 'add'
should_route :get, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
should_route :get, "/users/222/edit/membership", :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
should_route :post, "/users/new", :controller => 'users', :action => 'add'
should_route :post, "/users/444/edit", :controller => 'users', :action => 'edit', :id => '444'
should_route :post, "/users/123/memberships", :controller => 'users', :action => 'edit_membership', :id => '123'
should_route :post, "/users/123/memberships/55", :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
end
context "versions" do
should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
should_route :post, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
end
context "wikis" do
should_route :get, "/projects/567/wiki", :controller => 'wiki', :action => 'index', :id => '567'
should_route :get, "/projects/567/wiki/lalala", :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
should_route :get, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
should_route :get, "/projects/1/wiki/CookBook_documentation/history", :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation'
should_route :get, "/projects/1/wiki/CookBook_documentation/diff/2/vs/1", :controller => 'wiki', :action => 'diff', :id => '1', :page => 'CookBook_documentation', :version => '2', :version_from => '1'
should_route :get, "/projects/1/wiki/CookBook_documentation/annotate/2", :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2'
should_route :get, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
should_route :get, "/projects/567/wiki/page_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
should_route :get, "/projects/567/wiki/Page_Index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
should_route :get, "/projects/567/wiki/date_index", :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
should_route :get, "/projects/567/wiki/export", :controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
should_route :post, "/projects/567/wiki/my_page/edit", :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
should_route :post, "/projects/567/wiki/CookBook_documentation/preview", :controller => 'wiki', :action => 'preview', :id => '567', :page => 'CookBook_documentation'
should_route :post, "/projects/22/wiki/ladida/rename", :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
should_route :post, "/projects/22/wiki/ladida/destroy", :controller => 'wiki', :action => 'destroy', :id => '22', :page => 'ladida'
should_route :post, "/projects/22/wiki/ladida/protect", :controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'
end
context "administration panel" do
should_route :get, "/admin/projects", :controller => 'admin', :action => 'projects'
end
end