Project

General

Profile

Patch #40194 ยป clear_disabled_fields.patch

Yazan Al aeddin, 2024-02-05 16:56

View differences:

app/models/issue.rb
2069 2069
      tracker.disabled_core_fields.each do |attribute|
2070 2070
        send "#{attribute}=", nil
2071 2071
      end
2072
      self.priority_id ||= IssuePriority.default&.id || IssuePriority.active.first.id
2072
      self.priority_id ||= IssuePriority.default&.id || IssuePriority.active.first&.id
2073 2073
      self.done_ratio ||= 0
2074 2074
    end
2075 2075
  end
test/unit/issue_test.rb
3559 3559
    r = Issue.like('issue today')
3560 3560
    assert_include Issue.find(7), r
3561 3561
  end
3562

  
3563
  test "clear_disabled_fields raises error when no priority is present" do
3564
    issue = Issue.new
3565
    # Stubbing IssuePriority.default and IssuePriority.active.first to return nil
3566
    IssuePriority.stubs(:default).returns(nil)
3567
    IssuePriority.stubs(:active).returns([])
3568

  
3569
    issue.tracker = Tracker.find(1)
3570
    issue.priority_id = nil
3571
 
3572
    # Assert that attempting to call clear_disabled_fields raises NoMethodError
3573
    assert_nothing_raised { issue.send(:clear_disabled_fields) }
3574
  end
3562 3575
end
    (1-1/1)