kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.5 KiB
119 lines
3.5 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
12 years ago
|
# OpenProject is a project management system.
|
||
10 years ago
|
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
14 years ago
|
#
|
||
18 years ago
|
# This program is free software; you can redistribute it and/or
|
||
12 years ago
|
# modify it under the terms of the GNU General Public License version 3.
|
||
14 years ago
|
#
|
||
11 years ago
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
10 years ago
|
require 'legacy_spec_helper'
|
||
18 years ago
|
|
||
11 years ago
|
describe Watcher do
|
||
|
before do
|
||
12 years ago
|
@user = FactoryGirl.create :user
|
||
11 years ago
|
@issue = FactoryGirl.create :work_package
|
||
10 years ago
|
@role = FactoryGirl.create :role, permissions: [:view_work_packages]
|
||
12 years ago
|
@issue.project.add_member! @user, @role
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should add_watcher' do
|
||
12 years ago
|
@issue.add_watcher(@user)
|
||
|
assert_contains @issue.watchers.map(&:user), @user
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should add_watcher_will_not_add_same_user_twice' do
|
||
18 years ago
|
assert @issue.add_watcher(@user)
|
||
12 years ago
|
refute @issue.add_watcher(@user)
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should watched_by' do
|
||
12 years ago
|
@issue.add_watcher(@user)
|
||
18 years ago
|
assert @issue.watched_by?(@user)
|
||
11 years ago
|
assert_contains WorkPackage.watched_by(@user), @issue
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it 'watcher_users contains correct_classes' do
|
||
12 years ago
|
@issue.add_watcher(@user)
|
||
10 years ago
|
expect(@issue.watcher_users).to all be_kind_of(User)
|
||
14 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should watcher_users_should_not_validate_user' do
|
||
10 years ago
|
allow(@user).to receive(:valid?).and_return(false)
|
||
12 years ago
|
@issue.watcher_users << @user
|
||
|
assert @issue.watched_by?(@user)
|
||
14 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should watcher_user_ids' do
|
||
12 years ago
|
@issue.add_watcher(@user)
|
||
|
assert_contains @issue.watcher_user_ids, @user.id
|
||
14 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should watcher_user_ids' do
|
||
12 years ago
|
@issue.watcher_user_ids = [@user.id]
|
||
|
assert @issue.watched_by?(@user)
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should watcher_user_ids_should_make_ids_uniq' do
|
||
12 years ago
|
@issue.watcher_user_ids = [@user.id, @user.id]
|
||
|
assert @issue.valid?
|
||
|
assert_equal 1, @issue.watchers.count
|
||
13 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should recipients' do
|
||
12 years ago
|
@user.update_attribute :mail_notification, 'all'
|
||
14 years ago
|
|
||
18 years ago
|
assert @issue.watcher_recipients.empty?
|
||
|
assert @issue.add_watcher(@user)
|
||
9 years ago
|
assert_contains @issue.watcher_recipients, @user
|
||
18 years ago
|
|
||
12 years ago
|
@user.update_attribute :mail_notification, 'none'
|
||
9 years ago
|
assert_does_not_contain @issue.watcher_recipients, @user
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should unwatch' do
|
||
18 years ago
|
assert @issue.add_watcher(@user)
|
||
11 years ago
|
@issue.save
|
||
14 years ago
|
assert_equal 1, @issue.remove_watcher(@user)
|
||
11 years ago
|
@issue.save
|
||
|
@issue.reload
|
||
12 years ago
|
refute @issue.watched_by?(@user)
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should prune_removes_watchers_that_dont_have_permission' do
|
||
12 years ago
|
@issue.add_watcher(@user)
|
||
14 years ago
|
|
||
15 years ago
|
assert_no_difference 'Watcher.count' do
|
||
10 years ago
|
Watcher.prune(user: @user)
|
||
15 years ago
|
end
|
||
12 years ago
|
assert @issue.watched_by?(@user)
|
||
14 years ago
|
|
||
15 years ago
|
Member.delete_all
|
||
12 years ago
|
@user.reload
|
||
14 years ago
|
|
||
12 years ago
|
assert_difference 'Watcher.count', -1 do
|
||
10 years ago
|
Watcher.prune(user: @user)
|
||
15 years ago
|
end
|
||
12 years ago
|
refute @issue.watched_by?(@user)
|
||
15 years ago
|
end
|
||
18 years ago
|
end
|