fix-33610.patch

Yuichi HARADA, 2020-06-26 04:27

Download (1.81 KB)

View differences:

app/models/issue.rb
1853 1853
  # Make sure updated_on is updated when adding a note and set updated_on now
1854 1854
  # so we can set closed_on with the same value on closing
1855 1855
  def force_updated_on_change
1856
    if @current_journal || changed?
1856
    if changed? || (@current_journal && !@current_journal.notes_and_details_empty?)
1857 1857
      self.updated_on = current_time_from_proper_timezone
1858 1858
      if new_record?
1859 1859
        self.created_on = updated_on
app/models/journal.rb
82 82
  def save(*args)
83 83
    journalize_changes
84 84
    # Do not save an empty journal
85
    (details.empty? && notes.blank?) ? false : super
85
    notes_and_details_empty? ? false : super
86
  end
87

  
88
  def notes_and_details_empty?
89
    notes.blank? && details.empty?
86 90
  end
87 91

  
88 92
  # Returns journal details that are visible to user
test/unit/issue_test.rb
1508 1508
    assert_not_equal updated_on_was, issue.updated_on
1509 1509
  end
1510 1510

  
1511
  def test_adding_journal_with_notes_and_details_empty_should_not_update_timestamp
1512
    issue = Issue.find(1)
1513
    updated_on_was = issue.updated_on
1514

  
1515
    issue.init_journal(User.first)
1516
    assert_no_difference 'Journal.count' do
1517
      assert issue.save
1518
    end
1519
    issue.reload
1520

  
1521
    assert_equal updated_on_was, issue.updated_on
1522
  end
1523

  
1511 1524
  def test_should_close_duplicates
1512 1525
    # Create 3 issues
1513 1526
    issue1 = Issue.generate!