Merged r24415 from trunk to 6.1-stable (#33610).

git-svn-id: https://svn.redmine.org/redmine/branches/6.1-stable@24420 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2026-02-17 00:38:18 +00:00
parent bc19a696ed
commit e613e08a3c
3 changed files with 19 additions and 2 deletions

View File

@@ -2016,7 +2016,7 @@ class Issue < ApplicationRecord
# Make sure updated_on is updated when adding a note and set updated_on now
# so we can set closed_on with the same value on closing
def force_updated_on_change
if @current_journal || changed?
if changed? || (@current_journal && !@current_journal.notes_and_details_empty?)
self.updated_on = current_time_from_proper_timezone
if new_record?
self.created_on = updated_on

View File

@@ -102,7 +102,11 @@ class Journal < ApplicationRecord
def save(*args)
journalize_changes
# Do not save an empty journal
(details.empty? && notes.blank?) ? false : super()
notes_and_details_empty? ? false : super()
end
def notes_and_details_empty?
notes.blank? && details.empty?
end
def journalized

View File

@@ -1623,6 +1623,19 @@ class IssueTest < ActiveSupport::TestCase
assert_not_equal updated_on_was, issue.updated_on
end
def test_adding_journal_with_notes_and_details_empty_should_not_update_timestamp
issue = Issue.find(1)
updated_on_was = issue.updated_on
issue.init_journal(User.first)
assert_no_difference 'Journal.count' do
assert issue.save
end
issue.reload
assert_equal updated_on_was, issue.updated_on
end
def test_should_close_duplicates
# Create 3 issues
issue1 = Issue.generate!