]> source.dussan.org Git - redmine.git/commitdiff
Fixed that relations to issues that are not visible are displayed in the issue histor...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 13 Jul 2013 09:56:58 +0000 (09:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 13 Jul 2013 09:56:58 +0000 (09:56 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12014 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/journal.rb
test/unit/journal_test.rb

index c14051f8392a90828c4499dcb96890fcf3123662..70ecc54f518f1ebfceb9e361f6d205b3b6b91284 100644 (file)
@@ -53,12 +53,15 @@ class Journal < ActiveRecord::Base
     (details.empty? && notes.blank?) ? false : super
   end
 
+  # Returns journal details that are visible to user
   def visible_details(user=User.current)
     details.select do |detail|
       if detail.property == 'cf' 
         field_id = detail.prop_key
         field = CustomField.find_by_id(field_id)
         field && field.visible_by?(project, user)
+      elsif detail.property == 'relation'
+        Issue.find_by_id(detail.value || detail.old_value).try(:visible?, user)
       else
         true
       end
index 38d75d723bc016fe0f74712ea764542e42d5428e..e3184bf216ec8a8a225ae3aa339962a5670c4028 100644 (file)
@@ -175,4 +175,23 @@ class JournalTest < ActiveSupport::TestCase
     assert_equal '0', j.old_value
     assert_equal '0', j.value
   end
+
+  def test_visible_details_should_include_relations_to_visible_issues_only
+    issue = Issue.generate!
+    visible_issue = Issue.generate!
+    IssueRelation.create!(:issue_from => issue, :issue_to => visible_issue, :relation_type => 'relates')
+    hidden_issue = Issue.generate!(:is_private => true)
+    IssueRelation.create!(:issue_from => issue, :issue_to => hidden_issue, :relation_type => 'relates')
+    issue.reload
+    assert_equal 1, issue.journals.size
+    journal = issue.journals.first
+    assert_equal 2, journal.details.size
+
+    visible_details = journal.visible_details(User.anonymous)
+    assert_equal 1, visible_details.size
+    assert_equal visible_issue.id.to_s, visible_details.first.value
+
+    visible_details = journal.visible_details(User.find(2))
+    assert_equal 2, visible_details.size
+  end
 end