From 548e31689800ffde8d5578e23cb535e83c62c045 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 23 Nov 2014 08:44:39 +0000 Subject: [PATCH] Merged r13638 (#18060). git-svn-id: http://svn.redmine.org/redmine/branches/2.6-stable@13642 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/user.rb | 2 +- test/unit/user_test.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index d8590f47c..f9667b6a8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -354,7 +354,7 @@ class User < Principal def notified_project_ids=(ids) @notified_projects_ids_changed = true - @notified_projects_ids = ids + @notified_projects_ids = ids.map(&:to_i).uniq.select {|n| n > 0} end # Updates per project notifications (after_save callback) diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 187ec7c8b..8d0808c86 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -913,6 +913,11 @@ class UserTest < ActiveSupport::TestCase assert_equal 6, User.valid_notification_options(User.find(2)).size end + def test_notified_project_ids_setter_should_coerce_to_unique_integer_array + @jsmith.notified_project_ids = ["1", "123", "2u", "wrong", "12", 6, 12, -35, ""] + assert_equal [1, 123, 2, 12, 6], @jsmith.notified_projects_ids + end + def test_mail_notification_all @jsmith.mail_notification = 'all' @jsmith.notified_project_ids = []