Commit 9b595c68 authored by Eric Davis's avatar Eric Davis

Refactor: Move the rest of the routing tests to RoutingTest.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3687 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 0fc884cf
......@@ -34,21 +34,6 @@ class AttachmentsControllerTest < ActionController::TestCase
User.current = nil
end
def test_routing
assert_routing('/attachments/1', :controller => 'attachments', :action => 'show', :id => '1')
assert_routing('/attachments/1/filename.ext', :controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext')
assert_routing('/attachments/download/1', :controller => 'attachments', :action => 'download', :id => '1')
assert_routing('/attachments/download/1/filename.ext', :controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext')
end
def test_recognizes
assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1'}, '/attachments/1')
assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1'}, '/attachments/show/1')
assert_recognizes({:controller => 'attachments', :action => 'show', :id => '1', :filename => 'filename.ext'}, '/attachments/1/filename.ext')
assert_recognizes({:controller => 'attachments', :action => 'download', :id => '1'}, '/attachments/download/1')
assert_recognizes({:controller => 'attachments', :action => 'download', :id => '1', :filename => 'filename.ext'},'/attachments/download/1/filename.ext')
end
def test_show_diff
get :show, :id => 5
assert_response :success
......
......@@ -31,13 +31,6 @@ class BoardsControllerTest < ActionController::TestCase
User.current = nil
end
def test_index_routing
assert_routing(
{:method => :get, :path => '/projects/world_domination/boards'},
:controller => 'boards', :action => 'index', :project_id => 'world_domination'
)
end
def test_index
get :index, :project_id => 1
assert_response :success
......@@ -60,17 +53,6 @@ class BoardsControllerTest < ActionController::TestCase
assert_not_nil assigns(:topics)
end
def test_new_routing
assert_routing(
{:method => :get, :path => '/projects/world_domination/boards/new'},
:controller => 'boards', :action => 'new', :project_id => 'world_domination'
)
assert_recognizes(
{:controller => 'boards', :action => 'new', :project_id => 'world_domination'},
{:method => :post, :path => '/projects/world_domination/boards'}
)
end
def test_post_new
@request.session[:user_id] = 2
assert_difference 'Board.count' do
......@@ -79,17 +61,6 @@ class BoardsControllerTest < ActionController::TestCase
assert_redirected_to '/projects/ecookbook/settings/boards'
end
def test_show_routing
assert_routing(
{:method => :get, :path => '/projects/world_domination/boards/44'},
:controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination'
)
assert_routing(
{:method => :get, :path => '/projects/world_domination/boards/44.atom'},
:controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination', :format => 'atom'
)
end
def test_show
get :show, :project_id => 1, :id => 1
assert_response :success
......@@ -108,17 +79,6 @@ class BoardsControllerTest < ActionController::TestCase
assert_not_nil assigns(:messages)
end
def test_edit_routing
assert_routing(
{:method => :get, :path => '/projects/world_domination/boards/44/edit'},
:controller => 'boards', :action => 'edit', :id => '44', :project_id => 'world_domination'
)
assert_recognizes(#TODO: use PUT method to board_path, modify form accordingly
{:controller => 'boards', :action => 'edit', :id => '44', :project_id => 'world_domination'},
{:method => :post, :path => '/projects/world_domination/boards/44/edit'}
)
end
def test_post_edit
@request.session[:user_id] = 2
assert_no_difference 'Board.count' do
......@@ -128,13 +88,6 @@ class BoardsControllerTest < ActionController::TestCase
assert_equal 'Testing', Board.find(2).name
end
def test_destroy_routing
assert_routing(#TODO: use DELETE method to board_path, modify form accoringly
{:method => :post, :path => '/projects/world_domination/boards/44/destroy'},
:controller => 'boards', :action => 'destroy', :id => '44', :project_id => 'world_domination'
)
end
def test_post_destroy
@request.session[:user_id] = 2
assert_difference 'Board.count', -1 do
......
......@@ -31,13 +31,6 @@ class DocumentsControllerTest < ActionController::TestCase
User.current = nil
end
def test_index_routing
assert_routing(
{:method => :get, :path => '/projects/567/documents'},
:controller => 'documents', :action => 'index', :project_id => '567'
)
end
def test_index
# Sets a default category
e = Enumeration.find_by_name('Technical documentation')
......@@ -54,17 +47,6 @@ class DocumentsControllerTest < ActionController::TestCase
:content => 'Technical documentation'}
end
def test_new_routing
assert_routing(
{:method => :get, :path => '/projects/567/documents/new'},
:controller => 'documents', :action => 'new', :project_id => '567'
)
assert_recognizes(
{:controller => 'documents', :action => 'new', :project_id => '567'},
{:method => :post, :path => '/projects/567/documents'}
)
end
def test_new_with_one_attachment
ActionMailer::Base.deliveries.clear
Setting.notified_events << 'document_added'
......@@ -87,31 +69,6 @@ class DocumentsControllerTest < ActionController::TestCase
assert_equal 1, ActionMailer::Base.deliveries.size
end
def test_edit_routing
assert_routing(
{:method => :get, :path => '/documents/22/edit'},
:controller => 'documents', :action => 'edit', :id => '22'
)
assert_recognizes(#TODO: should be using PUT on document URI
{:controller => 'documents', :action => 'edit', :id => '567'},
{:method => :post, :path => '/documents/567/edit'}
)
end
def test_show_routing
assert_routing(
{:method => :get, :path => '/documents/22'},
:controller => 'documents', :action => 'show', :id => '22'
)
end
def test_destroy_routing
assert_recognizes(#TODO: should be using DELETE on document URI
{:controller => 'documents', :action => 'destroy', :id => '567'},
{:method => :post, :path => '/documents/567/destroy'}
)
end
def test_destroy
@request.session[:user_id] = 2
post :destroy, :id => 1
......
......@@ -32,17 +32,6 @@ class IssueCategoriesControllerTest < ActionController::TestCase
@request.session[:user_id] = 2
end
def test_new_routing
assert_routing(
{:method => :get, :path => 'projects/test/issue_categories/new'},
:controller => 'issue_categories', :action => 'new', :project_id => 'test'
)
assert_routing(
{:method => :post, :path => 'projects/test/issue_categories/new'},
:controller => 'issue_categories', :action => 'new', :project_id => 'test'
)
end
def test_get_new
@request.session[:user_id] = 2 # manager
get :new, :project_id => '1'
......
......@@ -25,13 +25,6 @@ class IssueRelationsControllerTest < ActionController::TestCase
User.current = nil
end
def test_new_routing
assert_routing(
{:method => :post, :path => '/issues/1/relations'},
{:controller => 'issue_relations', :action => 'new', :issue_id => '1'}
)
end
def test_new
assert_difference 'IssueRelation.count' do
@request.session[:user_id] = 3
......@@ -69,13 +62,6 @@ class IssueRelationsControllerTest < ActionController::TestCase
end
end
def test_destroy_routing
assert_recognizes( #TODO: use DELETE on issue URI
{:controller => 'issue_relations', :action => 'destroy', :issue_id => '1', :id => '23'},
{:method => :post, :path => '/issues/1/relations/23/destroy'}
)
end
def test_destroy
assert_difference 'IssueRelation.count', -1 do
@request.session[:user_id] = 3
......
......@@ -33,13 +33,6 @@ class MembersControllerTest < ActionController::TestCase
@request.session[:user_id] = 2
end
def test_members_routing
assert_routing(
{:method => :post, :path => 'projects/5234/members/new'},
:controller => 'members', :action => 'new', :id => '5234'
)
end
def test_create
assert_difference 'Member.count' do
post :new, :id => 1, :member => {:role_ids => [1], :user_id => 7}
......
......@@ -31,13 +31,6 @@ class MessagesControllerTest < ActionController::TestCase
User.current = nil
end
def test_show_routing
assert_routing(
{:method => :get, :path => '/boards/22/topics/2'},
:controller => 'messages', :action => 'show', :id => '2', :board_id => '22'
)
end
def test_show
get :show, :board_id => 1, :id => 1
assert_response :success
......@@ -77,17 +70,6 @@ class MessagesControllerTest < ActionController::TestCase
assert_response 404
end
def test_new_routing
assert_routing(
{:method => :get, :path => '/boards/lala/topics/new'},
:controller => 'messages', :action => 'new', :board_id => 'lala'
)
assert_recognizes(#TODO: POST to collection, need to adjust form accordingly
{:controller => 'messages', :action => 'new', :board_id => 'lala'},
{:method => :post, :path => '/boards/lala/topics/new'}
)
end
def test_get_new
@request.session[:user_id] = 2
get :new, :board_id => 1
......@@ -120,17 +102,6 @@ class MessagesControllerTest < ActionController::TestCase
assert mail.bcc.include?('dlopper@somenet.foo')
end
def test_edit_routing
assert_routing(
{:method => :get, :path => '/boards/lala/topics/22/edit'},
:controller => 'messages', :action => 'edit', :board_id => 'lala', :id => '22'
)
assert_recognizes( #TODO: use PUT to topic_path, modify form accordingly
{:controller => 'messages', :action => 'edit', :board_id => 'lala', :id => '22'},
{:method => :post, :path => '/boards/lala/topics/22/edit'}
)
end
def test_get_edit
@request.session[:user_id] = 2
get :edit, :board_id => 1, :id => 1
......@@ -149,13 +120,6 @@ class MessagesControllerTest < ActionController::TestCase
assert_equal 'New body', message.content
end
def test_reply_routing
assert_recognizes(
{:controller => 'messages', :action => 'reply', :board_id => '22', :id => '555'},
{:method => :post, :path => '/boards/22/topics/555/replies'}
)
end
def test_reply
@request.session[:user_id] = 2
post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' }
......@@ -164,13 +128,6 @@ class MessagesControllerTest < ActionController::TestCase
assert Message.find_by_subject('Test reply')
end
def test_destroy_routing
assert_recognizes(#TODO: use DELETE to topic_path, adjust form accordingly
{:controller => 'messages', :action => 'destroy', :board_id => '22', :id => '555'},
{:method => :post, :path => '/boards/22/topics/555/destroy'}
)
end
def test_destroy_topic
@request.session[:user_id] = 2
post :destroy, :board_id => 1, :id => 1
......
......@@ -31,20 +31,6 @@ class NewsControllerTest < ActionController::TestCase
User.current = nil
end
def test_index_routing
assert_routing(
{:method => :get, :path => '/news'},
:controller => 'news', :action => 'index'
)
end
def test_index_routing_formatted
assert_routing(
{:method => :get, :path => '/news.atom'},
:controller => 'news', :action => 'index', :format => 'atom'
)
end
def test_index
get :index
assert_response :success
......@@ -53,20 +39,6 @@ class NewsControllerTest < ActionController::TestCase
assert_nil assigns(:project)
end
def test_index_with_project_routing
assert_routing(
{:method => :get, :path => '/projects/567/news'},
:controller => 'news', :action => 'index', :project_id => '567'
)
end
def test_index_with_project_routing_formatted
assert_routing(
{:method => :get, :path => '/projects/567/news.atom'},
:controller => 'news', :action => 'index', :project_id => '567', :format => 'atom'
)
end
def test_index_with_project
get :index, :project_id => 1
assert_response :success
......@@ -74,13 +46,6 @@ class NewsControllerTest < ActionController::TestCase
assert_not_nil assigns(:newss)
end
def test_show_routing
assert_routing(
{:method => :get, :path => '/news/2'},
:controller => 'news', :action => 'show', :id => '2'
)
end
def test_show
get :show, :id => 1
assert_response :success
......@@ -93,17 +58,6 @@ class NewsControllerTest < ActionController::TestCase
assert_response 404
end
def test_new_routing
assert_routing(
{:method => :get, :path => '/projects/567/news/new'},
:controller => 'news', :action => 'new', :project_id => '567'
)
assert_recognizes(
{:controller => 'news', :action => 'new', :project_id => '567'},
{:method => :post, :path => '/projects/567/news'}
)
end
def test_get_new
@request.session[:user_id] = 2
get :new, :project_id => 1
......@@ -129,17 +83,6 @@ class NewsControllerTest < ActionController::TestCase
assert_equal 1, ActionMailer::Base.deliveries.size
end
def test_edit_routing
assert_routing(
{:method => :get, :path => '/news/234'},
:controller => 'news', :action => 'show', :id => '234'
)
assert_recognizes(#TODO: PUT to news URI instead, need to modify form
{:controller => 'news', :action => 'edit', :id => '567'},
{:method => :post, :path => '/news/567/edit'}
)
end
def test_get_edit
@request.session[:user_id] = 2
get :edit, :id => 1
......@@ -197,13 +140,6 @@ class NewsControllerTest < ActionController::TestCase
assert_equal comments_count - 1, News.find(1).comments.size
end
def test_destroy_routing
assert_recognizes(#TODO: should use DELETE to news URI, need to change form
{:controller => 'news', :action => 'destroy', :id => '567'},
{:method => :post, :path => '/news/567/destroy'}
)
end
def test_destroy
@request.session[:user_id] = 2
post :destroy, :id => 1
......
......@@ -34,13 +34,6 @@ class ProjectsControllerTest < ActionController::TestCase
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
......@@ -59,13 +52,6 @@ class ProjectsControllerTest < ActionController::TestCase
assert_no_tag :a, :content => /Private child of eCookbook/
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'
assert_response :success
......@@ -74,21 +60,6 @@ class ProjectsControllerTest < ActionController::TestCase
assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
end
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
context "#add" do
context "by admin user" do
setup do
......@@ -248,13 +219,6 @@ class ProjectsControllerTest < ActionController::TestCase
end
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
......@@ -295,17 +259,6 @@ class ProjectsControllerTest < ActionController::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
......@@ -313,13 +266,6 @@ class ProjectsControllerTest < ActionController::TestCase
assert_template 'settings'
end
def test_edit_routing
assert_routing(
{:method => :post, :path => '/projects/4223/edit'},
:controller => 'projects', :action => 'edit', :id => '4223'
)
end
def test_edit
@request.session[:user_id] = 2 # manager
post :edit, :id => 1, :project => {:name => 'Test changed name',
......@@ -329,18 +275,6 @@ class ProjectsControllerTest < ActionController::TestCase
assert_equal 'Test changed name', project.name
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
......@@ -377,17 +311,6 @@ class ProjectsControllerTest < ActionController::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
......@@ -418,20 +341,6 @@ class ProjectsControllerTest < ActionController::TestCase
:attributes => { :href => '/attachments/download/9/version_file.zip' }
end
def test_list_files_routing
assert_routing(
{:method => :get, :path => '/projects/33/files'},
:controller => 'projects', :action => 'list_files', :id => '33'
)
end
def test_roadmap_routing
assert_routing(
{:method => :get, :path => 'projects/33/roadmap'},
:controller => 'projects', :action => 'roadmap', :id => '33'
)
end
def test_roadmap
get :roadmap, :id => 1
assert_response :success
......@@ -462,21 +371,6 @@ class ProjectsControllerTest < ActionController::TestCase
# Version on subproject appears
assert assigns(:versions).include?(Version.find(4))
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
......@@ -513,10 +407,6 @@ class ProjectsControllerTest < ActionController::TestCase
}
end
def test_global_activity_routing
assert_routing({:method => :get, :path => '/activity'}, :controller => 'projects', :action => 'activity', :id => nil)
end
def test_global_activity
get :activity
assert_response :success
......@@ -553,24 +443,12 @@ class ProjectsControllerTest < ActionController::TestCase
}
end
def test_global_activity_atom_routing
assert_routing({:method => :get, :path => '/activity.atom'}, :controller => 'projects', :action => 'activity', :id => nil, :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_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
......@@ -578,14 +456,6 @@ class ProjectsControllerTest < ActionController::TestCase
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
......@@ -643,11 +513,6 @@ class ProjectsControllerTest < ActionController::TestCase
assert_template 'show'
end
def test_reset_activities_routing
assert_routing({:method => :delete, :path => 'projects/64/reset_activities'},
:controller => 'projects', :action => 'reset_activities', :id => '64')
end
def test_reset_activities
@request.session[:user_id] = 2 # manager
project_activity = TimeEntryActivity.new({
......@@ -694,11 +559,6 @@ class ProjectsControllerTest < ActionController::TestCase
assert_equal 3, TimeEntry.find_all_by_activity_id_and_project_id(9, 1).size, "TimeEntries still assigned to project specific activity"
end
def test_save_activities_routing
assert_routing({:method => :post, :path => 'projects/64/activities/save'},
:controller => 'projects', :action => 'save_activities', :id => '64')
end
def test_save_activities_to_override_system_activities
@request.session[:user_id] = 2 # manager
billable_field = TimeEntryActivityCustomField.find_by_name("Billable")
......
......@@ -31,38 +31,6 @@ class RepositoriesControllerTest < ActionController::TestCase
User.current = nil
end
def test_show_routing
assert_routing(
{:method => :get, :path => '/projects/redmine/repository'},
:controller => 'repositories', :action => 'show', :id => 'redmine'
)
end
def test_edit_routing
assert_routing(
{:method => :get, :path => '/projects/world_domination/repository/edit'},
:controller => 'repositories', :action => 'edit', :id => 'world_domination'
)
assert_routing(
{:method => :post, :path => '/projects/world_domination/repository/edit'},
:controller => 'repositories', :action => 'edit', :id => 'world_domination'
)
end
def test_revisions_routing
assert_routing(
{:method => :get, :path => '/projects/redmine/repository/revisions'},
:controller => 'repositories', :action => 'revisions', :id => 'redmine'
)
end
def test_revisions_atom_routing
assert_routing(
{:method => :get, :path => '/projects/redmine/repository/revisions.atom'},
:controller => 'repositories', :action => 'revisions', :id => 'redmine', :format => 'atom'
)
end
def test_revisions
get :revisions, :id => 1
assert_response :success
......@@ -70,13 +38,6 @@ class RepositoriesControllerTest < ActionController::TestCase
assert_not_nil assigns(:changesets)
end
def test_revision_routing
assert_routing(
{:method => :get, :path => '/projects/restmine/repository/revisions/2457'},
:controller => 'repositories', :action => 'revision', :id => 'restmine', :rev => '2457'
)
end
def test_revision
get :revision, :id => 1, :rev => 1
assert_response :success
......@@ -96,90 +57,6 @@ class RepositoriesControllerTest < ActionController::TestCase
}
end
def test_diff_routing
assert_routing(