]> source.dussan.org Git - redmine.git/commitdiff
Converted routing and urls to follow the Rails REST convention.
authorEric Davis <edavis@littlestreamsoftware.com>
Mon, 26 Jan 2009 01:47:51 +0000 (01:47 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Mon, 26 Jan 2009 01:47:51 +0000 (01:47 +0000)
Patch supplied by commits from Gerrit Kaiser on Github.  Existing routes will
still work (backwards compatible) but any new urls will be generated using the
new routing rules.

Changes listed below:

* made the URLs for some project tabs and project settings follow the new rails RESTful conventions of /collection/:id/subcollection/:sub_id
* prettier URL for project roadmap
* more nice project URLs
* use GET for filtering form
* prettified URLs used on issues tab
* custom route for activity atom feeds
* prettier repository urls
* fixed broken route definition
* fixed failing tests for issuecontroller that were hardcoding the url string
* more RESTful routes for boards and messages
* RESTful routes for wiki pages
* RESTful routes for documents
* moved old routes that are retained for compatibility to the bottom and grouped them together
* added RESTful URIs for issues
* RESTfulness for the news section
* fixed route order
* changed hardcoded URLs in tests
* fixed badly written tests
* fixed forgotten parameter in routes
* changed hardcoded URLS to new scheme
* changed project add url to the standard POST to collection
* create new issue by POSTing to collection
* changed hardcoded URLs in integrations tests
* made project add form work again
* restful routes for project deletion
* prettier routes for project (un)archival
* made routes table more readable
* fixed note quoting
* user routing
* fixed bug
* always sort by GET
* Fixed: cross-project issue list should not show issues of projects for which the issue tracking module was disabled.
* prettified URLs used on issues tab
* urls for time log
* fixed reply routing
* eliminate revision query paremeter for diff and entry actions
* fixed test failures with hard-coded urls
* ensure ajax links always use get
* refactored ajax link generation into separate method

  #1901

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2317 e93f8b46-1217-0410-a6f0-8f06a7374b81

30 files changed:
app/helpers/application_helper.rb
app/helpers/sort_helper.rb
app/views/projects/changelog.rhtml
app/views/timelog/details.rhtml
app/views/timelog/report.rhtml
app/views/users/_general.rhtml
config/routes.rb
test/functional/admin_controller_test.rb
test/functional/boards_controller_test.rb
test/functional/documents_controller_test.rb
test/functional/issue_relations_controller_test.rb [new file with mode: 0644]
test/functional/issues_controller_test.rb
test/functional/members_controller_test.rb [new file with mode: 0644]
test/functional/messages_controller_test.rb
test/functional/news_controller_test.rb
test/functional/projects_controller_test.rb
test/functional/reports_controller_test.rb [new file with mode: 0644]
test/functional/repositories_controller_test.rb
test/functional/repositories_subversion_controller_test.rb
test/functional/timelog_controller_test.rb
test/functional/users_controller_test.rb
test/functional/versions_controller_test.rb
test/functional/wiki_controller_test.rb
test/functional/wikis_controller_test.rb
test/integration/admin_test.rb
test/integration/issues_test.rb
test/integration/projects_test.rb
test/unit/helpers/application_helper_test.rb
test/unit/lib/redmine/wiki_formatting/macros_test.rb
test/unit/mailer_test.rb

index e6b480b9fccbccc72559887eb812705148846872..6779fdef83930997f907a6953c32964356549bcb 100644 (file)
@@ -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
index ed520e74814514730f1b5a14c54b848b8af71bd1..85ae8151cf7cfc2a52e16fc45183214de34df041 100644 (file)
@@ -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
index e4d32a3934d666c8491ee550321d707721803af0..e44d1d1eed2988f5c8cbed1ddc662ce5e0cb969f 100644 (file)
@@ -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) %>
index db62fae6650c5f151d78cf3c8bfba1d473ba61d6..b2aeb86bb81ae514533cafaf9736933534b13d61 100644 (file)
@@ -6,7 +6,9 @@
 \r
 <h2><%= l(:label_spent_time) %></h2>\r
 \r
-<% form_remote_tag( :url => {}, :method => :get, :update => 'content' ) do %>\r
+<% form_remote_tag( :url => {}, :html => {:method => :get}, :method => :get, :update => 'content' ) do %>\r
+<%# TOOD: remove the project_id and issue_id hidden fields, that information is\r
+already in the URI %>\r
 <%= hidden_field_tag 'project_id', params[:project_id] %>\r
 <%= hidden_field_tag 'issue_id', params[:issue_id] if @issue %>\r
 <%= render :partial => 'date_range' %>\r
index eea0d0fc76fd870c028393e54c56ad8a16c840e0..ad7d79459b60dd154202f37afd95d3c32a31560f 100644 (file)
@@ -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 %>
index 80615ff6c93bbf0989b580d70414eb612656543e..352c002d0cb3c5cdea509e2b5ea17d0893426541 100644 (file)
@@ -1,4 +1,4 @@
-<% 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 %>
index 0a4d3fd9f68f21c591ecb05c2c2ea5465fbf2b80..ca66f4b5750d7d628c2e58cf672d195c3288d648 100644 (file)
@@ -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'
index a9c45aae3fad770f5240d8bf520458ab79f4fa38..32965de4c9219f11fef741363f2e3b466162f3ee 100644 (file)
@@ -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
index 3ff71bc4e148a43c236715a4e5f8c7f70ada082b..190eae237d658ddeffd833065196f4c657026c38 100644 (file)
@@ -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
index b2e7abda09ab9d917e050372a1826a5a2814a25a..2ad94aacfd3f07722b200b895cc336fd51da88dc 100644 (file)
@@ -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
diff --git a/test/functional/issue_relations_controller_test.rb b/test/functional/issue_relations_controller_test.rb
new file mode 100644 (file)
index 0000000..69464c5
--- /dev/null
@@ -0,0 +1,22 @@
+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
index daca0eb417a298cfcb927c860b7ce5e55723ace6..1097ca5d10f4392836154309f6b910199f6085e6 100644 (file)
@@ -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
+
+  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
@@ -107,6 +139,17 @@ class IssuesControllerTest < Test::Unit::TestCase
     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
@@ -126,6 +169,17 @@ class IssuesControllerTest < Test::Unit::TestCase
     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
@@ -221,6 +275,24 @@ class IssuesControllerTest < Test::Unit::TestCase
     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
@@ -251,6 +323,17 @@ class IssuesControllerTest < Test::Unit::TestCase
                                 :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_show_export_to_pdf
     get :show, :id => 3, :format => 'pdf'
@@ -290,7 +373,7 @@ class IssuesControllerTest < Test::Unit::TestCase
                                 :priority_id => 5}
     assert_response :success
     assert_template 'new'
