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.
108 lines
3.4 KiB
108 lines
3.4 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
|
#
|
||
17 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'
|
||
17 years ago
|
|
||
11 years ago
|
describe Activity, type: :model do
|
||
12 years ago
|
fixtures :all
|
||
17 years ago
|
|
||
11 years ago
|
before do
|
||
17 years ago
|
@project = Project.find(1)
|
||
10 years ago
|
[1, 4, 5, 6].each do |issue_id|
|
||
11 years ago
|
i = WorkPackage.find(issue_id)
|
||
10 years ago
|
i.add_journal(User.current, 'A journal to find')
|
||
14 years ago
|
i.save!
|
||
|
end
|
||
11 years ago
|
|
||
10 years ago
|
WorkPackage.all.each(&:recreate_initial_journal!)
|
||
|
Message.all.each(&:recreate_initial_journal!)
|
||
11 years ago
|
end
|
||
|
|
||
11 years ago
|
after do
|
||
11 years ago
|
Journal.delete_all
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should activity without subprojects' do
|
||
10 years ago
|
events = find_events(User.anonymous, project: @project)
|
||
9 years ago
|
refute_nil events
|
||
14 years ago
|
|
||
11 years ago
|
assert events.include?(WorkPackage.find(1))
|
||
|
assert !events.include?(WorkPackage.find(4))
|
||
17 years ago
|
# subproject issue
|
||
11 years ago
|
assert !events.include?(WorkPackage.find(5))
|
||
17 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should activity with subprojects' do
|
||
10 years ago
|
events = find_events(User.anonymous, project: @project, with_subprojects: 1)
|
||
9 years ago
|
refute_nil events
|
||
14 years ago
|
|
||
11 years ago
|
assert events.include?(WorkPackage.find(1))
|
||
17 years ago
|
# subproject issue
|
||
11 years ago
|
assert events.include?(WorkPackage.find(5))
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should global activity anonymous' do
|
||
17 years ago
|
events = find_events(User.anonymous)
|
||
9 years ago
|
refute_nil events
|
||
14 years ago
|
|
||
11 years ago
|
assert events.include?(WorkPackage.find(1))
|
||
17 years ago
|
assert events.include?(Message.find(5))
|
||
|
# Issue of a private project
|
||
11 years ago
|
assert !events.include?(WorkPackage.find(6))
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should global activity logged user' do
|
||
17 years ago
|
events = find_events(User.find(2)) # manager
|
||
9 years ago
|
refute_nil events
|
||
14 years ago
|
|
||
11 years ago
|
assert events.include?(WorkPackage.find(1))
|
||
17 years ago
|
# Issue of a private project the user belongs to
|
||
11 years ago
|
assert events.include?(WorkPackage.find(6))
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should user activity' do
|
||
16 years ago
|
user = User.find(2)
|
||
10 years ago
|
events = Redmine::Activity::Fetcher.new(User.anonymous, author: user).events(nil, nil, limit: 10)
|
||
14 years ago
|
|
||
16 years ago
|
assert(events.size > 0)
|
||
|
assert(events.size <= 10)
|
||
10 years ago
|
assert_nil(events.detect { |e| e.event_author != user })
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
17 years ago
|
private
|
||
14 years ago
|
|
||
10 years ago
|
def find_events(user, options = {})
|
||
14 years ago
|
events = Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1)
|
||
|
# Because events are provided by the journals, but we want to test for
|
||
|
# their targets here, transform that
|
||
10 years ago
|
events.map do |e|
|
||
11 years ago
|
e.provider.new.activitied_type.find(e.journable_id)
|
||
11 years ago
|
end
|
||
17 years ago
|
end
|
||
|
end
|