##// END OF EJS Templates
Fixed: validation error on issue creation when trying to add an invalid user as a watcher (#5373)....
Jean-Philippe Lang -
r5760:ef00501c3699
parent child
Show More
@@ -47,7 +47,28 class WatcherTest < ActiveSupport::TestCase
47 47 assert Issue.watched_by(@user).include?(@issue)
48 48 end
49 49
50 def test_watcher_users
51 watcher_users = Issue.find(2).watcher_users
52 assert_kind_of Array, watcher_users
53 assert_kind_of User, watcher_users.first
54 end
55
56 def test_watcher_users_should_not_validate_user
57 User.update_all("firstname = ''", "id=1")
58 @user.reload
59 assert !@user.valid?
60
61 issue = Issue.new(:project => Project.find(1), :tracker_id => 1, :subject => "test", :author => User.find(2))
62 issue.watcher_users << @user
63 issue.save!
64 assert issue.watched_by?(@user)
65 end
66
50 67 def test_watcher_user_ids
68 assert_equal [1, 3], Issue.find(2).watcher_user_ids.sort
69 end
70
71 def test_watcher_user_ids=
51 72 issue = Issue.new
52 73 issue.watcher_user_ids = ['1', '3']
53 74 assert issue.watched_by?(User.find(1))
@@ -13,7 +13,7 module Redmine
13 13
14 14 class_eval do
15 15 has_many :watchers, :as => :watchable, :dependent => :delete_all
16 has_many :watcher_users, :through => :watchers, :source => :user
16 has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
17 17
18 18 named_scope :watched_by, lambda { |user_id|
19 19 { :include => :watchers,
General Comments 0
You need to be logged in to leave comments. Login now