-  end
+  end 
   
   def test_post_new
     @request.session[:user_id] = 2
@@ -301,7 +384,7 @@ class IssuesControllerTest < Test::Unit::TestCase
                           :priority_id => 5,
                           :estimated_hours => '',
                           :custom_field_values => {'2' => 'Value for field 2'}}
-    assert_redirected_to :controller => 'issues', :action => 'show'
+    assert_redirected_to :action => 'show'
     
     issue = Issue.find_by_subject('This is the test_new issue')
     assert_not_nil issue
@@ -330,9 +413,9 @@ class IssuesControllerTest < Test::Unit::TestCase
                           :subject => 'This is the test_new issue',
                           :description => 'This is the description',
                           :priority_id => 5}
-    assert_redirected_to :controller => 'issues', :action => 'show'
+    assert_redirected_to :action => 'show'
   end
-  
+
   def test_post_new_with_required_custom_field_and_without_custom_fields_param
     field = IssueCustomField.find_by_name('Database')
     field.update_attribute(:is_required, true)
@@ -402,6 +485,13 @@ class IssuesControllerTest < Test::Unit::TestCase
                                         :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
@@ -411,6 +501,17 @@ class IssuesControllerTest < Test::Unit::TestCase
     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
@@ -442,6 +543,13 @@ class IssuesControllerTest < Test::Unit::TestCase
                                     :attributes => { :selected => 'selected' } }
   end
   
+  def test_reply_routing
+    assert_routing(
+      {:method => :post, :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
@@ -473,7 +581,7 @@ class IssuesControllerTest < Test::Unit::TestCase
                                         }
       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
@@ -499,7 +607,7 @@ class IssuesControllerTest < Test::Unit::TestCase
                                         }
       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
     
@@ -519,7 +627,7 @@ class IssuesControllerTest < Test::Unit::TestCase
            :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')
@@ -536,7 +644,7 @@ class IssuesControllerTest < Test::Unit::TestCase
     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
@@ -555,7 +663,7 @@ class IssuesControllerTest < Test::Unit::TestCase
            :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)
     
@@ -581,7 +689,7 @@ class IssuesControllerTest < Test::Unit::TestCase
          :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
@@ -600,7 +708,7 @@ class IssuesControllerTest < Test::Unit::TestCase
     post :edit,
          :id => 1,
          :notes => ''
-    assert_redirected_to 'issues/show/1'
+    assert_redirected_to :action => 'show', :id => '1'
     
     issue.reload
     assert issue.journals.empty?
@@ -671,17 +779,28 @@ class IssuesControllerTest < Test::Unit::TestCase
     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
@@ -693,7 +812,7 @@ class IssuesControllerTest < Test::Unit::TestCase
   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
@@ -714,10 +833,10 @@ class IssuesControllerTest < Test::Unit::TestCase
     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',
@@ -726,7 +845,7 @@ class IssuesControllerTest < Test::Unit::TestCase
                             :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',
@@ -777,11 +896,18 @@ class IssuesControllerTest < Test::Unit::TestCase
                                              :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
 
@@ -797,7 +923,7 @@ class IssuesControllerTest < Test::Unit::TestCase
   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
@@ -805,7 +931,7 @@ class IssuesControllerTest < Test::Unit::TestCase
   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
@@ -814,7 +940,7 @@ class IssuesControllerTest < Test::Unit::TestCase
   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
diff --git a/test/functional/members_controller_test.rb b/test/functional/members_controller_test.rb
new file mode 100644 (file)
index 0000000..f69bde1
--- /dev/null
@@ -0,0 +1,15 @@
+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
index 7f6c3854b73d662b88659d0b7c56b34d7ddad9b3..d19249c068430c1abeb50c59b269b6318613f2ec 100644 (file)
@@ -31,6 +31,13 @@ class MessagesControllerTest < Test::Unit::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
@@ -54,6 +61,17 @@ class MessagesControllerTest < Test::Unit::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
@@ -86,6 +104,17 @@ class MessagesControllerTest < Test::Unit::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
@@ -104,6 +133,13 @@ class MessagesControllerTest < Test::Unit::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' }
@@ -111,6 +147,13 @@ class MessagesControllerTest < Test::Unit::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
index 01f8015b9177766f8231a58a7e2ad25b3984cdd9..651471b6630728928a6203417d7f988889bca293 100644 (file)
@@ -31,6 +31,20 @@ class NewsControllerTest < Test::Unit::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
@@ -38,6 +52,20 @@ class NewsControllerTest < Test::Unit::TestCase
     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
@@ -46,6 +74,13 @@ class NewsControllerTest < Test::Unit::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
@@ -58,6 +93,17 @@ class NewsControllerTest < Test::Unit::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
@@ -79,6 +125,17 @@ class NewsControllerTest < Test::Unit::TestCase
     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
@@ -127,6 +184,13 @@ class NewsControllerTest < Test::Unit::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
index 4b8c6c40263d3e121f2e6c91f950de6c4435a806..25f9ad78ee01585cf815bf500622ccbf89aba742 100644 (file)
@@ -33,7 +33,14 @@ class ProjectsControllerTest < Test::Unit::TestCase
     @request.session[:user_id] = nil
     Setting.default_language = 'en'
   end
-
+  
+  def test_index_routing
+    assert_routing(
+      {:method => :get, :path => '/projects'},
+      :controller => 'projects', :action => 'index'
+    )
+  end
+  
   def test_index
     get :index
     assert_response :success
@@ -50,7 +57,14 @@ class ProjectsControllerTest < Test::Unit::TestCase
                                }
                                
     assert_no_tag :a, :content => /Private child of eCookbook/
-  end\r
+  end
+  
+  def test_index_atom_routing
+    assert_routing(
+      {:method => :get, :path => '/projects.atom'},
+      :controller => 'projects', :action => 'index', :format => 'atom'
+    )
+  end
   
   def test_index_atom
     get :index, :format => 'atom'
@@ -59,12 +73,34 @@ class ProjectsControllerTest < Test::Unit::TestCase
     assert_select 'feed>title', :text => 'Redmine: Latest projects'
     assert_select 'feed>entry', :count => Project.count(:conditions => Project.visible_by(User.current))
   end
-  \r
-  def test_show_by_id\r
-    get :show, :id => 1\r
+  
+  def test_add_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/new'},
+      :controller => 'projects', :action => 'add'
+    )
+    assert_recognizes(
+      {:controller => 'projects', :action => 'add'},
+      {:method => :post, :path => '/projects/new'}
+    )
+    assert_recognizes(
+      {:controller => 'projects', :action => 'add'},
+      {:method => :post, :path => '/projects'}
+    )
+  end
+  
+  def test_show_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/test'},
+      :controller => 'projects', :action => 'show', :id => 'test'
+    )
+  end
+  
+  def test_show_by_id
+    get :show, :id => 1
     assert_response :success
