Refactor: Move the updating of an Issue to the #update method.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3486 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
19d4ddf2f2
commit
c68d853bf4
|
@ -198,6 +198,31 @@ class IssuesController < ApplicationController
|
|||
@issue.safe_attributes = attrs
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { }
|
||||
format.xml { }
|
||||
end
|
||||
end
|
||||
|
||||
#--
|
||||
# Start converting to the Rails REST controllers
|
||||
#++
|
||||
def update
|
||||
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
|
||||
@priorities = IssuePriority.all
|
||||
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||||
@time_entry = TimeEntry.new
|
||||
|
||||
@notes = params[:notes]
|
||||
journal = @issue.init_journal(User.current, @notes)
|
||||
# User can change issue attributes only if he has :edit permission or if a workflow transition is allowed
|
||||
if (@edit_allowed || !@allowed_statuses.empty?) && params[:issue]
|
||||
attrs = params[:issue].dup
|
||||
attrs.delete_if {|k,v| !UPDATABLE_ATTRS_ON_TRANSITION.include?(k) } unless @edit_allowed
|
||||
attrs.delete(:status_id) unless @allowed_statuses.detect {|s| s.id.to_s == attrs[:status_id].to_s}
|
||||
@issue.safe_attributes = attrs
|
||||
end
|
||||
|
||||
if request.get?
|
||||
# nop
|
||||
else
|
||||
|
@ -237,13 +262,6 @@ class IssuesController < ApplicationController
|
|||
attachments.each(&:destroy)
|
||||
end
|
||||
|
||||
#--
|
||||
# Start converting to the Rails REST controllers
|
||||
#++
|
||||
def update
|
||||
edit
|
||||
end
|
||||
|
||||
def reply
|
||||
journal = Journal.find(params[:journal_id]) if params[:journal_id]
|
||||
if journal
|
||||
|
|
|
@ -126,7 +126,8 @@ ActionController::Routing::Routes.draw do |map|
|
|||
issues_actions.connect 'issues.:format', :action => 'new', :format => /xml/
|
||||
end
|
||||
issues_routes.with_options :conditions => {:method => :put} do |issues_actions|
|
||||
issues_actions.connect 'issues/:id.:format', :action => 'edit', :id => /\d+/, :format => /xml/
|
||||
issues_actions.connect 'issues/:id/edit', :action => 'update', :id => /\d+/
|
||||
issues_actions.connect 'issues/:id.:format', :action => 'update', :id => /\d+/, :format => /xml/
|
||||
end
|
||||
issues_routes.with_options :conditions => {:method => :delete} do |issues_actions|
|
||||
issues_actions.connect 'issues/:id.:format', :action => 'destroy', :id => /\d+/, :format => /xml/
|
||||
|
|
|
@ -114,7 +114,7 @@ class IssuesApiTest < ActionController::IntegrationTest
|
|||
def test_update_routing
|
||||
assert_routing(
|
||||
{:method => :put, :path => '/issues/1.xml'},
|
||||
:controller => 'issues', :action => 'edit', :id => '1', :format => 'xml'
|
||||
:controller => 'issues', :action => 'update', :id => '1', :format => 'xml'
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ class IssuesTest < ActionController::IntegrationTest
|
|||
log_user('jsmith', 'jsmith')
|
||||
set_tmp_attachments_directory
|
||||
|
||||
post 'issues/1/edit',
|
||||
put 'issues/1/edit',
|
||||
:notes => 'Some notes',
|
||||
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
|
||||
assert_redirected_to "issues/1"
|
||||
|
|
Loading…
Reference in New Issue