From d2fd7e489a5a4127a2fe85879b9253932642fa3f Mon Sep 17 00:00:00 2001
From: MAEDA Go
<%= f.check_box :is_in_roadmap %>
+<%= f.check_box :notes_allowed_on_closed %>
<%= f.textarea :description, :rows => 4 %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index e99f01f74..068feed20 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -429,6 +429,7 @@ en: field_last_activity_date: Last activity field_thousands_delimiter: Thousands delimiter field_ratio_interval: Ratio interval + field_notes_allowed_on_closed: Allow notes on closed issues setting_app_title: Application title setting_welcome_text: Welcome text diff --git a/db/migrate/20260201094039_add_notes_allowed_on_closed_to_trackers.rb b/db/migrate/20260201094039_add_notes_allowed_on_closed_to_trackers.rb new file mode 100644 index 000000000..210e7f720 --- /dev/null +++ b/db/migrate/20260201094039_add_notes_allowed_on_closed_to_trackers.rb @@ -0,0 +1,5 @@ +class AddNotesAllowedOnClosedToTrackers < ActiveRecord::Migration[6.1] + def change + add_column :trackers, :notes_allowed_on_closed, :boolean, default: true, null: false + end +end diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb index e5cd79ade..c5e53cc2a 100644 --- a/test/unit/issue_test.rb +++ b/test/unit/issue_test.rb @@ -953,6 +953,29 @@ class IssueTest < ActiveSupport::TestCase assert_equal '', issue.notes end + def test_should_not_allow_notes_on_closed_issue_when_tracker_disallows + tracker = Tracker.find(1) + tracker.update!(notes_allowed_on_closed: false) + + issue = Issue.find(8) + user = User.find(2) + issue.init_journal(user) + issue.send :safe_attributes=, {'notes' => 'note'}, user + assert_equal '', issue.notes + end + + def test_should_allow_notes_on_closed_issue_when_reopening + tracker = Tracker.find(1) + tracker.update!(notes_allowed_on_closed: false) + + issue = Issue.find(8) + issue.status_id = 1 + user = User.find(2) + issue.init_journal(user) + issue.send :safe_attributes=, {'notes' => 'note'}, user + assert_equal 'note', issue.notes + end + def test_safe_attributes_should_accept_target_tracker_enabled_fields source = Tracker.find(1) source.core_fields = [] diff --git a/test/unit/mail_handler_test.rb b/test/unit/mail_handler_test.rb index 373819be9..b7ae0b12a 100644 --- a/test/unit/mail_handler_test.rb +++ b/test/unit/mail_handler_test.rb @@ -972,6 +972,15 @@ class MailHandlerTest < ActiveSupport::TestCase assert !journal.notes.match(/^Start Date:/i) end + def test_update_issue_should_not_allow_notes_on_closed_issue_when_tracker_disallows + issue = Issue.find(2) + issue.update!(status: IssueStatus.find_by(:is_closed => true)) + issue.tracker.update!(notes_allowed_on_closed: false) + assert_no_difference 'Journal.count' do + submit_email('ticket_reply.eml') + end + end + def test_update_issue_with_attachment assert_difference 'Journal.count' do assert_difference 'JournalDetail.count' do -- 2.50.1