-    assert_template 'show'\r
-    assert_not_nil assigns(:project)\r
+    assert_template 'show'
+    assert_not_nil assigns(:project)
   end
 
   def test_show_by_identifier
@@ -90,6 +126,17 @@ class ProjectsControllerTest < Test::Unit::TestCase
     assert_tag :tag => 'a', :content => /Private child/
   end
   
+  def test_settings_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/4223/settings'},
+      :controller => 'projects', :action => 'settings', :id => '4223'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/4223/settings/members'},
+      :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members'
+    )
+  end
+  
   def test_settings
     @request.session[:user_id] = 2 # manager
     get :settings, :id => 1
@@ -106,13 +153,49 @@ class ProjectsControllerTest < Test::Unit::TestCase
     assert_equal 'Test changed name', project.name
   end
   
+  def test_add_version_routing
+    assert_routing(
+      {:method => :get, :path => 'projects/64/versions/new'},
+      :controller => 'projects', :action => 'add_version', :id => '64'
+    )
+    assert_routing(
+    #TODO: use PUT
+      {:method => :post, :path => 'projects/64/versions/new'},
+      :controller => 'projects', :action => 'add_version', :id => '64'
+    )
+  end
+  
+  def test_add_issue_category_routing
+    assert_routing(
+      {:method => :get, :path => 'projects/test/categories/new'},
+      :controller => 'projects', :action => 'add_issue_category', :id => 'test'
+    )
+    assert_routing(
+    #TODO: use PUT and update form
+      {:method => :post, :path => 'projects/64/categories/new'},
+      :controller => 'projects', :action => 'add_issue_category', :id => '64'
+    )
+  end
+  
+  def test_destroy_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/567/destroy'},
+      :controller => 'projects', :action => 'destroy', :id => '567'
+    )
+    assert_routing(
+    #TODO: use DELETE and update form
+      {:method => :post, :path => 'projects/64/destroy'},
+      :controller => 'projects', :action => 'destroy', :id => '64'
+    )
+  end
+  
   def test_get_destroy
     @request.session[:user_id] = 1 # admin
     get :destroy, :id => 1
     assert_response :success
     assert_template 'destroy'
     assert_not_nil Project.find_by_id(1)
-  end\r
+  end
 
   def test_post_destroy
     @request.session[:user_id] = 1 # admin
@@ -142,6 +225,17 @@ class ProjectsControllerTest < Test::Unit::TestCase
     assert mail.body.include?('testfile.txt')
   end
   
+  def test_add_file_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/33/files/new'},
+      :controller => 'projects', :action => 'add_file', :id => '33'
+    )
+    assert_routing(
+      {:method => :post, :path => '/projects/33/files/new'},
+      :controller => 'projects', :action => 'add_file', :id => '33'
+    )
+  end
+  
   def test_add_version_file
     set_tmp_attachments_directory
     @request.session[:user_id] = 2
@@ -156,27 +250,48 @@ class ProjectsControllerTest < Test::Unit::TestCase
     assert_equal 'testfile.txt', a.filename
     assert_equal Version.find(2), a.container
   end
-  \r
-  def test_list_files\r
-    get :list_files, :id => 1\r
-    assert_response :success\r
-    assert_template 'list_files'\r
+  
+  def test_list_files
+    get :list_files, :id => 1
+    assert_response :success
+    assert_template 'list_files'
     assert_not_nil assigns(:containers)
     
     # file attached to the project
     assert_tag :a, :content => 'project_file.zip',
                    :attributes => { :href => '/attachments/download/8/project_file.zip' }
-    \r
+    
     # file attached to a project's version
     assert_tag :a, :content => 'version_file.zip',
                    :attributes => { :href => '/attachments/download/9/version_file.zip' }
-  end\r
-\r
-  def test_changelog\r
-    get :changelog, :id => 1\r
-    assert_response :success\r
-    assert_template 'changelog'\r
-    assert_not_nil assigns(:versions)\r
+  end
+
+  def test_list_files_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/33/files'},
+      :controller => 'projects', :action => 'list_files', :id => '33'
+    )
+  end
+  
+  def test_changelog_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/44/changelog'},
+      :controller => 'projects', :action => 'changelog', :id => '44'
+    )
+  end
+  
+  def test_changelog
+    get :changelog, :id => 1
+    assert_response :success
+    assert_template 'changelog'
+    assert_not_nil assigns(:versions)
+  end
+  
+  def test_roadmap_routing
+    assert_routing(
+      {:method => :get, :path => 'projects/33/roadmap'},
+      :controller => 'projects', :action => 'roadmap', :id => '33'
+    )
   end
   
   def test_roadmap
@@ -200,7 +315,21 @@ class ProjectsControllerTest < Test::Unit::TestCase
     # Completed version appears
     assert assigns(:versions).include?(Version.find(1))
   end
-
+  
+  def test_project_activity_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/1/activity'},
+       :controller => 'projects', :action => 'activity', :id => '1'
+    )
+  end
+  
+  def test_project_activity_atom_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/1/activity.atom'},
+       :controller => 'projects', :action => 'activity', :id => '1', :format => 'atom'
+    )    
+  end
+  
   def test_project_activity
     get :activity, :id => 1, :with_subprojects => 0
     assert_response :success
@@ -237,6 +366,10 @@ class ProjectsControllerTest < Test::Unit::TestCase
                }
   end
   
+  def test_global_activity_routing
+    assert_routing({:method => :get, :path => '/activity'}, :controller => 'projects', :action => 'activity')
+  end
+  
   def test_global_activity
     get :activity
     assert_response :success
@@ -273,19 +406,39 @@ class ProjectsControllerTest < Test::Unit::TestCase
                }
   end
   
+  def test_global_activity_atom_routing
+    assert_routing({:method => :get, :path => '/activity.atom'}, :controller => 'projects', :action => 'activity', :format => 'atom')
+  end
+  
   def test_activity_atom_feed
     get :activity, :format => 'atom'
     assert_response :success
     assert_template 'common/feed.atom.rxml'
   end
   
-  def test_archive    
+  def test_archive_routing
+    assert_routing(
+    #TODO: use PUT to project path and modify form
+      {:method => :post, :path => 'projects/64/archive'},
+      :controller => 'projects', :action => 'archive', :id => '64'
+    )
+  end
+  
+  def test_archive
     @request.session[:user_id] = 1 # admin
     post :archive, :id => 1
     assert_redirected_to 'admin/projects'
     assert !Project.find(1).active?
   end
   
+  def test_unarchive_routing
+    assert_routing(
+    #TODO: use PUT to project path and modify form
+      {:method => :post, :path => '/projects/567/unarchive'},
+      :controller => 'projects', :action => 'unarchive', :id => '567'
+    )
+  end
+  
   def test_unarchive
     @request.session[:user_id] = 1 # admin
     Project.find(1).archive
