]> source.dussan.org Git - redmine.git/commitdiff
Merged r11228 from trunk (#12851).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Jan 2013 17:09:36 +0000 (17:09 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 20 Jan 2013 17:09:36 +0000 (17:09 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.2-stable@11236 e93f8b46-1217-0410-a6f0-8f06a7374b81

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

index 4b60843c7fd23b11381c3b45bcf79100b8b2fc79..a47e6c024df2cc38196fb3d04e56489e4f013fc2 100644 (file)
@@ -418,7 +418,7 @@ class Issue < ActiveRecord::Base
 
     if attrs['parent_issue_id'].present?
       s = attrs['parent_issue_id'].to_s
-      unless (m = s.match(%r{\A#?(\d+)\z})) && Issue.visible(user).exists?(m[1])
+      unless (m = s.match(%r{\A#?(\d+)\z})) && (m[1] == parent_id.to_s || Issue.visible(user).exists?(m[1]))
         @invalid_parent_issue_id = attrs.delete('parent_issue_id')
       end
     end
index 12cc9174696db7583c589a48984d4cf1f36276fa..1ed80551352ede27b0812f0d76c03b652f27df9b 100644 (file)
@@ -2914,6 +2914,20 @@ class IssuesControllerTest < ActionController::TestCase
     assert_equal spent_hours_before + 2.5, issue.spent_hours
   end
 
+  def test_put_update_should_preserve_parent_issue_even_if_not_visible
+    parent = Issue.generate!(:project_id => 1, :is_private => true)
+    issue = Issue.generate!(:parent_issue_id => parent.id)
+    assert !parent.visible?(User.find(3))
+    @request.session[:user_id] = 3
+
+    get :edit, :id => issue.id
+    assert_select 'input[name=?][value=?]', 'issue[parent_issue_id]', parent.id.to_s
+
+    put :update, :id => issue.id, :issue => {:subject => 'New subject', :parent_issue_id => parent.id.to_s}
+    assert_response 302
+    assert_equal parent, issue.parent
+  end
+
   def test_put_update_with_attachment_only
     set_tmp_attachments_directory