Index: trunk/app/controllers/issues_controller.rb
===================================================================
--- trunk/app/controllers/issues_controller.rb	(revision 13996)
+++ trunk/app/controllers/issues_controller.rb	(revision 13997)
@@ -21,10 +21,10 @@
 
   before_filter :find_issue, :only => [:show, :edit, :update]
   before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
-  before_filter :find_project, :only => [:new, :create, :update_form]
+  before_filter :find_project, :only => [:new, :create]
   before_filter :authorize, :except => [:index]
   before_filter :find_optional_project, :only => [:index]
-  before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form]
+  before_filter :build_new_issue_from_params, :only => [:new, :create]
   accept_rss_auth :index, :show
   accept_api_auth :index, :show, :create, :update, :destroy
 
@@ -138,6 +138,7 @@
   def new
     respond_to do |format|
       format.html { render :action => 'new', :layout => !request.xhr? }
+      format.js
     end
   end
 
@@ -176,6 +177,7 @@
 
     respond_to do |format|
       format.html { }
+      format.js
       format.xml  { }
     end
   end
@@ -210,11 +212,6 @@
     end
   end
 
-  # Updates the issue form when changing the project, status or tracker
-  # on issue creation/update
-  def update_form
-  end
-
   # Bulk edit/copy a set of issues
   def bulk_edit
     @issues.sort!
@@ -419,32 +416,27 @@
   end
 
   # TODO: Refactor, lots of extra code in here
-  # TODO: Changing tracker on an existing issue should not trigger this
   def build_new_issue_from_params
-    if params[:id].blank?
-      @issue = Issue.new
-      if params[:copy_from]
-        begin
-          @issue.init_journal(User.current)
-          @copy_from = Issue.visible.find(params[:copy_from])
-          unless User.current.allowed_to?(:copy_issues, @copy_from.project)
-            raise ::Unauthorized
-          end
-          @link_copy = link_copy?(params[:link_copy]) || request.get?
-          @copy_attachments = params[:copy_attachments].present? || request.get?
-          @copy_subtasks = params[:copy_subtasks].present? || request.get?
-          @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
-        rescue ActiveRecord::RecordNotFound
-          render_404
-          return
+    @issue = Issue.new
+    if params[:copy_from]
+      begin
+        @issue.init_journal(User.current)
+        @copy_from = Issue.visible.find(params[:copy_from])
+        unless User.current.allowed_to?(:copy_issues, @copy_from.project)
+          raise ::Unauthorized
         end
+        @link_copy = link_copy?(params[:link_copy]) || request.get?
+        @copy_attachments = params[:copy_attachments].present? || request.get?
+        @copy_subtasks = params[:copy_subtasks].present? || request.get?
+        @issue.copy_from(@copy_from, :attachments => @copy_attachments, :subtasks => @copy_subtasks, :link => @link_copy)
+      rescue ActiveRecord::RecordNotFound
+        render_404
+        return
       end
-      @issue.project = @project
-      @issue.author ||= User.current
-      @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
-    else
-      @issue = @project.issues.visible.find(params[:id])
     end
+    @issue.project = @project
+    @issue.author ||= User.current
+    @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
 
     if attrs = params[:issue].deep_dup
       if params[:was_default_status] == attrs[:status_id]
Index: trunk/app/helpers/issues_helper.rb
===================================================================
--- trunk/app/helpers/issues_helper.rb	(revision 13996)
+++ trunk/app/helpers/issues_helper.rb	(revision 13997)
@@ -199,6 +199,16 @@
     s.html_safe
   end
 
+  # Returns the path for updating the issue form
+  # with project as the current project
+  def update_issue_form_path(project, issue)
+    if issue.new_record?
+      new_project_issue_path(project, :format => 'js')
+    else
+      edit_issue_path(issue, :format => 'js')
+    end
+  end
+
   # Returns the number of descendants for an array of issues
   def issues_descendant_count(issues)
     ids = issues.reject(&:leaf?).map {|issue| issue.descendants.ids}.flatten.uniq
Index: trunk/app/views/issues/update_form.js.erb
===================================================================
--- trunk/app/views/issues/update_form.js.erb	(revision 13996)
+++ trunk/app/views/issues/update_form.js.erb	(nonexistent)
@@ -1,7 +0,0 @@
-replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
-
-<% if User.current.allowed_to?(:log_time, @issue.project) %>
-  $('#log_time').show();
-<% else %>
-  $('#log_time').hide();
-<% end %>