diff --git a/test/functional/reports_controller_test.rb b/test/functional/reports_controller_test.rb
new file mode 100644 (file)
index 0000000..b90d904
--- /dev/null
@@ -0,0 +1,20 @@
+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
index 972c57e00bd3ac59e126a6bc125a80bc88ebd17d..ccf5e77ba299ea9007c56bdd090bbbb74b3bbdd4 100644 (file)
@@ -31,25 +31,134 @@ class RepositoriesControllerTest < Test::Unit::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
     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_diff_path_routing_with_revision
+    assert_routing(
+      {:method => :get, :path => '/projects/restmine/repository/revisions/2/diff/path/to/file.c'},
+      :controller => 'repositories', :action => 'diff', :id => 'restmine', :path => %w[path to file.c], :rev => '2'
+    )
+  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_entry_routing_with_revision
+    assert_routing(
+      {:method => :get, :path => '/projects/restmine/repository/revisions/2/entry/path/to/file.c'},
+      :controller => 'repositories', :action => 'entry', :id => 'restmine', :path => %w[path to file.c], :rev => '2'
+    )
+  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
index 1ec8dc4a9a1bd3d7642fee93e8315b160aa30a82..a3918a922c5af9033fad069549fc1652f25f88c4 100644 (file)
@@ -131,11 +131,11 @@ class RepositoriesSubversionControllerTest < Test::Unit::TestCase
                  :child => { :tag => 'li',
                              # link to the entry at rev 2
                              :child => { :tag => 'a', 
-                                         :attributes => {:href => '/repositories/entry/ecookbook/test/some/path/in/the/repo?rev=2'},
+                                         :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/test/some/path/in/the/repo'},
                                          :content => 'repo',
                                          # link to partial diff
                                          :sibling =>  { :tag => 'a', 
-                                                        :attributes => { :href => '/repositories/diff/ecookbook/test/some/path/in/the/repo?rev=2' } 
+                                                        :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/test/some/path/in/the/repo' } 
                                                        }
                                         }
                             }
@@ -153,11 +153,11 @@ class RepositoriesSubversionControllerTest < Test::Unit::TestCase
                  :child => { :tag => 'li',
                              # link to the entry at rev 2
                              :child => { :tag => 'a', 
-                                         :attributes => {:href => '/repositories/entry/ecookbook/path/in/the/repo?rev=2'},
+                                         :attributes => {:href => '/projects/ecookbook/repository/revisions/2/entry/path/in/the/repo'},
                                          :content => 'repo',
                                          # link to partial diff
                                          :sibling =>  { :tag => 'a', 
-                                                        :attributes => { :href => '/repositories/diff/ecookbook/path/in/the/repo?rev=2' } 
+                                                        :attributes => { :href => '/projects/ecookbook/repository/revisions/2/diff/path/in/the/repo' } 
                                                        }
                                         }
                             }
index a83de5db03a7436b21f1c983ad6e4f81eb100ccc..f2d0f3141447ecba839c22601fffe66a1fb3731f 100644 (file)
@@ -30,6 +30,28 @@ class TimelogControllerTest < Test::Unit::TestCase
     @response   = ActionController::TestResponse.new
   end
   
+  def test_edit_routing
+    assert_routing(
+      {:method => :get, :path => '/issues/567/time_entries/new'},
+      :controller => 'timelog', :action => 'edit', :issue_id => '567'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/ecookbook/time_entries/new'},
+      :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/ecookbook/issues/567/time_entries/new'},
+      :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567'
+    )
+
+    #TODO: change new form to POST to issue_time_entries_path instead of to edit action
+    #TODO: change edit form to PUT to time_entry_path
+    assert_routing(
+      {:method => :get, :path => '/time_entries/22/edit'},
+      :controller => 'timelog', :action => 'edit', :id => '22'
+    )
+  end
+  
   def test_get_edit
     @request.session[:user_id] = 3
     get :edit, :project_id => 1
@@ -41,6 +63,8 @@ class TimelogControllerTest < Test::Unit::TestCase
   end
   
   def test_post_edit
+    # TODO: should POST to issues’ time log instead of project. change form
+    # and routing
     @request.session[:user_id] = 3
     post :edit, :project_id => 1,
                 :time_entry => {:comments => 'Some work on TimelogControllerTest',
@@ -49,7 +73,7 @@ class TimelogControllerTest < Test::Unit::TestCase
                                 :spent_on => '2008-03-14',
                                 :issue_id => '1',
                                 :hours => '7.3'}
-    assert_redirected_to 'projects/ecookbook/timelog/details'
+    assert_redirected_to :action => 'details', :project_id => 'ecookbook'
     
     i = Issue.find(1)
     t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
@@ -70,7 +94,7 @@ class TimelogControllerTest < Test::Unit::TestCase
     post :edit, :id => 1,
                 :time_entry => {:issue_id => '2',
                                 :hours => '8'}
-    assert_redirected_to 'projects/ecookbook/timelog/details'
+    assert_redirected_to :action => 'details', :project_id => 'ecookbook'
     entry.reload
     
     assert_equal 8, entry.hours
@@ -78,18 +102,44 @@ class TimelogControllerTest < Test::Unit::TestCase
     assert_equal 2, entry.user_id
   end
   
+  def test_destroy_routing
+    #TODO: use DELETE to time_entry_path
+    assert_routing(
+      {:method => :post, :path => '/time_entries/55/destroy'},
+      :controller => 'timelog', :action => 'destroy', :id => '55'
+    )
+  end
+  
   def test_destroy
     @request.session[:user_id] = 2
     post :destroy, :id => 1
-    assert_redirected_to 'projects/ecookbook/timelog/details'
+    assert_redirected_to :action => 'details', :project_id => 'ecookbook'
     assert_nil TimeEntry.find_by_id(1)
   end
-
+  
+  def test_report_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/567/time_entries/report'},
+      :controller => 'timelog', :action => 'report', :project_id => '567'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/567/time_entries/report.csv'},
+      :controller => 'timelog', :action => 'report', :project_id => '567', :format => 'csv'
+    )
+  end
+  
   def test_report_no_criteria
     get :report, :project_id => 1
     assert_response :success
     assert_template 'report'
   end
+  
+  def test_report_routing_for_all_projects
+    assert_routing(
+      {:method => :get, :path => '/time_entries/report'},
+      :controller => 'timelog', :action => 'report'
+    )
+  end
 
   def test_report_all_projects
     get :report
@@ -103,7 +153,7 @@ class TimelogControllerTest < Test::Unit::TestCase
     r.permissions_will_change!
     r.save
     get :report
-    assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Ftimelog%2Freport'
+    assert_redirected_to '/login?back_url=http%3A%2F%2Ftest.host%2Ftime_entries%2Freport'
   end
   
   def test_report_all_projects_one_criteria
