defines resourceful versions

* index is duped roadmap
pull/1186/head
Jens Ulferts 12 years ago
parent 93449b9e06
commit dd8dda61ca
  1. 7
      app/views/versions/_issue_counts.html.erb
  2. 2
      app/views/versions/edit.html.erb
  3. 20
      config/routes.rb
  4. 50
      test/integration/routing_test.rb

@ -1,12 +1,15 @@
<form id="status_by_form">
<fieldset>
<legend>
<% update_form = remote_function(:url => status_by_version_path(version),
:with => "Form.serialize('status_by_form')",
:method => :get) %>
<%= l(:label_issues_by,
select_tag('status_by',
status_by_options_for_select(criteria),
:id => 'status_by_select',
:onchange => remote_function(:url => status_by_project_version_path(version.project, version),
:with => "Form.serialize('status_by_form')"))) %>
:onchange => update_form)).html_safe %>
</legend>
<% if counts.empty? %>
<p><em><%= l(:label_no_data) %></em></p>

@ -1,6 +1,6 @@
<h2><%=l(:label_version)%></h2>
<% labelled_tabular_form_for :version, @version, :url => project_version_path(@project, @version), :html => {:method => :put} do |f| %>
<% labelled_tabular_form_for :version, @version, :url => version_path(@version), :html => {:method => :put} do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>

@ -110,7 +110,17 @@ OpenProject::Application.routes.draw do
resource 'enumerations', :controller => 'project_enumerations', :only => [:update, :destroy]
resources :files, :only => [:index, :new, :create]
resources :versions, :collection => {:close_completed => :put}, :member => {:status_by => :post}
resources :versions, :only => [:new, :create] do
collection do
put :close_completed
end
end
# this is only another name for versions#index
# For nice "road in the url for the index action
match '/roadmap' => 'versions#index', :via => :get
resources :news, :shallow => true
resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id'
@ -199,6 +209,12 @@ OpenProject::Application.routes.draw do
end
end
resources :versions, :only => [:show, :edit, :update, :destroy] do
member do
get :status_by
end
end
# Misc issue routes. TODO: move into resources
match '/issues/preview/:id' => 'previews#issue', :as => 'preview_issue' # TODO: would look nicer as /issues/:id/preview
match '/issues/:id/quoted' => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
@ -234,8 +250,6 @@ OpenProject::Application.routes.draw do
end
end
# For nice "road in the url for the index action
match '/projects/:project_id/roadmap' => 'Versions#index'
match '/news' => 'news#index', :as => 'all_news'
match '/news.:format' => 'news#index', :as => 'formatted_all_news'

@ -469,17 +469,45 @@ class RoutingTest < ActionController::IntegrationTest
# should route(:put, "/users/444.xml").to( :controller => 'users', :action => 'update', :id => '444', :format => 'xml')
# end
#
# # TODO: should they all be scoped under /projects/:project_id ?
# context "versions" do
# should route(:get, "/projects/foo/versions/new").to( :controller => 'versions', :action => 'new', :project_id => 'foo')
# should route(:get, "/versions/show/1").to( :controller => 'versions', :action => 'show', :id => '1')
# should route(:get, "/versions/edit/1").to( :controller => 'versions', :action => 'edit', :id => '1')
#
# should route(:post, "/projects/foo/versions").to( :controller => 'versions', :action => 'create', :project_id => 'foo')
# should route(:post, "/versions/update/1").to( :controller => 'versions', :action => 'update', :id => '1')
#
# should route(:delete, "/versions/destroy/1").to( :controller => 'versions', :action => 'destroy', :id => '1')
# end
context "versions" do
should route(:get, "/versions/1").to( :controller => 'versions',
:action => 'show',
:id => '1' )
should route(:get, "/versions/1/edit").to( :controller => 'versions',
:action => 'edit',
:id => '1' )
should route(:put, "/versions/1").to( :controller => 'versions',
:action => 'update',
:id => '1' )
should route(:delete, "/versions/1").to( :controller => 'versions',
:action => 'destroy',
:id => '1' )
should route(:get, "/versions/1/status_by").to( :controller => 'versions',
:action => 'status_by',
:id => '1' )
context "project" do
should route(:get, "/projects/foo/versions/new").to( :controller => 'versions',
:action => 'new',
:project_id => 'foo' )
should route(:post, "/projects/foo/versions").to( :controller => 'versions',
:action => 'create',
:project_id => 'foo' )
should route(:put, "/projects/foo/versions/close_completed").to( :controller => 'versions',
:action => 'close_completed',
:project_id => 'foo' )
should route(:get, "/projects/foo/roadmap").to( :controller => 'versions',
:action => 'index',
:project_id => 'foo' )
end
end
#
# context "wiki (singular, project's pages)" do
# should route(:get, "/projects/567/wiki").to( :controller => 'wiki', :action => 'show', :project_id => '567')

Loading…
Cancel
Save