@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
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
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/
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
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"