@@ -201,7 +251,14 @@ class TimelogControllerTest < Test::Unit::TestCase
     assert_not_nil assigns(:total_hours)
     assert_equal "162.90", "%.2f" % assigns(:total_hours)
   end
-
+  
+  def test_project_details_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/567/time_entries'},
+      :controller => 'timelog', :action => 'details', :project_id => '567'
+    )
+  end
+  
   def test_details_at_project_level
     get :details, :project_id => 1
     assert_response :success
@@ -239,6 +296,23 @@ class TimelogControllerTest < Test::Unit::TestCase
     assert_equal Date.today, assigns(:to)
   end
   
+  def test_issue_details_routing
+    assert_routing(
+      {:method => :get, :path => 'time_entries'},
+      :controller => 'timelog', :action => 'details'
+    )
+    assert_routing(
+      {:method => :get, :path => '/issues/234/time_entries'},
+      :controller => 'timelog', :action => 'details', :issue_id => '234'
+    )
+    # TODO: issue detail page shouldnt link to project_issue_time_entries_path but to normal issues one
+    # doesnt seem to have effect on resulting page so controller can be left untouched
+    assert_routing(
+      {:method => :get, :path => '/projects/ecookbook/issues/123/time_entries'},
+      :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123'
+    )
+  end
+  
   def test_details_at_issue_level
     get :details, :issue_id => 1
     assert_response :success
@@ -252,6 +326,39 @@ class TimelogControllerTest < Test::Unit::TestCase
     assert_equal '2007-04-22'.to_date, assigns(:to)
   end
   
+  def test_details_formatted_routing
+    assert_routing(
+      {:method => :get, :path => 'time_entries.atom'},
+      :controller => 'timelog', :action => 'details', :format => 'atom'
+    )
+    assert_routing(
+      {:method => :get, :path => 'time_entries.csv'},
+      :controller => 'timelog', :action => 'details', :format => 'csv'
+    )
+  end
+  
+  def test_details_for_project_formatted_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/567/time_entries.atom'},
+      :controller => 'timelog', :action => 'details', :format => 'atom', :project_id => '567'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/567/time_entries.csv'},
+      :controller => 'timelog', :action => 'details', :format => 'csv', :project_id => '567'
+    )
+  end
+  
+  def test_details_for_issue_formatted_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/ecookbook/issues/123/time_entries.atom'},
+      :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123', :format => 'atom'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/ecookbook/issues/123/time_entries.csv'},
+      :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123', :format => 'csv'
+    )
+  end
+  
   def test_details_atom_feed
     get :details, :project_id => 1, :format => 'atom'
     assert_response :success
index 82f3e9ee206f032c4e73e91d4f2ffd7b80f8f69a..42e69f48dd621c473ef0af5f41c5e94f11eafc52 100644 (file)
@@ -32,11 +32,27 @@ class UsersControllerTest < Test::Unit::TestCase
     @request.session[:user_id] = 1 # admin
   end
   
+  def test_index_routing
+    #TODO: unify with list
+    assert_generates(
+      '/users',
+      :controller => 'users', :action => 'index'
+    )
+  end
+  
   def test_index
     get :index
     assert_response :success
     assert_template 'list'
   end
+  
+  def test_list_routing
+    #TODO: rename action to index
+    assert_routing(
+      {:method => :get, :path => '/users'},
+      :controller => 'users', :action => 'list'
+    )
+  end
 
   def test_list
     get :list
@@ -56,17 +72,71 @@ class UsersControllerTest < Test::Unit::TestCase
     assert_equal 1, users.size
     assert_equal 'John', users.first.firstname
   end
+
+  def test_add_routing
+    assert_routing(
+      {:method => :get, :path => '/users/new'},
+      :controller => 'users', :action => 'add'
+    )
+    assert_recognizes(
+    #TODO: remove this and replace with POST to collection, need to modify form
+      {:controller => 'users', :action => 'add'},
+      {:method => :post, :path => '/users/new'}
+    )
+    assert_recognizes(
+      {:controller => 'users', :action => 'add'},
+      {:method => :post, :path => '/users'}
+    )
+  end
+  
+  def test_edit_routing
+    assert_routing(
+      {:method => :get, :path => '/users/444/edit'},
+      :controller => 'users', :action => 'edit', :id => '444'
+    )
+    assert_routing(
+      {:method => :get, :path => '/users/222/edit/membership'},
+      :controller => 'users', :action => 'edit', :id => '222', :tab => 'membership'
+    )
+    assert_recognizes(
+    #TODO: use PUT on user_path, modify form
+      {:controller => 'users', :action => 'edit', :id => '444'},
+      {:method => :post, :path => '/users/444/edit'}
+    )
+  end
+  
+  def test_add_membership_routing
+    assert_routing(
+      {:method => :post, :path => '/users/123/memberships'},
+      :controller => 'users', :action => 'edit_membership', :id => '123'
+    )
+  end
+  
+  def test_edit_membership_routing
+    assert_routing(
+      {:method => :post, :path => '/users/123/memberships/55'},
+      :controller => 'users', :action => 'edit_membership', :id => '123', :membership_id => '55'
+    )
+  end
   
   def test_edit_membership
     post :edit_membership, :id => 2, :membership_id => 1,
                            :membership => { :role_id => 2}
-    assert_redirected_to '/users/edit/2?tab=memberships'
+    assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships'
     assert_equal 2, Member.find(1).role_id
   end
   
+  def test_destroy_membership
+    assert_routing(
+    #TODO: use DELETE method on user_membership_path, modify form
+      {:method => :post, :path => '/users/567/memberships/12/destroy'},
+      :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
+    )
+  end
+  
   def test_destroy_membership
     post :destroy_membership, :id => 2, :membership_id => 1
-    assert_redirected_to '/users/edit/2?tab=memberships'
+    assert_redirected_to :action => 'edit', :id => '2', :tab => 'memberships'
     assert_nil Member.find_by_id(1)
   end
 end
index 562a57dd8f9b2a0013d4bf8715c0813520e466be..2ddf3a9f1222042e2c27f16bed5ed4b75be094df 100644 (file)
@@ -52,7 +52,7 @@ class VersionsControllerTest < Test::Unit::TestCase
     post :edit, :id => 2, 
                 :version => { :name => 'New version name', 
                               :effective_date => Date.today.strftime("%Y-%m-%d")}
-    assert_redirected_to '/projects/settings/ecookbook?tab=versions'
+    assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
     version = Version.find(2)
     assert_equal 'New version name', version.name
     assert_equal Date.today, version.effective_date
@@ -61,7 +61,7 @@ class VersionsControllerTest < Test::Unit::TestCase
   def test_destroy
     @request.session[:user_id] = 2
     post :destroy, :id => 3
