Project

General

Profile

Feature #28492 » issue-28492.ver.2.diff

Toshi MARUYAMA, 2019-10-16 03:53

View differences:

test/unit/issue_test.rb
2082 2082
    assert !closed_statuses.empty?
2083 2083
  end
2084 2084

  
2085
  def test_parent_issues_with_open_subtask_dont_allow_closed_statuses
2085
  test "test parent issues with open subtask dont allow closed statuses" do
2086 2086
    parent = Issue.generate!
2087 2087
    child = Issue.generate!(:parent_issue_id => parent.id)
2088 2088

  
app/views/settings/_issues.html.erb
7 7

  
8 8
<p><%= setting_select :cross_project_subtasks, cross_project_subtasks_options %></p>
9 9

  
10
<p><%= setting_check_box :close_parent_issue_whose_subtasks_are_open %></p>
11

  
10 12
<p><%= setting_check_box :close_duplicate_issues %></p>
11 13

  
12 14
<p><%= setting_check_box :issue_group_assignment %></p>
config/locales/en.yml
416 416
  setting_timespan_format: Time span format
417 417
  setting_cross_project_issue_relations: Allow cross-project issue relations
418 418
  setting_cross_project_subtasks: Allow cross-project subtasks
419
  setting_close_parent_issue_whose_subtasks_are_open: Allow closing parent issue whose subtasks are open
419 420
  setting_issue_list_default_columns: Isuses list defaults
420 421
  setting_repositories_encodings: Attachments and repositories encodings
421 422
  setting_emails_header: Email header
config/settings.yml
177 177
  default: 'derived'
178 178
link_copied_issue:
179 179
  default: 'ask'
180
close_parent_issue_whose_subtasks_are_open:
181
  default: 0
180 182
close_duplicate_issues:
181 183
  default: 1
182 184
issue_group_assignment:
app/models/issue.rb
1009 1009
    statuses << default_status if include_default || (new_record? && statuses.empty?)
1010 1010

  
1011 1011
    statuses = statuses.compact.uniq.sort
1012
    if blocked? || descendants.open.any?
1013
      # cannot close a blocked issue or a parent with open subtasks
1012
    if blocked? || (!Setting.close_parent_issue_whose_subtasks_are_open? && descendants.open.any?)
1014 1013
      statuses.reject!(&:is_closed?)
1015 1014
    end
1016 1015
    if ancestors.open(false).any?
test/unit/issue_test.rb
2082 2082
    assert !closed_statuses.empty?
2083 2083
  end
2084 2084

  
2085
  test "test parent issues with open subtask dont allow closed statuses" do
2085
  test "test parent issues with open subtask dont allow closed statuses if setting is false" do
2086 2086
    parent = Issue.generate!
2087 2087
    child = Issue.generate!(:parent_issue_id => parent.id)
2088

  
2089
    allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002))
2090
    assert allowed_statuses.any?
2091
    assert_equal [], allowed_statuses.select(&:is_closed?)
2088
    with_settings :close_parent_issue_whose_subtasks_are_open => 0 do
2089
      allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002))
2090
      assert allowed_statuses.any?
2091
      assert_equal [], allowed_statuses.select(&:is_closed?)
2092
    end
2093
  end
2094

  
2095
  test "test parent issues with open subtask allow closed statuses if setting is true" do
2096
    parent = Issue.generate!
2097
    child = Issue.generate!(:parent_issue_id => parent.id)
2098
    with_settings :close_parent_issue_whose_subtasks_are_open => 1 do
2099
      allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002))
2100
      assert allowed_statuses.any?
2101
      assert allowed_statuses.select(&:is_closed?).any?
2102
    end
2092 2103
  end
2093 2104

  
2094 2105
  def test_parent_issues_with_closed_subtask_allow_closed_statuses
(3-3/6)