Project

General

Profile

Feature #39500 » 0002-Change-the-default-notification-option-from-only_my_.patch

Go MAEDA, 2023-11-14 03:38

View differences:

config/settings.yml
314 314
  default: 0
315 315
  security_notifications: 1
316 316
default_notification_option:
317
  default: 'only_my_events'
317
  default: 'only_assigned'
318 318
emails_header:
319 319
  default: ''
320 320
thumbnails_enabled:
db/migrate/017_create_settings.rb
5 5
      t.column "value", :text
6 6
    end
7 7

  
8
    # Persist text_formatting default setting for new installations
9
    setting = Setting.new(:name => "text_formatting", :value => Setting.text_formatting)
10
    setting.save!
8
    # Persist default settings for new installations
9
    Setting.create!(name: 'default_notification_option', value: Setting.default_notification_option)
10
    Setting.create!(name: 'text_formatting', value: Setting.text_formatting)
11 11
  end
12 12

  
13 13
  def self.down
db/migrate/20231113131245_ensure_default_notification_option_is_stored_in_db.rb
1
class EnsureDefaultNotificationOptionIsStoredInDb < ActiveRecord::Migration[6.1]
2
  def up
3
    # Set the default value in Redmine <= 5.1 to preserve the behavior of existing installations
4
    Setting.find_or_create_by!(name: 'default_notification_option') do |setting|
5
      setting.value = 'only_my_events'
6
    end
7
  end
8

  
9
  def down
10
    # no-op
11
  end
12
end
test/unit/issue_test.rb
3017 3017
  end
3018 3018

  
3019 3019
  test "Issue#recipients should include the author if the author is active" do
3020
    issue = Issue.generate!(:author => User.generate!)
3020
    issue = Issue.generate!(:author => User.generate!(:mail_notification => 'only_my_events'))
3021 3021
    assert issue.author, "No author set for Issue"
3022 3022
    assert issue.recipients.include?(issue.author.mail)
3023 3023
  end
test/unit/user_test.rb
192 192

  
193 193
  def test_user_before_create_should_set_the_mail_notification_to_the_default_setting
194 194
    user1 = User.generate!
195
    assert_equal 'only_my_events', user1.mail_notification
195
    assert_equal 'only_assigned', user1.mail_notification
196 196
    with_settings :default_notification_option => 'all' do
197 197
      user2 = User.generate!
198 198
      assert_equal 'all', user2.mail_notification
(2-2/2)