-    assert_redirected_to '/projects/settings/ecookbook?tab=versions'
+    assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
     assert_nil Version.find_by_id(3)
   end
   
index d47a4ff47fa3b612398913446e62f7170a210f2c..40dc04ae409732f42014779d5ce56db1825530fc 100644 (file)
@@ -31,6 +31,21 @@ class WikiControllerTest < Test::Unit::TestCase
     User.current = nil
   end
   
+  def test_index_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/567/wiki'},
+      :controller => 'wiki', :action => 'index', :id => '567'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/567/wiki/lalala'},
+      :controller => 'wiki', :action => 'index', :id => '567', :page => 'lalala'
+    )
+    assert_generates(
+      '/projects/567/wiki',
+      :controller => 'wiki', :action => 'index', :id => '567', :page => nil
+    )
+  end
+  
   def test_show_start_page
     get :index, :id => 'ecookbook'
     assert_response :success
@@ -40,7 +55,7 @@ class WikiControllerTest < Test::Unit::TestCase
     # 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
   
@@ -67,6 +82,17 @@ class WikiControllerTest < Test::Unit::TestCase
     assert_template 'edit'
   end
   
+  def test_edit_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/567/wiki/my_page/edit'},
+      :controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'
+    )
+    assert_recognizes(#TODO: use PUT to page path, adjust forms accordingly
+      {:controller => 'wiki', :action => 'edit', :id => '567', :page => 'my_page'},
+      {:method => :post, :path => '/projects/567/wiki/my_page/edit'}
+    )
+  end
+  
   def test_create_page
     @request.session[:user_id] = 2
     post :edit, :id => 1,
@@ -74,13 +100,20 @@ class WikiControllerTest < Test::Unit::TestCase
                 :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',
@@ -103,6 +136,13 @@ class WikiControllerTest < Test::Unit::TestCase
     assert_tag :tag => 'h1', :content => /New page/
   end
   
+  def test_history_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/1/wiki/CookBook_documentation/history'},
+      :controller => 'wiki', :action => 'history', :id => '1', :page => 'CookBook_documentation'
+    )
+  end
+  
   def test_history
     get :history, :id => 1, :page => 'CookBook_documentation'
     assert_response :success
@@ -120,6 +160,13 @@ class WikiControllerTest < Test::Unit::TestCase
     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
@@ -129,6 +176,13 @@ class WikiControllerTest < Test::Unit::TestCase
                                :content => /updated/
   end
   
+  def test_annotate_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/1/wiki/CookBook_documentation/annotate/2'},
+      :controller => 'wiki', :action => 'annotate', :id => '1', :page => 'CookBook_documentation', :version => '2'
+    )
+  end
+  
   def test_annotate
     get :annotate, :id => 1, :page =>  'CookBook_documentation', :version => 2
     assert_response :success
@@ -143,12 +197,24 @@ class WikiControllerTest < Test::Unit::TestCase
                              :child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
   end
   
+  def test_rename_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/22/wiki/ladida/rename'},
+      :controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'
+    )
+    assert_recognizes(
+      #TODO: should be moved into a update action and use a PUT to the page URI
+      {:controller => 'wiki', :action => 'rename', :id => '22', :page => 'ladida'},
+      {:method => :post, :path => '/projects/22/wiki/ladida/rename'}
+    )
+  end
+  
   def test_rename_with_redirect
     @request.session[:user_id] = 2
     post :rename, :id => 1, :page => 'Another_page',
                             :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')
@@ -160,16 +226,43 @@ class WikiControllerTest < Test::Unit::TestCase
     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'
+  end
+  
+  def test_special_routing
+    assert_routing(
+      {:method => :get, :path => '/projects/567/wiki/page_index'},
+      :controller => 'wiki', :action => 'special', :id => '567', :page => 'page_index'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/567/wiki/Page_Index'},
+      :controller => 'wiki', :action => 'special', :id => '567', :page => 'Page_Index'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/567/wiki/date_index'},
+      :controller => 'wiki', :action => 'special', :id => '567', :page => 'date_index'
+    )
+    assert_routing(
+      {:method => :get, :path => '/projects/567/wiki/export'},
+      :controller => 'wiki', :action => 'special', :id => '567', :page => 'export'
+    )
   end
   
   def test_page_index
@@ -181,13 +274,13 @@ class WikiControllerTest < Test::Unit::TestCase
     assert_equal Project.find(1).wiki.pages.size, pages.size
     
     assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
-                    :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/CookBook_documentation' },
+                    :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
                                               :content => 'CookBook documentation' },
                                 :child => { :tag => 'ul',
                                             :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' } } } },
-                    :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/wiki/ecookbook/Another_page' },
+                    :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
                                                                        :content => 'Another page' } }
   end
   
@@ -196,12 +289,19 @@ class WikiControllerTest < Test::Unit::TestCase
     assert_response 404
   end
   
+  def test_protect_routing
+    assert_routing(
+      {:method => :post, :path => 'projects/22/wiki/ladida/protect'},
+      {:controller => 'wiki', :action => 'protect', :id => '22', :page => 'ladida'}
+    )
+  end
+  
   def test_protect_page
     page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
     assert !page.protected?
     @request.session[:user_id] = 2
     post :protect, :id => 1, :page => page.title, :protected => '1'
-    assert_redirected_to 'wiki/ecookbook/Another_page'
+    assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_page'
     assert page.reload.protected?
   end
   
@@ -210,7 +310,7 @@ class WikiControllerTest < Test::Unit::TestCase
     assert page.protected?
     @request.session[:user_id] = 2
     post :protect, :id => 1, :page => page.title, :protected => '0'
-    assert_redirected_to '/wiki/ecookbook/CookBook_documentation'
+    assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'CookBook_documentation'
     assert !page.reload.protected?
   end
   
@@ -219,7 +319,7 @@ class WikiControllerTest < Test::Unit::TestCase
     get :index, :id => 1
     assert_response :success
     assert_template 'show'
-    assert_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
+    assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
   end
   
   def test_show_page_without_edit_link
@@ -227,7 +327,7 @@ class WikiControllerTest < Test::Unit::TestCase
     get :index, :id => 1
     assert_response :success
     assert_template 'show'
-    assert_no_tag :tag => 'a', :attributes => { :href => '/wiki/1/CookBook_documentation/edit' }
+    assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
   end  
   
   def test_edit_unprotected_page
index 9dc8c72260ade6b29175bb11c494463b570b8cad..4000b112899597f07da8947665e0b41ee5c56190 100644 (file)
@@ -31,6 +31,14 @@ class WikisControllerTest < Test::Unit::TestCase
     User.current = nil
   end
   
