summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-15 16:50:25 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-15 16:50:25 +0000
commitbe6e0927f3ce95e751bd3c6f4a61de6979898012 (patch)
treea71c41d3f1f19ef60418f945fcb70494a39a516c
parentcdfc57d5442f72d62437f52af480049c943ecbf8 (diff)
downloadredmine-be6e0927f3ce95e751bd3c6f4a61de6979898012.tar.gz
redmine-be6e0927f3ce95e751bd3c6f4a61de6979898012.zip
Refactor: Split VersionsController#edit into #edit and #update
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4088 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/versions_controller.rb5
-rw-r--r--app/views/versions/edit.rhtml2
-rw-r--r--config/routes.rb3
-rw-r--r--lib/redmine.rb2
-rw-r--r--test/functional/versions_controller_test.rb4
-rw-r--r--test/integration/routing_test.rb6
6 files changed, 17 insertions, 5 deletions
diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb
index dd01da95b..96c240c50 100644
--- a/app/controllers/versions_controller.rb
+++ b/app/controllers/versions_controller.rb
@@ -87,8 +87,11 @@ class VersionsController < ApplicationController
end
end
end
-
+
def edit
+ end
+
+ def update
if request.post? && params[:version]
attributes = params[:version].dup
attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
diff --git a/app/views/versions/edit.rhtml b/app/views/versions/edit.rhtml
index 1556ebba1..8c437eb5e 100644
--- a/app/views/versions/edit.rhtml
+++ b/app/views/versions/edit.rhtml
@@ -1,6 +1,6 @@
<h2><%=l(:label_version)%></h2>
-<% labelled_tabular_form_for :version, @version, :url => { :action => 'edit' } do |f| %>
+<% labelled_tabular_form_for :version, @version, :url => { :action => 'update', :id => @version } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index c85f23eb2..9f9a4e3f0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -205,7 +205,10 @@ ActionController::Routing::Routes.draw do |map|
map.with_options :controller => 'versions' do |versions|
versions.connect 'projects/:project_id/versions/new', :action => 'new'
versions.connect 'projects/:project_id/roadmap', :action => 'index'
+ versions.connect 'versions/:action/:id', :conditions => {:method => :get}
+
versions.with_options :conditions => {:method => :post} do |version_actions|
+ version_actions.connect 'versions/update/:id', :action => 'update'
version_actions.connect 'projects/:project_id/versions/close_completed', :action => 'close_completed'
end
end
diff --git a/lib/redmine.rb b/lib/redmine.rb
index f8f564220..2b27c206b 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -50,7 +50,7 @@ Redmine::AccessControl.map do |map|
map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member
map.permission :select_project_modules, {:projects => :modules}, :require => :member
map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member
- map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :close_completed, :destroy]}, :require => :member
+ map.permission :manage_versions, {:projects => :settings, :versions => [:new, :edit, :update, :close_completed, :destroy]}, :require => :member
map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member
map.project_module :issue_tracking do |map|
diff --git a/test/functional/versions_controller_test.rb b/test/functional/versions_controller_test.rb
index f738794ae..9e8cdf90d 100644
--- a/test/functional/versions_controller_test.rb
+++ b/test/functional/versions_controller_test.rb
@@ -113,9 +113,9 @@ class VersionsControllerTest < ActionController::TestCase
assert_not_nil Version.find_by_status('closed')
end
- def test_post_edit
+ def test_post_update
@request.session[:user_id] = 2
- post :edit, :id => 2,
+ post :update, :id => 2,
:version => { :name => 'New version name',
:effective_date => Date.today.strftime("%Y-%m-%d")}
assert_redirected_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => 'ecookbook'
diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb
index 38c1b2a0e..ba4948008 100644
--- a/test/integration/routing_test.rb
+++ b/test/integration/routing_test.rb
@@ -251,10 +251,16 @@ class RoutingTest < ActionController::IntegrationTest
should_route :post, "/users/567/memberships/12/destroy", :controller => 'users', :action => 'destroy_membership', :id => '567', :membership_id => '12'
end
+ # TODO: should they all be scoped under /projects/:project_id ?
context "versions" do
should_route :get, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
+ should_route :get, "/versions/show/1", :controller => 'versions', :action => 'show', :id => '1'
+ should_route :get, "/versions/edit/1", :controller => 'versions', :action => 'edit', :id => '1'
should_route :post, "/projects/foo/versions/new", :controller => 'versions', :action => 'new', :project_id => 'foo'
+ should_route :post, "/versions/update/1", :controller => 'versions', :action => 'update', :id => '1'
+
+ should_route :delete, "/versions/destroy/1", :controller => 'versions', :action => 'destroy', :id => '1'
end
context "wiki (singular, project's pages)" do