Property changes on: trunk/app/views/issues/update_form.js.erb
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: trunk/app/views/issues/_attributes.html.erb
===================================================================
--- trunk/app/views/issues/_attributes.html.erb	(revision 13996)
+++ trunk/app/views/issues/_attributes.html.erb	(revision 13997)
@@ -4,7 +4,7 @@
 <div class="splitcontentleft">
 <% if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %>
 <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), {:required => true},
-                :onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')" %></p>
+                :onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}')" %></p>
 <%= hidden_field_tag 'was_default_status', @issue.status_id, :id => nil if @issue.status == @issue.default_status %>
 <% else %>
 <p><label><%= l(:field_status) %></label> <%= @issue.status %></p>
Index: trunk/app/views/issues/_form.html.erb
===================================================================
--- trunk/app/views/issues/_form.html.erb	(revision 13996)
+++ trunk/app/views/issues/_form.html.erb	(revision 13997)
@@ -9,12 +9,12 @@
 
 <% if @issue.safe_attribute? 'project_id' %>
 <p><%= f.select :project_id, project_tree_options_for_select(@issue.allowed_target_projects, :selected => @issue.project), {:required => true},
-                :onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')" %></p>
+                :onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}')" %></p>
 <% end %>
 
 <% if @issue.safe_attribute? 'tracker_id' %>
 <p><%= f.select :tracker_id, @issue.project.trackers.collect {|t| [t.name, t.id]}, {:required => true},
-                :onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')" %></p>
+                :onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}')" %></p>
 <% end %>
 
 <% if @issue.safe_attribute? 'subject' %>
Index: trunk/app/views/issues/edit.js.erb
===================================================================
--- trunk/app/views/issues/edit.js.erb	(nonexistent)
+++ trunk/app/views/issues/edit.js.erb	(revision 13997)
@@ -0,0 +1,7 @@
+replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');
+
+<% if User.current.allowed_to?(:log_time, @issue.project) %>
+  $('#log_time').show();
+<% else %>
+  $('#log_time').hide();
+<% end %>

Property changes on: trunk/app/views/issues/edit.js.erb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: trunk/app/views/issues/new.js.erb
===================================================================
--- trunk/app/views/issues/new.js.erb	(nonexistent)
+++ trunk/app/views/issues/new.js.erb	(revision 13997)
@@ -0,0 +1 @@
+replaceIssueFormWith('<%= escape_javascript(render :partial => 'form') %>');

Property changes on: trunk/app/views/issues/new.js.erb
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Index: trunk/config/routes.rb
===================================================================
--- trunk/config/routes.rb	(revision 13996)
+++ trunk/config/routes.rb	(revision 13997)
@@ -112,8 +112,8 @@
 
     get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue'
     resources :issues, :only => [:index, :new, :create]
-    # issue form update
-    match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :patch, :post], :as => 'issue_form'
+    # Used when updating the form of a new issue
+    post 'issues/new', :to => 'issues#new'
 
     resources :files, :only => [:index, :new, :create]
 
@@ -168,6 +168,10 @@
   end
 
   resources :issues do
+    member do
+      # Used when updating the form of an existing issue
+      patch 'edit', :to => 'issues#edit'
+    end
     collection do
       match 'bulk_edit', :via => [:get, :post]
       post 'bulk_update'
Index: trunk/lib/redmine.rb
===================================================================
--- trunk/lib/redmine.rb	(revision 13996)
+++ trunk/lib/redmine.rb	(revision 13997)
@@ -98,14 +98,14 @@
                                   :queries => :index,
                                   :reports => [:issue_report, :issue_report_details]},
                                   :read => true
-    map.permission :add_issues, {:issues => [:new, :create, :update_form], :attachments => :upload}
-    map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new], :attachments => :upload}
-    map.permission :copy_issues, {:issues => [:new, :create, :bulk_edit, :bulk_update, :update_form], :attachments => :upload}
+    map.permission :add_issues, {:issues => [:new, :create], :attachments => :upload}
+    map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update], :journals => [:new], :attachments => :upload}
+    map.permission :copy_issues, {:issues => [:new, :create, :bulk_edit, :bulk_update], :attachments => :upload}
     map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]}
     map.permission :manage_subtasks, {}
     map.permission :set_issues_private, {}
     map.permission :set_own_issues_private, {}, :require => :loggedin
-    map.permission :add_issue_notes, {:issues => [:edit, :update, :update_form], :journals => [:new], :attachments => :upload}
+    map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new], :attachments => :upload}
     map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
     map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
     map.permission :view_private_notes, {}, :read => true, :require => :member