+  def test_edit_routing
+    assert_routing(
+    #TODO: use PUT
+      {:method => :post, :path => 'projects/ladida/wiki'},
+      :controller => 'wikis', :action => 'edit', :id => 'ladida'
+    )
+  end
+  
   def test_create
     @request.session[:user_id] = 1
     assert_nil Project.find(3).wiki
@@ -41,10 +49,21 @@ class WikisControllerTest < Test::Unit::TestCase
     assert_equal 'Start page', wiki.start_page
   end
   
+  def test_destroy_routing
+    assert_routing(
+      {:method => :get, :path => 'projects/ladida/wiki/destroy'},
+      :controller => 'wikis', :action => 'destroy', :id => 'ladida'
+    )
+    assert_recognizes(  #TODO: use DELETE and update form
+      {:controller => 'wikis', :action => 'destroy', :id => 'ladida'},
+      {:method => :post, :path => 'projects/ladida/wiki/destroy'}
+    )
+  end
+  
   def test_destroy
     @request.session[:user_id] = 1
     post :destroy, :id => 1, :confirm => 1
-    assert_redirected_to '/projects/settings/ecookbook?tab=wiki'
+    assert_redirected_to :action => 'settings', :id => 'ecookbook', :tab => 'wiki'
     assert_nil Project.find(1).wiki
   end
   
@@ -53,4 +72,4 @@ class WikisControllerTest < Test::Unit::TestCase
     post :destroy, :id => 999, :confirm => 1
     assert_response 404
   end
-end
+end 
index 6e385873e2d31a50ad860a5b20b1a942e7b0c0d3..5182c9abd41514f47e41a1b1f613cbd7b78992e6 100644 (file)
@@ -42,10 +42,10 @@ class AdminTest < ActionController::IntegrationTest
   
   def test_add_project
     log_user("admin", "admin")
-    get "projects/add"
+    get "projects/new"
     assert_response :success
     assert_template "projects/add"
