mirror of
https://github.com/meineerde/redmine.git
synced 2026-04-02 05:51:38 +00:00
The descendant count in the issues delete confirmation message is wrong if issues share some descendants.
git-svn-id: http://svn.redmine.org/redmine/trunk@13818 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1699e37a0c
commit
bfdd9f7c29
@ -180,20 +180,20 @@ module IssuesHelper
|
|||||||
s.html_safe
|
s.html_safe
|
||||||
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
|
||||||
|
ids -= issues.map(&:id)
|
||||||
|
ids.size
|
||||||
|
end
|
||||||
|
|
||||||
def issues_destroy_confirmation_message(issues)
|
def issues_destroy_confirmation_message(issues)
|
||||||
issues = [issues] unless issues.is_a?(Array)
|
issues = [issues] unless issues.is_a?(Array)
|
||||||
message = l(:text_issues_destroy_confirmation)
|
message = l(:text_issues_destroy_confirmation)
|
||||||
descendant_count = issues.inject(0) {|memo, i| memo += (i.right - i.left - 1)/2}
|
|
||||||
|
descendant_count = issues_descendant_count(issues)
|
||||||
if descendant_count > 0
|
if descendant_count > 0
|
||||||
issues.each do |issue|
|
message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
|
||||||
next if issue.root?
|
|
||||||
issues.each do |other_issue|
|
|
||||||
descendant_count -= 1 if issue.is_descendant_of?(other_issue)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if descendant_count > 0
|
|
||||||
message << "\n" + l(:text_issues_destroy_descendants_confirmation, :count => descendant_count)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
message
|
message
|
||||||
end
|
end
|
||||||
|
|||||||
@ -68,6 +68,16 @@ class IssuesHelperTest < ActionView::TestCase
|
|||||||
issues_destroy_confirmation_message(Issue.find([1, 2]))
|
issues_destroy_confirmation_message(Issue.find([1, 2]))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_issues_destroy_confirmation_message_with_issues_that_share_descendants
|
||||||
|
root = Issue.generate!
|
||||||
|
child = Issue.generate!(:parent_issue_id => root.id)
|
||||||
|
Issue.generate!(:parent_issue_id => child.id)
|
||||||
|
|
||||||
|
assert_equal l(:text_issues_destroy_confirmation) + "\n" +
|
||||||
|
l(:text_issues_destroy_descendants_confirmation, :count => 1),
|
||||||
|
issues_destroy_confirmation_message([root.reload, child.reload])
|
||||||
|
end
|
||||||
|
|
||||||
test 'show_detail with no_html should show a changing attribute' do
|
test 'show_detail with no_html should show a changing attribute' do
|
||||||
detail = JournalDetail.new(:property => 'attr', :old_value => '40',
|
detail = JournalDetail.new(:property => 'attr', :old_value => '40',
|
||||||
:value => '100', :prop_key => 'done_ratio')
|
:value => '100', :prop_key => 'done_ratio')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user