Index: trunk/test/functional/issues_controller_test.rb
===================================================================
--- trunk/test/functional/issues_controller_test.rb	(revision 13996)
+++ trunk/test/functional/issues_controller_test.rb	(revision 13997)
@@ -1757,13 +1757,13 @@
 
   def test_update_form_for_new_issue
     @request.session[:user_id] = 2
-    xhr :post, :update_form, :project_id => 1,
+    xhr :post, :new, :project_id => 1,
                      :issue => {:tracker_id => 2,
                                 :subject => 'This is the test_new issue',
                                 :description => 'This is the description',
                                 :priority_id => 5}
     assert_response :success
-    assert_template 'update_form'
+    assert_template 'new'
     assert_template :partial => '_form'
     assert_equal 'text/javascript', response.content_type
 
@@ -1781,7 +1781,7 @@
     WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 1, :new_status_id => 5)
     WorkflowTransition.create!(:role_id => 1, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4)
 
-    xhr :post, :update_form, :project_id => 1,
+    xhr :post, :new, :project_id => 1,
                      :issue => {:tracker_id => 1,
                                 :status_id => 5,
                                 :subject => 'This is an issue'}
@@ -1796,7 +1796,7 @@
     tracker.update! :default_status_id => 2
     tracker.generate_transitions! 2, 1, :clear => true
 
-    xhr :post, :update_form, :project_id => 1,
+    xhr :post, :new, :project_id => 1,
                      :issue => {:tracker_id => 2,
                                 :status_id => 1},
                      :was_default_status => 1
@@ -2776,8 +2776,7 @@
 
   def test_update_form_for_existing_issue
     @request.session[:user_id] = 2
-    xhr :put, :update_form, :project_id => 1,
-                             :id => 1,
+    xhr :patch, :edit, :id => 1,
                              :issue => {:tracker_id => 2,
                                         :subject => 'This is the test_new issue',
                                         :description => 'This is the description',
@@ -2784,7 +2783,7 @@
                                         :priority_id => 5}
     assert_response :success
     assert_equal 'text/javascript', response.content_type
-    assert_template 'update_form'
+    assert_template 'edit'
     assert_template :partial => '_form'
 
     issue = assigns(:issue)
@@ -2797,7 +2796,7 @@
 
   def test_update_form_for_existing_issue_should_keep_issue_author
     @request.session[:user_id] = 3
-    xhr :put, :update_form, :project_id => 1, :id => 1, :issue => {:subject => 'Changed'}
+    xhr :patch, :edit, :id => 1, :issue => {:subject => 'Changed'}
     assert_response :success
     assert_equal 'text/javascript', response.content_type
 
@@ -2814,8 +2813,7 @@
     WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 5)
     WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 5, :new_status_id => 4)
 
-    xhr :put, :update_form, :project_id => 1,
-                    :id => 2,
+    xhr :patch, :edit, :id => 2,
                     :issue => {:tracker_id => 2,
                                :status_id => 5,
                                :subject => 'This is an issue'}
@@ -2826,8 +2824,7 @@
 
   def test_update_form_for_existing_issue_with_project_change
     @request.session[:user_id] = 2
-    xhr :put, :update_form, :project_id => 1,
-                             :id => 1,
+    xhr :patch, :edit, :id => 1,
                              :issue => {:project_id => 2,
                                         :tracker_id => 2,
                                         :subject => 'This is the test_new issue',
@@ -2849,7 +2846,7 @@
     WorkflowTransition.delete_all
     WorkflowTransition.create!(:role_id => 1, :tracker_id => 2, :old_status_id => 2, :new_status_id => 3)
 
-    xhr :put, :update_form, :project_id => 1, :id => 2
+    xhr :patch, :edit, :id => 2
     assert_response :success
     assert_equal [2,3], assigns(:allowed_statuses).map(&:id).sort
   end
Index: trunk/test/integration/routing/issues_test.rb
===================================================================
--- trunk/test/integration/routing/issues_test.rb	(revision 13996)
+++ trunk/test/integration/routing/issues_test.rb	(revision 13997)
@@ -50,7 +50,7 @@
   end
 
   def test_issues_form_update
-    should_route 'POST /projects/23/issues/update_form' => 'issues#update_form', :project_id => '23'
-    should_route 'PUT /projects/23/issues/update_form' => 'issues#update_form', :project_id => '23'
+    should_route 'POST /projects/23/issues/new' => 'issues#new', :project_id => '23'
+    should_route 'PATCH /issues/23/edit' => 'issues#edit', :id => '23'
   end
 end
