mirror of
https://github.com/redmine/redmine.git
synced 2026-02-17 12:07:51 +01:00
Avoid updating updated_on when submitting the issue edit form without changes (#33610).
Patch by Yuichi HARADA (user:yui.har). git-svn-id: https://svn.redmine.org/redmine/trunk@24415 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -2020,7 +2020,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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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!
|
||||
|
||||
Reference in New Issue
Block a user