Fixed: validation error on issue creation when trying to add an invalid user as a watcher (#5373).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5880 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1b4a5e5aff
commit
ef00501c36
|
@ -47,7 +47,28 @@ class WatcherTest < ActiveSupport::TestCase
|
||||||
assert Issue.watched_by(@user).include?(@issue)
|
assert Issue.watched_by(@user).include?(@issue)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_watcher_users
|
||||||
|
watcher_users = Issue.find(2).watcher_users
|
||||||
|
assert_kind_of Array, watcher_users
|
||||||
|
assert_kind_of User, watcher_users.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_watcher_users_should_not_validate_user
|
||||||
|
User.update_all("firstname = ''", "id=1")
|
||||||
|
@user.reload
|
||||||
|
assert !@user.valid?
|
||||||
|
|
||||||
|
issue = Issue.new(:project => Project.find(1), :tracker_id => 1, :subject => "test", :author => User.find(2))
|
||||||
|
issue.watcher_users << @user
|
||||||
|
issue.save!
|
||||||
|
assert issue.watched_by?(@user)
|
||||||
|
end
|
||||||
|
|
||||||
def test_watcher_user_ids
|
def test_watcher_user_ids
|
||||||
|
assert_equal [1, 3], Issue.find(2).watcher_user_ids.sort
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_watcher_user_ids=
|
||||||
issue = Issue.new
|
issue = Issue.new
|
||||||
issue.watcher_user_ids = ['1', '3']
|
issue.watcher_user_ids = ['1', '3']
|
||||||
assert issue.watched_by?(User.find(1))
|
assert issue.watched_by?(User.find(1))
|
||||||
|
|
|
@ -13,7 +13,7 @@ module Redmine
|
||||||
|
|
||||||
class_eval do
|
class_eval do
|
||||||
has_many :watchers, :as => :watchable, :dependent => :delete_all
|
has_many :watchers, :as => :watchable, :dependent => :delete_all
|
||||||
has_many :watcher_users, :through => :watchers, :source => :user
|
has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
|
||||||
|
|
||||||
named_scope :watched_by, lambda { |user_id|
|
named_scope :watched_by, lambda { |user_id|
|
||||||
{ :include => :watchers,
|
{ :include => :watchers,
|
||||||
|
|
Loading…
Reference in New Issue