]> source.dussan.org Git - redmine.git/commitdiff
Fixed that entering #nnn as parent task should validate (#11979).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Oct 2012 14:35:57 +0000 (14:35 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Oct 2012 14:35:57 +0000 (14:35 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10658 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/functional/issues_controller_test.rb

index 13a21e07a2371fe1da3e931cae56300285599c77..0029fffb9a66605fe58ec0156a1a2df6edfd9575 100644 (file)
@@ -416,7 +416,8 @@ class Issue < ActiveRecord::Base
     end
 
     if attrs['parent_issue_id'].present?
-      unless Issue.visible(user).exists?(attrs['parent_issue_id'].to_i)
+      s = attrs['parent_issue_id'].to_s
+      unless (m = s.match(%r{\A#?(\d+)\z})) && Issue.visible(user).exists?(m[1])
         @invalid_parent_issue_id = attrs.delete('parent_issue_id')
       end
     end
index 443cd8ab30dbb2edd90a6274045943a9c6b0e199..d1675c845f88fb629883c25e80d543e56f361cf1 100644 (file)
@@ -1940,12 +1940,24 @@ class IssuesControllerTest < ActionController::TestCase
       post :create, :project_id => 1,
                  :issue => {:tracker_id => 1,
                             :subject => 'This is a child issue',
-                            :parent_issue_id => 2}
+                            :parent_issue_id => '2'}
+      assert_response 302
+    end
+    issue = Issue.order('id DESC').first
+    assert_equal Issue.find(2), issue.parent
+  end
+
+  def test_post_create_subissue_with_sharp_parent_id
+    @request.session[:user_id] = 2
 
+    assert_difference 'Issue.count' do
+      post :create, :project_id => 1,
+                 :issue => {:tracker_id => 1,
+                            :subject => 'This is a child issue',
+                            :parent_issue_id => '#2'}
       assert_response 302
     end
-    issue = Issue.find_by_subject('This is a child issue')
-    assert_not_nil issue
+    issue = Issue.order('id DESC').first
     assert_equal Issue.find(2), issue.parent
   end