]> source.dussan.org Git - redmine.git/commitdiff
Selected projects in email notifications on "my account" are lost when the page is...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 22 Nov 2014 10:56:59 +0000 (10:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 22 Nov 2014 10:56:59 +0000 (10:56 +0000)
Patch by Felix Schäfer.

git-svn-id: http://svn.redmine.org/redmine/trunk@13638 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user.rb
test/unit/user_test.rb

index b5bb6ae1ef39c0c42ce89a06c0d07281ddd2ac55..76e9beac6b255412c6f0d7aa3585cc2d7e19583a 100644 (file)
@@ -368,7 +368,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)
index df0e79f188dc44593ee198d4995f9ffb8413e289..bf784200f59baeace8f118edafb8c40aa4a4818a 100644 (file)
@@ -948,6 +948,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 = []