-    post "projects/add", :project => { :name => "blog", 
+    post "projects", :project => { :name => "blog", 
                                        :description => "weblog",
                                        :identifier => "blog",
                                        :is_public => 1,
index 2ef933fc20df5ae99ccc0a55bd7f593b57051f43..61bbbce34b764e711f56ff38c9f4e71ceb1d5529 100644 (file)
@@ -39,7 +39,7 @@ class IssuesTest < ActionController::IntegrationTest
     assert_response :success
     assert_template 'issues/new'
     
-    post 'projects/1/issues/new', :tracker_id => "1",
+    post 'projects/1/issues', :tracker_id => "1",
                                  :issue => { :start_date => "2006-12-26", 
                                              :priority_id => "3", 
                                              :subject => "new test issue", 
@@ -54,7 +54,7 @@ class IssuesTest < ActionController::IntegrationTest
     assert_kind_of Issue, issue
 
     # check redirection
-    assert_redirected_to "issues/show"
+    assert_redirected_to :controller => 'issues', :action => 'show'
     follow_redirect!
     assert_equal issue, assigns(:issue)
 
@@ -69,10 +69,10 @@ class IssuesTest < ActionController::IntegrationTest
     log_user('jsmith', 'jsmith')
     set_tmp_attachments_directory
 
-    post 'issues/edit/1',
+    post 'issues/1/edit',
          :notes => 'Some notes',
          :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
-    assert_redirected_to "issues/show/1"
+    assert_redirected_to "issues/1"
     
     # make sure attachment was saved
     attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
index e56bee484a1eec737a63bcd27cf09222c6928e7e..14175ea9845c468cdf83cb561086ba1397c2b3f4 100644 (file)
@@ -27,18 +27,18 @@ class ProjectsTest < ActionController::IntegrationTest
     assert_response :success
     assert_template "admin/projects"
     post "projects/archive", :id => 1
-    assert_redirected_to "admin/projects"    
+    assert_redirected_to "admin/projects"
     assert !Project.find(1).active?
     
-    get "projects/show", :id => 1
+    get 'projects/1'
     assert_response 403
-    get "projects/show", :id => subproject.id
+    get "projects/#{subproject.id}"
     assert_response 403
     
     post "projects/unarchive", :id => 1
-    assert_redirected_to "admin/projects"    
+    assert_redirected_to "admin/projects"
     assert Project.find(1).active?
-    get "projects/show", :id => 1
+    get "projects/1"
     assert_response :success
   end  
 end
index 5f1a58935742ad5bafb50b33003391141b0cedd2..9fbb3f6531f81dbd162b41868a4d702cf6a8a0a1 100644 (file)
@@ -174,23 +174,23 @@ class ApplicationHelperTest < HelperTestCase
   
   def test_wiki_links
     to_test = {
-      '[[CookBook documentation]]' => '<a href="/wiki/ecookbook/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
-      '[[Another page|Page]]' => '<a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a>',
+      '[[CookBook documentation]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation" class="wiki-page">CookBook documentation</a>',
+      '[[Another page|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a>',
       # link with anchor
-      '[[CookBook documentation#One-section]]' => '<a href="/wiki/ecookbook/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>',
-      '[[Another page#anchor|Page]]' => '<a href="/wiki/ecookbook/Another_page#anchor" class="wiki-page">Page</a>',
+      '[[CookBook documentation#One-section]]' => '<a href="/projects/ecookbook/wiki/CookBook_documentation#One-section" class="wiki-page">CookBook documentation</a>',
+      '[[Another page#anchor|Page]]' => '<a href="/projects/ecookbook/wiki/Another_page#anchor" class="wiki-page">Page</a>',
       # page that doesn't exist
-      '[[Unknown page]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">Unknown page</a>',
-      '[[Unknown page|404]]' => '<a href="/wiki/ecookbook/Unknown_page" class="wiki-page new">404</a>',
+      '[[Unknown page]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
+      '[[Unknown page|404]]' => '<a href="/projects/ecookbook/wiki/Unknown_page" class="wiki-page new">404</a>',
       # link to another project wiki
-      '[[onlinestore:]]' => '<a href="/wiki/onlinestore/" class="wiki-page">onlinestore</a>',
-      '[[onlinestore:|Wiki]]' => '<a href="/wiki/onlinestore/" class="wiki-page">Wiki</a>',
-      '[[onlinestore:Start page]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Start page</a>',
-      '[[onlinestore:Start page|Text]]' => '<a href="/wiki/onlinestore/Start_page" class="wiki-page">Text</a>',
-      '[[onlinestore:Unknown page]]' => '<a href="/wiki/onlinestore/Unknown_page" class="wiki-page new">Unknown page</a>',
+      '[[onlinestore:]]' => '<a href="/projects/onlinestore/wiki/" class="wiki-page">onlinestore</a>',
+      '[[onlinestore:|Wiki]]' => '<a href="/projects/onlinestore/wiki/" class="wiki-page">Wiki</a>',
+      '[[onlinestore:Start page]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Start page</a>',
+      '[[onlinestore:Start page|Text]]' => '<a href="/projects/onlinestore/wiki/Start_page" class="wiki-page">Text</a>',
+      '[[onlinestore:Unknown page]]' => '<a href="/projects/onlinestore/wiki/Unknown_page" class="wiki-page new">Unknown page</a>',
       # striked through link
-      '-[[Another page|Page]]-' => '<del><a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a></del>',
-      '-[[Another page|Page]] link-' => '<del><a href="/wiki/ecookbook/Another_page" class="wiki-page">Page</a> link</del>',
+      '-[[Another page|Page]]-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a></del>',
+      '-[[Another page|Page]] link-' => '<del><a href="/projects/ecookbook/wiki/Another_page" class="wiki-page">Page</a> link</del>',
       # escaping
       '![[Another page|Page]]' => '[[Another page|Page]]',
     }
@@ -242,9 +242,9 @@ EXPECTED
   
   def test_wiki_links_in_tables
     to_test = {"|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" =>
-                 '<tr><td><a href="/wiki/ecookbook/Page" class="wiki-page new">Link title</a></td>' +
-                 '<td><a href="/wiki/ecookbook/Other_Page" class="wiki-page new">Other title</a></td>' +
-                 '</tr><tr><td>Cell 21</td><td><a href="/wiki/ecookbook/Last_page" class="wiki-page new">Last page</a></td></tr>'
+                 '<tr><td><a href="/projects/ecookbook/wiki/Page" class="wiki-page new">Link title</a></td>' +
+                 '<td><a href="/projects/ecookbook/wiki/Other_Page" class="wiki-page new">Other title</a></td>' +
+                 '</tr><tr><td>Cell 21</td><td><a href="/projects/ecookbook/wiki/Last_page" class="wiki-page new">Last page</a></td></tr>'
     }
     @project = Project.find(1)
     to_test.each { |text, result| assert_equal "<table>#{result}</table>", textilizable(text).gsub(/[\t\n]/, '') }
index b5284acd30afedf7474893a23a36d6caaafbb1b5..a75289551c1b0817390081370f90cab33e8fade8 100644 (file)
@@ -64,8 +64,8 @@ class Redmine::WikiFormatting::MacrosTest < HelperTestCase
   
   def test_macro_child_pages
     expected =  "<p><ul class=\"pages-hierarchy\">\n" +
-                 "<li><a href=\"/wiki/ecookbook/Child_1\">Child 1</a></li>\n" +
-                 "<li><a href=\"/wiki/ecookbook/Child_2\">Child 2</a></li>\n" +
+                 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" +
+                 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
                  "</ul>\n</p>"
     
     @project = Project.find(1)
@@ -80,10 +80,10 @@ class Redmine::WikiFormatting::MacrosTest < HelperTestCase
   
   def test_macro_child_pages_with_option
     expected =  "<p><ul class=\"pages-hierarchy\">\n" +
-                 "<li><a href=\"/wiki/ecookbook/Another_page\">Another page</a>\n" +
+                 "<li><a href=\"/projects/ecookbook/wiki/Another_page\">Another page</a>\n" +
                  "<ul class=\"pages-hierarchy\">\n" +
-                 "<li><a href=\"/wiki/ecookbook/Child_1\">Child 1</a></li>\n" +
-                 "<li><a href=\"/wiki/ecookbook/Child_2\">Child 2</a></li>\n" +
+                 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" +
+                 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
                  "</ul>\n</li>\n</ul>\n</p>"
     
     @project = Project.find(1)
index 1e09eaa5cf14195d5f71ecd003b7fc756612ce88..141ff40b920f5028caaa4951f6e7f9fe095a85d9 100644 (file)
@@ -31,12 +31,12 @@ class MailerTest < Test::Unit::TestCase
     mail = ActionMailer::Base.deliveries.last
     assert_kind_of TMail::Mail, mail
     # link to the main ticket
-    assert mail.body.include?('<a href="https://mydomain.foo/issues/show/1">Bug #1: Can\'t print recipes</a>')
+    assert mail.body.include?('<a href="https://mydomain.foo/issues/1">Bug #1: Can\'t print recipes</a>')
+    
     # link to a referenced ticket
-    assert mail.body.include?('<a href="https://mydomain.foo/issues/show/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
+    assert mail.body.include?('<a href="https://mydomain.foo/issues/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
     # link to a changeset
-    assert mail.body.include?('<a href="https://mydomain.foo/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
+    assert mail.body.include?('<a href="https://mydomain.foo/projects/ecookbook/repository/revisions/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
   end
   
   def test_generated_links_with_prefix
@@ -52,12 +52,12 @@ class MailerTest < Test::Unit::TestCase
     mail = ActionMailer::Base.deliveries.last
     assert_kind_of TMail::Mail, mail
     # link to the main ticket
-    assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/show/1">Bug #1: Can\'t print recipes</a>')
+    assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/1">Bug #1: Can\'t print recipes</a>')
  
     # link to a referenced ticket
-    assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/show/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
+    assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
     # link to a changeset
-    assert mail.body.include?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
+    assert mail.body.include?('<a href="http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
   ensure
     # restore it
     Redmine::Utils.relative_url_root = relative_url_root
@@ -76,12 +76,12 @@ class MailerTest < Test::Unit::TestCase
     mail = ActionMailer::Base.deliveries.last
     assert_kind_of TMail::Mail, mail
     # link to the main ticket
-    assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/show/1">Bug #1: Can\'t print recipes</a>')
+    assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/1">Bug #1: Can\'t print recipes</a>')
  
     # link to a referenced ticket
-    assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/show/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
+    assert mail.body.include?('<a href="http://mydomain.foo/rdm/issues/2" class="issue" title="Add ingredients categories (Assigned)">#2</a>')
     # link to a changeset
-    assert mail.body.include?('<a href="http://mydomain.foo/rdm/repositories/revision/ecookbook/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
+    assert mail.body.include?('<a href="http://mydomain.foo/rdm/projects/ecookbook/repository/revisions/2" class="changeset" title="This commit fixes #1, #2 and references #1 &amp; #3">r2</a>')
   ensure
     # restore it
     Redmine::Utils.relative_url_root = relative_url_root
@@ -92,7 +92,7 @@ class MailerTest < Test::Unit::TestCase
     journal = Journal.find(2)
     Mailer.deliver_issue_edit(journal)
     mail = ActionMailer::Base.deliveries.last
-    assert !mail.body.include?('<a href="https://mydomain.foo/issues/show/1">Bug #1: Can\'t print recipes</a>')
+    assert !mail.body.include?('<a href="https://mydomain.foo/issues/1">Bug #1: Can\'t print recipes</a>')
   end
   
   def test_issue_add_message_id