]> source.dussan.org Git - redmine.git/commitdiff
Fixed an error when trying to copy an issue that does not exist.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 17 Jan 2012 20:20:59 +0000 (20:20 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 17 Jan 2012 20:20:59 +0000 (20:20 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8670 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
test/functional/issues_controller_test.rb

index 358faf5078ef4a58b5944df1be52c9e1e3fefb33..82fa5f8ea879b4a9b730a1aa96074cfe53f5cf18 100644 (file)
@@ -360,7 +360,12 @@ private
   def build_new_issue_from_params
     if params[:id].blank?
       @issue = Issue.new
-      @issue.copy_from(params[:copy_from]) if params[:copy_from]
+      begin
+        @issue.copy_from(params[:copy_from]) if params[:copy_from]
+      rescue ActiveRecord::RecordNotFound
+        render_404
+        return
+      end
       @issue.project = @project
     else
       @issue = @project.issues.visible.find(params[:id])
index 13002c296fb7d950c504c2c1a9baf856e1cdb6a8..1273767b4d8cafdac5224683fa07692daa53c044 100644 (file)
@@ -1631,6 +1631,12 @@ class IssuesControllerTest < ActionController::TestCase
     assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
   end
 
+  def test_new_as_copy_with_invalid_issue_should_respond_with_404
+    @request.session[:user_id] = 2
+    get :new, :project_id => 1, :copy_from => 99999
+    assert_response 404
+  end
+
   def test_create_as_copy_on_different_project
     @request.session[:user_id] = 2
     assert_difference 'Issue.count' do