Project

General

Profile

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

Toshi MARUYAMA, 2020-01-31 14:33

View differences:

test/unit/issue_test.rb
2099 2099
    assert !closed_statuses.empty?
2100 2100
  end
2101 2101

  
2102
  def test_parent_issues_with_open_subtask_dont_allow_closed_statuses
2102
  test "test parent issues with open subtask dont allow closed statuses" do
2103 2103
    parent = Issue.generate!
2104 2104
    child = Issue.generate!(:parent_issue_id => parent.id)
2105 2105

  
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 :closed_parent_issues_with_open_subtasks %></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
417 417
  setting_timespan_format: Time span format
418 418
  setting_cross_project_issue_relations: Allow cross-project issue relations
419 419
  setting_cross_project_subtasks: Allow cross-project subtasks
420
  setting_closed_parent_issues_with_open_subtasks: Allow closed parent issues with open subtasks
420 421
  setting_issue_list_default_columns: Isuses list defaults
421 422
  setting_repositories_encodings: Attachments and repositories encodings
422 423
  setting_emails_header: Email header
config/settings.yml
177 177
  default: 'derived'
178 178
link_copied_issue:
179 179
  default: 'ask'
180
closed_parent_issues_with_open_subtasks:
181
  default: 0
180 182
close_duplicate_issues:
181 183
  default: 1
182 184
issue_group_assignment:
app/models/issue.rb
1008 1008
    statuses << default_status if include_default || (new_record? && statuses.empty?)
1009 1009

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

  
2102
  test "test parent issues with open subtask dont allow closed statuses" do
2102
  test "test parent issues with open subtask dont allow closed statuses if setting is false" do
2103 2103
    parent = Issue.generate!
2104 2104
    child = Issue.generate!(:parent_issue_id => parent.id)
2105

  
2106
    allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002))
2107
    assert allowed_statuses.any?
2108
    assert_equal [], allowed_statuses.select(&:is_closed?)
2105
    with_settings :closed_parent_issues_with_open_subtasks => 0 do
2106
      allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002))
2107
      assert allowed_statuses.any?
2108
      assert_equal [], allowed_statuses.select(&:is_closed?)
2109
    end
2110
  end
2111

  
2112
  test "test parent issues with open subtask allow closed statuses if setting is true" do
2113
    parent = Issue.generate!
2114
    child = Issue.generate!(:parent_issue_id => parent.id)
2115
    with_settings :closed_parent_issues_with_open_subtasks => 1 do
2116
      allowed_statuses = parent.reload.new_statuses_allowed_to(users(:users_002))
2117
      assert allowed_statuses.any?
2118
      assert allowed_statuses.select(&:is_closed?).any?
2119
    end
2109 2120
  end
2110 2121

  
2111 2122
  def test_parent_issues_with_closed_subtask_allow_closed_statuses
(5-5/6)