GitLab wurde erfolgreich aktualisiert. Durch regelmäßige Updates bleibt das THM GitLab sicher. Danke für Ihre Geduld.

Commit e0986842 authored by edavis10's avatar edavis10

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: https://svn.redmine.org/redmine/trunk@2317 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 569b817b
......@@ -243,39 +243,36 @@ module ApplicationHelper
url_param.clear if url_param.has_key?(:set_filter)
html = ''
html << link_to_remote(('&#171; ' + l(:label_previous)),
{:update => 'content',
:url => url_param.merge(page_param => paginator.current.previous),
:complete => 'window.scrollTo(0,0)'},
{:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous
if paginator.current.previous
html << link_to_remote_content_update('&#171; ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' '
end
html << (pagination_links_each(paginator, options) do |n|
link_to_remote(n.to_s,
{:url => {:params => url_param.merge(page_param => n)},
:update => 'content',
:complete => 'window.scrollTo(0,0)'},
{:href => url_for(:params => url_param.merge(page_param => n))})
link_to_remote_content_update(n.to_s, url_param.merge(page_param => n))
end || '')
html << ' ' + link_to_remote((l(:label_next) + ' &#187;'),
{:update => 'content',
:url => url_param.merge(page_param => paginator.current.next),
:complete => 'window.scrollTo(0,0)'},
{:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next
if paginator.current.next
html << ' ' + link_to_remote_content_update((l(:label_next) + ' &#187;'), url_param.merge(page_param => paginator.current.next))
end
unless count.nil?
html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ')
html << [
" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})",
per_page_links(paginator.items_per_page)
].compact.join(' | ')
end
html
end
def per_page_links(selected=nil)
url_param = params.dup
url_param.clear if url_param.has_key?(:set_filter)
links = Setting.per_page_options_array.collect do |n|
n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)},
n == selected ? n : link_to_remote(n, {:update => "content",
:url => params.dup.merge(:per_page => n),
:method => :get},
{:href => url_for(url_param.merge(:per_page => n))})
end
links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
......@@ -664,4 +661,12 @@ module ApplicationHelper
extend helper
return self
end
def link_to_remote_content_update(text, url_params)
link_to_remote(text,
{:url => url_params, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'},
{:href => url_for(:params => url_params)}
)
end
end
......@@ -121,7 +121,7 @@ module SortHelper
url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options)
link_to_remote(caption,
{:update => "content", :url => url_options},
{:update => "content", :url => url_options, :method => :get},
{:href => url_for(url_options)}) +
(icon ? nbsp(2) + image_tag(icon) : '')
end
......
......@@ -26,7 +26,7 @@
<% 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) %>
......
......@@ -6,7 +6,9 @@
<h2><%= l(:label_spent_time) %></h2>
<% form_remote_tag( :url => {}, :method => :get, :update => 'content' ) do %>
<% form_remote_tag( :url => {}, :html => {:method => :get}, :method => :get, :update => 'content' ) do %>
<%# TOOD: remove the project_id and issue_id hidden fields, that information is
already in the URI %>
<%= hidden_field_tag 'project_id', params[:project_id] %>
<%= hidden_field_tag 'issue_id', params[:issue_id] if @issue %>
<%= render :partial => 'date_range' %>
......
......@@ -6,10 +6,11 @@
<h2><%= l(:label_spent_time) %></h2>
<% form_remote_tag(:url => {}, :update => 'content') do %>
<% form_remote_tag(:url => {}, :html => {:method => :get}, :method => :get, :update => 'content') do %>
<% @criterias.each do |criteria| %>
<%= hidden_field_tag 'criterias[]', criteria, :id => nil %>
<% end %>
<%# TODO: get rid of the project_id field, that should already be in the URL %>
<%= hidden_field_tag 'project_id', params[:project_id] %>
<%= render :partial => 'date_range' %>
......@@ -25,6 +26,7 @@
:id => nil,
:disabled => (@criterias.length >= 3)) %>
<%= link_to_remote l(:button_clear), {:url => {:project_id => @project, :period_type => params[:period_type], :period => params[:period], :from => @from, :to => @to, :columns => @columns},
:method => :get,
:update => 'content'
}, :class => 'icon icon-reload' %></p>
<% end %>
......
<% labelled_tabular_form_for :user, @user, :url => { :action => "edit" } do |f| %>
<% labelled_tabular_form_for :user, @user, :url => { :action => "edit", :tab => nil } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>
......@@ -12,39 +12,241 @@ ActionController::Routing::Routes.draw do |map|
end
map.home '', :controller => 'welcome'
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 'time_entries/:id/edit', :action => 'edit', :controller => 'timelog'
map.connect 'projects/:project_id/time_entries/new', :action => 'edit', :controller => 'timelog'
map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog'
map.with_options :controller => 'timelog' do |timelog|
timelog.connect 'projects/:project_id/time_entries', :action => 'details'
timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details|
time_details.connect 'time_entries'
time_details.connect 'time_entries.:format'
time_details.connect 'issues/:issue_id/time_entries'
time_details.connect 'issues/:issue_id/time_entries.:format'
time_details.connect 'projects/:project_id/time_entries.:format'
time_details.connect 'projects/:project_id/issues/:issue_id/time_entries'
time_details.connect 'projects/:project_id/issues/:issue_id/time_entries.:format'
end
timelog.connect 'projects/:project_id/time_entries/report', :action => 'report'
timelog.with_options :action => 'report',:conditions => {:method => :get} do |time_report|
time_report.connect 'time_entries/report'
time_report.connect 'time_entries/report.:format'
time_report.connect 'projects/:project_id/time_entries/report.:format'
end
timelog.with_options :action => 'edit', :conditions => {:method => :get} do |time_edit|
time_edit.connect 'issues/:issue_id/time_entries/new'
end
timelog.connect 'time_entries/:id/destroy', :action => 'destroy', :conditions => {:method => :post}
end
map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post}
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.with_options :conditions => {:method => :get} do |messages_views|
messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
end
messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/
end
end
map.with_options :controller => 'boards' do |board_routes|
board_routes.with_options :conditions => {:method => :get} do |board_views|
board_views.connect 'projects/:project_id/boards', :action => 'index'
board_views.connect 'projects/:project_id/boards/new', :action => 'new'
board_views.connect 'projects/:project_id/boards/:id', :action => 'show'
board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit'
end
board_routes.with_options :conditions => {:method => :post} do |board_actions|
board_actions.connect 'projects/:project_id/boards', :action => 'new'
board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/
end
end
map.with_options :controller => 'documents' do |document_routes|
document_routes.with_options :conditions => {:method => :get} do |document_views|
document_views.connect 'projects/:project_id/documents', :action => 'index'
document_views.connect 'projects/:project_id/documents/new', :action => 'new'
document_views.connect 'documents/:id', :action => 'show'
document_views.connect 'documents/:id/edit', :action => 'edit'
end
document_routes.with_options :conditions => {:method => :post} do |document_actions|
document_actions.connect 'projects/:project_id/documents', :action => 'new'
document_actions.connect 'documents/:id/:action', :action => /destroy|edit/
end
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/move', :action => 'move'
end
issues_routes.with_options :conditions => {:method => :post} do |issues_actions|
issues_actions.connect 'projects/:project_id/issues', :action => 'new'
issues_actions.connect 'issues/:id/quoted', :action => 'reply'
issues_actions.connect 'issues/:id/:action',
:action => /edit|move|destroy/
end
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.with_options :controller => 'users' do |users|
users.with_options :conditions => {:method => :get} do |user_views|
user_views.connect 'users', :action => 'list'
user_views.connect 'users', :action => 'index'
user_views.connect 'users/new', :action => 'add'
user_views.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil
end
users.with_options :conditions => {:method => :post} do |user_actions|
user_actions.connect 'users', :action => 'add'
user_actions.connect 'users/new', :action => 'add'
user_actions.connect 'users/:id/edit', :action => 'edit'
user_actions.connect 'users/:id/memberships', :action => 'edit_membership'
user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership'
user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership'
end
end
map.with_options :controller => 'projects' do |projects|
projects.with_options :conditions => {:method => :get} do |project_views|
project_views.connect 'projects', :action => 'index'
project_views.connect 'projects.:format', :action => 'index'
project_views.connect 'projects/new', :action => 'add'
project_views.connect 'projects/:id', :action => 'show'
project_views.connect 'projects/:id/:action', :action => /roadmap|changelog|destroy|settings/
project_views.connect 'projects/:id/files', :action => 'list_files'
project_views.connect 'projects/:id/files/new', :action => 'add_file'
project_views.connect 'projects/:id/versions/new', :action => 'add_version'
project_views.connect 'projects/:id/categories/new', :action => 'add_issue_category'
project_views.connect 'projects/:id/settings/:tab', :action => 'settings'
end
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
projects.with_options :conditions => {:method => :post} do |project_actions|
project_actions.connect 'projects/new', :action => 'add'
project_actions.connect 'projects', :action => 'add'
project_actions.connect 'projects/:id/:action', :action => /destroy|archive|unarchive/
project_actions.connect 'projects/:id/files/new', :action => 'add_file'
project_actions.connect 'projects/:id/versions/new', :action => 'add_version'
project_actions.connect 'projects/:id/categories/new', :action => 'add_issue_category'
end
end
map.with_options :controller => 'repositories' do |repositories|
repositories.with_options :conditions => {:method => :get} do |repository_views|
repositories.connect 'projects/:id/repository', :action => 'show'
repositories.connect 'projects/:id/repository/edit', :action => 'edit'
repositories.connect 'projects/:id/repository/statistics', :action => 'stats'
repositories.connect 'projects/:id/repository/revisions', :action => 'revisions'
repositories.connect 'projects/:id/repository/revisions.:format', :action => 'revisions'
repositories.connect 'projects/:id/repository/revisions/:rev', :action => 'revision'
repositories.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff'
repositories.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff'
repositories.connect 'projects/:id/repository/revisions/:rev/:action/*path'
repositories.connect 'projects/:id/repository/:action/*path'
end
repositories.connect 'projects/:id/repository/edit', :action => 'edit', :conditions => {:method => :post}
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'
......
......@@ -38,6 +38,13 @@ class AdminControllerTest < Test::Unit::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
......
......@@ -31,6 +31,13 @@ class BoardsControllerTest < Test::Unit::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
......@@ -39,6 +46,24 @@ class BoardsControllerTest < Test::Unit::TestCase
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
......@@ -47,4 +72,22 @@ class BoardsControllerTest < Test::Unit::TestCase
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
......@@ -30,7 +30,14 @@ class DocumentsControllerTest < Test::Unit::TestCase
@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
# Sets a default category
e = Enumeration.find_by_name('Technical documentation')
......@@ -47,6 +54,17 @@ class DocumentsControllerTest < Test::Unit::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
@request.session[:user_id] = 2
set_tmp_attachments_directory
......@@ -66,6 +84,31 @@ class DocumentsControllerTest < Test::Unit::TestCase
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
......
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
......@@ -49,6 +49,13 @@ class IssuesControllerTest < Test::Unit::TestCase
@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
......@@ -74,6 +81,31 @@ class IssuesControllerTest < Test::Unit::TestCase
assert_tag :tag => 'a', :content => /Subproject issue/
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_should_not_list_issues_when_module_disabled
EnabledModule.delete_all("name = 'issue_tracking' AND project_id = 1")
get :index
assert_response :success
assert_template 'index.rhtml'
assert_not_nil assigns(:issues)
assert_nil assigns(:project)
assert_no_tag :tag => 'a', :content => /Can't print recipes/
assert_tag :tag => 'a', :content => /Subproject issue/
end