Project

General

Profile

Patch #1901 ยป restful_urls_start.diff

Gerrit Kaiser, 2008-09-15 03:23

View differences:

app/views/projects/changelog.rhtml
<% end %>
<% content_for :sidebar do %>
<% form_tag do %>
<% form_tag({},:method => :get) do %>
<h3><%= l(:label_change_log) %></h3>
<% @trackers.each do |tracker| %>
<label><%= check_box_tag "tracker_ids[]", tracker.id, (@selected_tracker_ids.include? tracker.id.to_s) %>
config/routes.rb
map.signin 'login', :controller => 'account', :action => 'login'
map.signout 'logout', :controller => 'account', :action => 'logout'
map.connect 'wiki/:id/:page/:action', :controller => 'wiki', :page => nil
map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow'
map.connect 'help/:ctrl/:page', :controller => 'help'
#map.connect ':controller/:action/:id/:sort_key/:sort_order'
map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get}
map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post}
map.with_options :controller => 'wiki' do |wiki_routes|
wiki_routes.with_options :conditions => {:method => :get} do |wiki_views|
wiki_views.connect 'projects/:id/wiki/:page', :action => 'special', :page => /page_index|date_index|export/i
wiki_views.connect 'projects/:id/wiki/:page', :action => 'index', :page => nil
wiki_views.connect 'projects/:id/wiki/:page/edit', :action => 'edit'
wiki_views.connect 'projects/:id/wiki/:page/rename', :action => 'rename'
wiki_views.connect 'projects/:id/wiki/:page/history', :action => 'history'
wiki_views.connect 'projects/:id/wiki/:page/diff/:version/vs/:version_from', :action => 'diff'
wiki_views.connect 'projects/:id/wiki/:page/annotate/:version', :action => 'annotate'
end
wiki_routes.connect 'projects/:id/wiki/:page/:action',
:action => /edit|rename|destroy|preview|protect/,
:conditions => {:method => :post}
end
map.with_options :controller => 'messages' do |messages_routes|
messages_routes.connect 'boards/:board_id/topics/new', :action => 'new', :conditions => {:method => :get}
messages_routes.connect 'boards/:board_id/topics/new', :action => 'new', :conditions => {:method => :post}
messages_routes.connect 'boards/:board_id/topics/:id', :action => 'show', :conditions => {:method => :get}
messages_routes.connect 'boards/:board_id/topics/:id', :action => 'reply', :conditions => {:method => :post}
messages_routes.connect 'boards/:board_id/topics/:id/edit', :action => 'edit', :conditions => {:method => :get}
messages_routes.connect 'boards/:board_id/topics/:id/edit', :action => 'edit', :conditions => {:method => :post}
messages_routes.connect 'boards/:board_id/topics/:id/replies', :action => 'reply', :conditions => {:method => :post}
messages_routes.connect 'boards/:board_id/topics/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
end
map.with_options :controller => 'boards' do |board_routes|
board_routes.connect 'projects/:project_id/boards', :action => 'index', :conditions => {:method => :get}
board_routes.connect 'projects/:project_id/boards/new', :action => 'new', :conditions => {:method => :get}
board_routes.connect 'projects/:project_id/boards', :action => 'new', :conditions => {:method => :post}
board_routes.connect 'projects/:project_id/boards/:id', :action => 'show', :conditions => {:method => :get}
board_routes.connect 'projects/:project_id/boards/:id/edit', :action => 'edit', :conditions => {:method => :get}
board_routes.connect 'projects/:project_id/boards/:id/edit', :action => 'edit', :conditions => {:method => :post}
board_routes.connect 'projects/:project_id/boards/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
end
map.with_options :controller => 'documents' do |document_routes|
document_routes.connect 'projects/:project_id/documents', :action => 'index', :conditions => {:method => :get}
document_routes.connect 'projects/:project_id/documents/new', :action => 'new', :conditions => {:method => :get}
document_routes.connect 'projects/:project_id/documents', :action => 'new', :conditions => {:method => :post}
document_routes.connect 'documents/:id', :action => 'show', :conditions => {:method => :get}
document_routes.connect 'documents/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
document_routes.connect 'documents/:id/edit', :action => 'edit', :conditions => {:method => :get}
document_routes.connect 'documents/:id/edit', :action => 'edit', :conditions => {:method => :post}
end
map.with_options :controller => 'issues' do |issues_routes|
issues_routes.with_options :conditions => {:method => :get} do |issues_views|
issues_views.connect 'issues', :action => 'index'
issues_views.connect 'issues.:format', :action => 'index'
issues_views.connect 'projects/:project_id/issues.:format', :action => 'index'
issues_views.connect 'projects/:project_id/issues/new', :action => 'new'
issues_views.connect 'projects/:project_id/issues/:copy_from/copy', :action => 'new'
issues_views.connect 'issues/:id', :action => 'show'
issues_views.connect 'issues/:id.:format', :action => 'show'
issues_views.connect 'issues/:id/edit', :action => 'edit'
issues_views.connect 'issues/:id/quoted', :action => 'reply'
issues_views.connect 'issues/:id/move', :action => 'move'
end
issues_routes.connect 'projects/:project_id/issues', :action => 'new', :conditions => {:method => :post}
issues_routes.connect 'issues/:id/:action',
:action => /edit|move|destroy/,
:conditions => {:method => :post}
end
map.with_options :controller => 'issue_relations', :conditions => {:method => :post} do |relations|
relations.connect 'issues/:issue_id/relations/:id', :action => 'new'
relations.connect 'issues/:issue_id/relations/:id/destroy', :action => 'destroy'
end
map.with_options :controller => 'reports', :action => 'issue_report', :conditions => {:method => :get} do |reports|
reports.connect 'projects/:id/issues/report'
reports.connect 'projects/:id/issues/report/:detail'
end
map.with_options :controller => 'news' do |news_routes|
news_routes.with_options :conditions => {:method => :get} do |news_views|
news_views.connect 'news', :action => 'index'
news_views.connect 'projects/:project_id/news', :action => 'index'
news_views.connect 'projects/:project_id/news.:format', :action => 'index'
news_views.connect 'news.:format', :action => 'index'
news_views.connect 'projects/:project_id/news/new', :action => 'new'
news_views.connect 'news/:id', :action => 'show'
news_views.connect 'news/:id/edit', :action => 'edit'
end
news_routes.with_options do |news_actions|
news_actions.connect 'projects/:project_id/news', :action => 'new'
news_actions.connect 'news/:id/edit', :action => 'edit'
news_actions.connect 'news/:id/destroy', :action => 'destroy'
end
end
map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new'
map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
map.with_options :controller => 'projects' do |projects|
projects.connect 'projects', :action => 'index', :conditions => {:method => :get}
projects.connect 'projects.:format', :action => 'index', :conditions => {:method => :get}
projects.connect 'projects/new', :action => 'add', :conditions => {:method => :get}
projects.connect 'projects', :action => 'add', :conditions => {:method => :post}
projects.connect 'projects/:id', :action => 'show', :conditions => {:method => :get}
projects.connect 'projects/:id/roadmap', :action => 'roadmap', :conditions => {:method => :get}
projects.connect 'projects/:id/changelog', :action => 'changelog', :conditions => {:method => :get}
projects.connect 'projects/:id/files', :action => 'list_files', :conditions => {:method => :get}
projects.connect 'projects/:id/files/new', :action => 'add_file', :conditions => {:method => :get}
projects.connect 'projects/:id/files/new', :action => 'add_file', :conditions => {:method => :post}
projects.connect 'projects/:id/versions/new', :action => 'add_version', :conditions => {:method => :get}
projects.connect 'projects/:id/versions/new', :action => 'add_version', :conditions => {:method => :post}
projects.connect 'projects/:id/categories/new', :action => 'add_issue_category', :conditions => {:method => :get}
projects.connect 'projects/:id/categories/new', :action => 'add_issue_category', :conditions => {:method => :post}
projects.connect 'projects/:id/settings', :action => 'settings', :conditions => {:method => :get}
projects.connect 'projects/:id/settings/:tab', :action => 'settings', :conditions => {:method => :get}
projects.with_options :action => 'activity', :conditions => {:method => :get} do |activity|
activity.connect 'projects/:id/activity'
activity.connect 'projects/:id/activity.:format'
activity.connect 'activity'
activity.connect 'activity.:format'
end
end
map.with_options :controller => 'repositories' do |repositories|
repositories.connect 'projects/:id/repository', :action => 'show', :conditions => {:method => :get}
repositories.connect 'projects/:id/repository/edit', :action => 'edit', :conditions => {:method => :post}
repositories.connect 'projects/:id/repository/edit', :action => 'edit', :conditions => {:method => :get}
repositories.connect 'projects/:id/repository/statistics', :action => 'stats', :conditions => {:method => :get}
repositories.connect 'projects/:id/repository/revisions', :action => 'revisions', :conditions => {:method => :get}
repositories.connect 'projects/:id/repository/revisions.:format', :action => 'revisions', :conditions => {:method => :get}
repositories.connect 'projects/:id/repository/revisions/:rev', :action => 'revision', :conditions => {:method => :get}
repositories.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff', :conditions => {:method => :get}
repositories.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff', :conditions => {:method => :get}
repositories.connect 'projects/:id/repository/:action/*path', :conditions => {:method => :get}
end
map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
#left old routes at the bottom for backwards compat
map.connect 'projects/:project_id/issues/:action', :controller => 'issues'
map.connect 'projects/:project_id/news/:action', :controller => 'news'
map.connect 'projects/:project_id/documents/:action', :controller => 'documents'
map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards'
map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages'
map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki'
map.connect 'issues/:issue_id/relations/:action/:id', :controller => 'issue_relations'
map.connect 'projects/:project_id/news/:action', :controller => 'news'
map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/
map.with_options :controller => 'repositories' do |omap|
omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse'
omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes'
omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff'
omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry'
omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate'
omap.repositories_revision 'repositories/revision/:id/:rev', :action => 'revision'
omap.connect 'repositories/revision/:id/:rev', :action => 'revision'
end
map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/
map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/
map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/
# Allow downloading Web Service WSDL as a file with an extension
# instead of a file named 'wsdl'
map.connect ':controller/service.wsdl', :action => 'wsdl'
# Install the default route as the lowest priority.
map.connect ':controller/:action/:id'
test/functional/boards_controller_test.rb
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
......
assert_not_nil assigns(:project)
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_show_routing
assert_routing(
{:method => :get, :path => '/projects/world_domination/boards/44'},
:controller => 'boards', :action => 'show', :id => '44', :project_id => 'world_domination'
)
end
def test_show
get :show, :project_id => 1, :id => 1
assert_response :success
......
assert_not_nil assigns(:project)
assert_not_nil assigns(:topics)
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_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
end
test/functional/documents_controller_test.rb
@response = ActionController::TestResponse.new
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
get :index, :project_id => 'ecookbook'
assert_response :success
......
assert_not_nil assigns(:grouped)
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
@request.session[:user_id] = 2
set_tmp_attachments_directory
......
assert_equal 'testfile.txt', document.attachments.first.filename
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
test/functional/issue_relations_controller_test.rb
require File.dirname(__FILE__) + '/../test_helper'
require 'issue_relations_controller'
# Re-raise errors caught by the controller.
class IssueRelationsController; def rescue_action(e) raise e end; end
class IssueRelationsControllerTest < Test::Unit::TestCase
def test_new_routing
assert_routing(
{:method => :post, :path => '/issues/1/relations'},
{:controller => 'issue_relations', :action => 'new', :issue_id => '1'}
)
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
end
test/functional/issues_controller_test.rb
@response = ActionController::TestResponse.new
User.current = nil
end
def test_index_routing
assert_routing(
{:method => :get, :path => '/issues'},
:controller => 'issues', :action => 'index'
)
end
def test_index
get :index
......
assert_no_tag :tag => 'a', :content => /Issue of a private subproject/
assert_no_tag :tag => 'a', :content => /Issue on project 2/
end
def test_index_with_project_routing
assert_routing(
{:method => :get, :path => '/projects/23/issues'},
:controller => 'issues', :action => 'index', :project_id => '23'
)
end
def test_index_with_project
Setting.display_subprojects_issues = 0
get :index, :project_id => 1
......
assert_tag :tag => 'a', :content => /Issue of a private subproject/
end
def test_index_with_project_routing_formatted
assert_routing(
{:method => :get, :path => 'projects/23/issues.pdf'},
:controller => 'issues', :action => 'index', :project_id => '23', :format => 'pdf'
)
assert_routing(
{:method => :get, :path => 'projects/23/issues.atom'},
:controller => 'issues', :action => 'index', :project_id => '23', :format => 'atom'
)
end
def test_index_with_project_and_filter
get :index, :project_id => 1, :set_filter => 1
assert_response :success
......
assert_equal 'text/csv', @response.content_type
end
def test_index_formatted
assert_routing(
{:method => :get, :path => 'issues.pdf'},
:controller => 'issues', :action => 'index', :format => 'pdf'
)
assert_routing(
{:method => :get, :path => 'issues.atom'},
:controller => 'issues', :action => 'index', :format => 'atom'
)
end
def test_index_pdf
get :index, :format => 'pdf'
assert_response :success
......
assert_equal 'application/atom+xml', @response.content_type
end
def test_show_routing
assert_routing(
{:method => :get, :path => '/issues/64'},
:controller => 'issues', :action => 'show', :id => '64'
)
end
def test_show_routing_formatted
assert_routing(
{:method => :get, :path => '/issues/2332.pdf'},
:controller => 'issues', :action => 'show', :id => '2332', :format => 'pdf'
)
assert_routing(
{:method => :get, :path => '/issues/23123.atom'},
:controller => 'issues', :action => 'show', :id => '23123', :format => 'atom'
)
end
def test_show_by_anonymous
get :show, :id => 1
assert_response :success
......
:child => { :tag => 'legend',
:content => /Notes/ } }
end
def test_new_routing
assert_routing(
{:method => :get, :path => '/projects/1/issues/new'},
:controller => 'issues', :action => 'new', :project_id => '1'
)
assert_recognizes(
{:controller => 'issues', :action => 'new', :project_id => '1'},
{:method => :post, :path => '/projects/1/issues'}
)
end
def test_get_new
@request.session[:user_id] = 2
......
:priority_id => 5,
:estimated_hours => '',
:custom_field_values => {'2' => 'Value for field 2'}}
assert_redirected_to 'issues/show'
assert_redirected_to :action => 'show'
issue = Issue.find_by_subject('This is the test_new issue')
assert_not_nil issue
......
:subject => 'This is the test_new issue',
:description => 'This is the description',
:priority_id => 5}
assert_redirected_to 'issues/show'
assert_redirected_to :action => 'show'
end
def test_post_new_with_required_custom_field_and_without_custom_fields_param
......
:value => 'Value for field 2'}
end
def test_copy_routing
assert_routing(
{:method => :get, :path => '/projects/world_domination/issues/567/copy'},
:controller => 'issues', :action => 'new', :project_id => 'world_domination', :copy_from => '567'
)
end
def test_copy_issue
@request.session[:user_id] = 2
get :new, :project_id => 1, :copy_from => 1
......
assert_equal orig.subject, assigns(:issue).subject
end
def test_edit_routing
assert_routing(
{:method => :get, :path => '/issues/1/edit'},
:controller => 'issues', :action => 'edit', :id => '1'
)
assert_recognizes( #TODO: use a PUT on the issue URI isntead, need to adjust form
{:controller => 'issues', :action => 'edit', :id => '1'},
{:method => :post, :path => '/issues/1/edit'}
)
end
def test_get_edit
@request.session[:user_id] = 2
get :edit, :id => 1
......
:attributes => { :selected => 'selected' } }
end
def test_reply_routing
assert_routing(
{:method => :get, :path => '/issues/1/quoted'},
:controller => 'issues', :action => 'reply', :id => '1'
)
end
def test_reply_to_issue
@request.session[:user_id] = 2
get :reply, :id => 1
......
}
end
end
assert_redirected_to 'issues/show/1'
assert_redirected_to :action => 'show', :id => '1'
issue.reload
assert_equal new_subject, issue.subject
# Make sure custom fields were not cleared
......
}
end
end
assert_redirected_to 'issues/show/1'
assert_redirected_to :action => 'show', :id => '1'
issue.reload
assert_equal 'New custom value', issue.custom_value_for(2).value
......
:notes => 'Assigned to dlopper',
:time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
end
assert_redirected_to 'issues/show/1'
assert_redirected_to :action => 'show', :id => '1'
issue.reload
assert_equal 2, issue.status_id
j = issue.journals.find(:first, :order => 'id DESC')
......
post :edit,
:id => 1,
:notes => notes
assert_redirected_to 'issues/show/1'
assert_redirected_to :action => 'show', :id => '1'
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
assert_equal notes, j.notes
assert_equal 0, j.details.size
......
:notes => '2.5 hours added',
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
end
assert_redirected_to 'issues/show/1'
assert_redirected_to :action => 'show', :id => '1'
issue = Issue.find(1)
......
:id => 1,
:notes => '',
:attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain')}}
assert_redirected_to 'issues/show/1'
assert_redirected_to :action => 'show', :id => '1'
j = Issue.find(1).journals.find(:first, :order => 'id DESC')
assert j.notes.blank?
assert_equal 1, j.details.size
......
post :edit,
:id => 1,
:notes => ''
assert_redirected_to 'issues/show/1'
assert_redirected_to :action => 'show', :id => '1'
issue.reload
assert issue.journals.empty?
......
assert_nil Issue.find(2).assigned_to
end
def test_move_routing
assert_routing(
{:method => :get, :path => '/issues/1/move'},
:controller => 'issues', :action => 'move', :id => '1'
)
assert_recognizes(
{:controller => 'issues', :action => 'move', :id => '1'},
{:method => :post, :path => '/issues/1/move'}
)
end
def test_move_one_issue_to_another_project
@request.session[:user_id] = 1
post :move, :id => 1, :new_project_id => 2
assert_redirected_to 'projects/ecookbook/issues'
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 2, Issue.find(1).project_id
end
def test_bulk_move_to_another_project
@request.session[:user_id] = 1
post :move, :ids => [1, 2], :new_project_id => 2
assert_redirected_to 'projects/ecookbook/issues'
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
# Issues moved to project 2
assert_equal 2, Issue.find(1).project_id
assert_equal 2, Issue.find(2).project_id
......
def test_bulk_move_to_another_tracker
@request.session[:user_id] = 1
post :move, :ids => [1, 2], :new_tracker_id => 2
assert_redirected_to 'projects/ecookbook/issues'
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal 2, Issue.find(1).tracker_id
assert_equal 2, Issue.find(2).tracker_id
end
......
assert_response :success
assert_template 'context_menu'
assert_tag :tag => 'a', :content => 'Edit',
:attributes => { :href => '/issues/edit/1',
:attributes => { :href => '/issues/1/edit',
:class => 'icon-edit' }
assert_tag :tag => 'a', :content => 'Closed',
:attributes => { :href => '/issues/edit/1?issue%5Bstatus_id%5D=5',
:attributes => { :href => '/issues/1/edit?issue%5Bstatus_id%5D=5',
:class => '' }
assert_tag :tag => 'a', :content => 'Immediate',
:attributes => { :href => '/issues/bulk_edit?ids%5B%5D=1&amp;priority_id=8',
......
:attributes => { :href => '/issues/bulk_edit?assigned_to_id=3&amp;ids%5B%5D=1',
:class => '' }
assert_tag :tag => 'a', :content => 'Copy',
:attributes => { :href => '/projects/ecookbook/issues/new?copy_from=1',
:attributes => { :href => '/projects/ecookbook/issues/1/copy',
:class => 'icon-copy' }
assert_tag :tag => 'a', :content => 'Move',
:attributes => { :href => '/issues/move?ids%5B%5D=1',
......
:class => 'icon-del disabled' }
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
post :destroy, :id => 2
assert_redirected_to 'projects/ecookbook/issues'
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_nil Issue.find_by_id(2)
end
......
def test_destroy_issues_and_destroy_time_entries
@request.session[:user_id] = 2
post :destroy, :ids => [1, 3], :todo => 'destroy'
assert_redirected_to 'projects/ecookbook/issues'
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
assert_nil TimeEntry.find_by_id([1, 2])
end
......
def test_destroy_issues_and_assign_time_entries_to_project
@request.session[:user_id] = 2
post :destroy, :ids => [1, 3], :todo => 'nullify'
assert_redirected_to 'projects/ecookbook/issues'
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
assert_nil TimeEntry.find(1).issue_id
assert_nil TimeEntry.find(2).issue_id
......
def test_destroy_issues_and_reassign_time_entries_to_another_issue
@request.session[:user_id] = 2
post :destroy, :ids => [1, 3], :todo => 'reassign', :reassign_to_id => 2
assert_redirected_to 'projects/ecookbook/issues'
assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert !(Issue.find_by_id(1) || Issue.find_by_id(3))
assert_equal 2, TimeEntry.find(1).issue_id
assert_equal 2, TimeEntry.find(2).issue_id
......
a = issue.attachments.size
@request.session[:user_id] = 2
post :destroy_attachment, :id => 3, :attachment_id => 1
assert_redirected_to 'issues/show/3'
assert_redirected_to :action => 'show', :id => '3'
assert_nil Attachment.find_by_id(1)
issue.reload
assert_equal((a-1), issue.attachments.size)
test/functional/members_controller_test.rb
require File.dirname(__FILE__) + '/../test_helper'
require 'members_controller'
# Re-raise errors caught by the controller.
class MembersController; def rescue_action(e) raise e end; end
class MembersControllerTest < Test::Unit::TestCase
def test_members_routing
assert_routing(
{:method => :post, :path => 'projects/5234/members/new'},
:controller => 'members', :action => 'new', :id => '5234'
)
end
end
test/functional/messages_controller_test.rb
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
......
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
......
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
......
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' }
......
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
test/functional/news_controller_test.rb
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
......
assert_not_nil assigns(:newss)
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_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
......
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
......
assert_equal Project.find(1), news.project
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
......
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
test/functional/projects_controller_test.rb
@response = ActionController::TestResponse.new
@request.session[:user_id] = nil
end
def test_index_routing
assert_routing(
{:method => :get, :path => '/projects'},
:controller => 'projects', :action => 'index'
)
end
def test_index
get :index
assert_response :success
......
assert assigns(:project_tree).keys.include?(Project.find(1))
# Subproject in corresponding value
assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3))
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'
......
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'}
)
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
......
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
......
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
{:method => :post, :path => 'projects/64/categories/new'},
:controller => 'projects', :action => 'add_issue_category', :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
......
assert_redirected_to 'admin/projects'
assert_nil Project.find_by_id(1)
end
def test_list_files
get :list_files, :id => 1
assert_response :success
assert_template 'list_files'
assert_not_nil assigns(:versions)
end
def test_changelog
get :changelog, :id => 1
assert_response :success
assert_template 'changelog'
assert_not_nil assigns(:versions)
def test_list_files_routing
assert_routing(
{:method => :get, :path => '/projects/33/files'},
:controller => 'projects', :action => 'list_files', :id => '33'
)
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_list_files
get :list_files, :id => 1
assert_response :success
assert_template 'list_files'
assert_not_nil assigns(:versions)
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
......
# 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
......
}
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
......
}
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
test/functional/reports_controller_test.rb
require File.dirname(__FILE__) + '/../test_helper'
require 'reports_controller'
# Re-raise errors caught by the controller.
class ReportsController; def rescue_action(e) raise e end; end
class ReportsControllerTest < Test::Unit::TestCase
def test_issue_report_routing
assert_routing(
{:method => :get, :path => '/projects/567/issues/report'},
:controller => 'reports', :action => 'issue_report', :id => '567'
)
assert_routing(
{:method => :get, :path => '/projects/567/issues/report/assigned_to'},
:controller => 'reports', :action => 'issue_report', :id => '567', :detail => 'assigned_to'
)
end
end
test/functional/repositories_controller_test.rb
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
assert_template 'revisions'
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_with_before_nil_and_afer_normal
get :revision, {:id => 1, :rev => 1}
assert_response :success
assert_template 'revision'
assert_no_tag :tag => "div", :attributes => { :class => "contextual" },
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook/0'}
:child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/0'}
}
assert_tag :tag => "div", :attributes => { :class => "contextual" },
:child => { :tag => "a", :attributes => { :href => '/repositories/revision/ecookbook/2'}
:child => { :tag => "a", :attributes => { :href => '/projects/ecookbook/repository/revisions/2'}
}
end
def test_diff_routing
assert_routing(
{:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff'},
:controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457'
)
end
def test_unified_diff_routing
assert_routing(
{:method => :get, :path => '/projects/restmine/repository/revisions/2457/diff.diff'},
:controller => 'repositories', :action => 'diff', :id => 'restmine', :rev => '2457', :format => 'diff'
)
end
def test_diff_path_routing
assert_routing(
{:method => :get, :path => '/projects/restmine/repository/diff/path/to/file.c'},
:controller => 'repositories', :action => 'diff', :id => 'restmine', :path => %w[path to file.c]
)
end
def test_browse_routing
assert_routing(
{:method => :get, :path => '/projects/restmine/repository/browse/path/to/dir'},
:controller => 'repositories', :action => 'browse', :id => 'restmine', :path => %w[path to dir]
)
end
def test_entry_routing
assert_routing(
{:method => :get, :path => '/projects/restmine/repository/entry/path/to/file.c'},
:controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c]
)
end
def test_annotate_routing
assert_routing(
{:method => :get, :path => '/projects/restmine/repository/annotate/path/to/file.c'},
:controller => 'repositories', :action => 'annotate', :id => 'restmine', :path => %w[path to file.c]
)
end
def test_changesrouting
assert_routing(
{:method => :get, :path => '/projects/restmine/repository/changes/path/to/file.c'},
:controller => 'repositories', :action => 'changes', :id => 'restmine', :path => %w[path to file.c]
)
end
def test_statistics_routing
assert_routing(
{:method => :get, :path => '/projects/restmine/repository/statistics'},
:controller => 'repositories', :action => 'stats', :id => 'restmine'
)
end
def test_graph_commits_per_month
get :graph, :id => 1, :graph => 'commits_per_month'
assert_response :success
test/functional/wiki_controller_test.rb
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
......
# 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
......
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,
......
: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',
......
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
......
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
......
: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
......
: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')
......
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'
... This diff was truncated because it exceeds the maximum size that can be displayed.
    (1-1/1)