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.
248 lines
6.7 KiB
248 lines
6.7 KiB
9 years ago
|
#-- copyright
|
||
5 years ago
|
# OpenProject is an open source project management software.
|
||
|
# Copyright (C) 2012-2020 the OpenProject GmbH
|
||
9 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
8 years ago
|
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||
9 years ago
|
# 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.
|
||
|
#
|
||
7 years ago
|
# See docs/COPYRIGHT.rdoc for more details.
|
||
9 years ago
|
#++
|
||
|
|
||
|
require 'spec_helper'
|
||
|
|
||
5 years ago
|
describe Projects::Activity, type: :model do
|
||
6 years ago
|
let(:project) do
|
||
7 years ago
|
FactoryBot.create(:project)
|
||
6 years ago
|
end
|
||
9 years ago
|
|
||
|
let(:initial_time) { Time.now }
|
||
|
|
||
6 years ago
|
let(:work_package) do
|
||
7 years ago
|
FactoryBot.create(:work_package,
|
||
6 years ago
|
project: project)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:work_package2) do
|
||
7 years ago
|
FactoryBot.create(:work_package,
|
||
6 years ago
|
project: project)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:wiki_content) do
|
||
9 years ago
|
project.reload
|
||
|
|
||
7 years ago
|
page = FactoryBot.create(:wiki_page,
|
||
6 years ago
|
wiki: project.wiki)
|
||
9 years ago
|
|
||
7 years ago
|
FactoryBot.create(:wiki_content,
|
||
6 years ago
|
page: page)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:wiki_content2) do
|
||
9 years ago
|
project.reload
|
||
|
|
||
7 years ago
|
page = FactoryBot.create(:wiki_page,
|
||
6 years ago
|
wiki: project.wiki)
|
||
9 years ago
|
|
||
7 years ago
|
FactoryBot.create(:wiki_content,
|
||
6 years ago
|
page: page)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:news) do
|
||
7 years ago
|
FactoryBot.create(:news,
|
||
6 years ago
|
project: project)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:news2) do
|
||
7 years ago
|
FactoryBot.create(:news,
|
||
6 years ago
|
project: project)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:repository) do
|
||
7 years ago
|
FactoryBot.create(:repository_git,
|
||
6 years ago
|
project: project)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:changeset) do
|
||
7 years ago
|
FactoryBot.create(:changeset,
|
||
6 years ago
|
repository: repository)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:changeset2) do
|
||
7 years ago
|
FactoryBot.create(:changeset,
|
||
6 years ago
|
repository: repository)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:forum) do
|
||
|
FactoryBot.create(:forum,
|
||
6 years ago
|
project: project)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:message) do
|
||
7 years ago
|
FactoryBot.create(:message,
|
||
6 years ago
|
forum: forum)
|
||
6 years ago
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:message2) do
|
||
7 years ago
|
FactoryBot.create(:message,
|
||
6 years ago
|
forum: forum)
|
||
6 years ago
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:time_entry) do
|
||
7 years ago
|
FactoryBot.create(:time_entry,
|
||
6 years ago
|
work_package: work_package,
|
||
|
project: project)
|
||
|
end
|
||
9 years ago
|
|
||
6 years ago
|
let(:time_entry2) do
|
||
7 years ago
|
FactoryBot.create(:time_entry,
|
||
6 years ago
|
work_package: work_package,
|
||
|
project: project)
|
||
|
end
|
||
9 years ago
|
|
||
|
def latest_activity
|
||
|
Project.with_latest_activity.find(project.id).latest_activity_at
|
||
|
end
|
||
|
|
||
|
describe '.with_latest_activity' do
|
||
|
it 'is the latest work_package update' do
|
||
|
work_package.update_attribute(:updated_at, initial_time - 10.seconds)
|
||
|
work_package2.update_attribute(:updated_at, initial_time - 20.seconds)
|
||
|
work_package.reload
|
||
|
work_package2.reload
|
||
|
|
||
|
expect(latest_activity).to eql work_package.updated_at
|
||
|
end
|
||
|
|
||
|
it 'is the latest wiki_contents update' do
|
||
|
wiki_content.update_attribute(:updated_on, initial_time - 10.seconds)
|
||
|
wiki_content2.update_attribute(:updated_on, initial_time - 20.seconds)
|
||
|
wiki_content.reload
|
||
|
wiki_content2.reload
|
||
|
|
||
|
expect(latest_activity).to eql wiki_content.updated_on
|
||
|
end
|
||
|
|
||
|
it 'is the latest news update' do
|
||
5 years ago
|
news.update_attribute(:updated_at, initial_time - 10.seconds)
|
||
|
news2.update_attribute(:updated_at, initial_time - 20.seconds)
|
||
9 years ago
|
news.reload
|
||
|
news2.reload
|
||
|
|
||
5 years ago
|
expect(latest_activity).to eql news.updated_at
|
||
9 years ago
|
end
|
||
|
|
||
|
it 'is the latest changeset update' do
|
||
|
changeset.update_attribute(:committed_on, initial_time - 10.seconds)
|
||
|
changeset2.update_attribute(:committed_on, initial_time - 20.seconds)
|
||
|
changeset.reload
|
||
|
changeset2.reload
|
||
|
|
||
|
expect(latest_activity).to eql changeset.committed_on
|
||
|
end
|
||
|
|
||
|
it 'is the latest message update' do
|
||
|
message.update_attribute(:updated_on, initial_time - 10.seconds)
|
||
|
message2.update_attribute(:updated_on, initial_time - 20.seconds)
|
||
|
message.reload
|
||
|
message2.reload
|
||
|
|
||
|
expect(latest_activity).to eql message.updated_on
|
||
|
end
|
||
|
|
||
|
it 'is the latest time_entry update' do
|
||
|
work_package.update_attribute(:updated_at, initial_time - 60.seconds)
|
||
|
time_entry.update_attribute(:updated_on, initial_time - 10.seconds)
|
||
|
time_entry2.update_attribute(:updated_on, initial_time - 20.seconds)
|
||
|
time_entry.reload
|
||
|
time_entry2.reload
|
||
|
|
||
|
expect(latest_activity).to eql time_entry.updated_on
|
||
|
end
|
||
|
|
||
|
it 'takes the time stamp of the latest activity across models' do
|
||
|
work_package.update_attribute(:updated_at, initial_time - 10.seconds)
|
||
|
wiki_content.update_attribute(:updated_on, initial_time - 20.seconds)
|
||
5 years ago
|
news.update_attribute(:updated_at, initial_time - 30.seconds)
|
||
9 years ago
|
changeset.update_attribute(:committed_on, initial_time - 40.seconds)
|
||
|
message.update_attribute(:updated_on, initial_time - 50.seconds)
|
||
|
|
||
|
work_package.reload
|
||
|
wiki_content.reload
|
||
|
news.reload
|
||
|
changeset.reload
|
||
|
message.reload
|
||
|
|
||
|
# Order:
|
||
|
# work_package
|
||
|
# wiki_content
|
||
|
# news
|
||
|
# changeset
|
||
|
# message
|
||
|
|
||
|
expect(latest_activity).to eql work_package.updated_at
|
||
|
|
||
|
work_package.update_attribute(:updated_at, message.updated_on - 10.seconds)
|
||
|
|
||
|
# Order:
|
||
|
# wiki_content
|
||
|
# news
|
||
|
# changeset
|
||
|
# message
|
||
|
# work_package
|
||
|
|
||
|
expect(latest_activity).to eql wiki_content.updated_on
|
||
|
|
||
|
wiki_content.update_attribute(:updated_on, work_package.updated_at - 10.seconds)
|
||
|
|
||
|
# Order:
|
||
|
# news
|
||
|
# changeset
|
||
|
# message
|
||
|
# work_package
|
||
|
# wiki_content
|
||
|
|
||
5 years ago
|
expect(latest_activity).to eql news.updated_at
|
||
9 years ago
|
|
||
5 years ago
|
news.update_attribute(:updated_at, wiki_content.updated_on - 10.seconds)
|
||
9 years ago
|
|
||
|
# Order:
|
||
|
# changeset
|
||
|
# message
|
||
|
# work_package
|
||
|
# wiki_content
|
||
|
# news
|
||
|
|
||
|
expect(latest_activity).to eql changeset.committed_on
|
||
|
|
||
5 years ago
|
changeset.update_attribute(:committed_on, news.updated_at - 10.seconds)
|
||
9 years ago
|
|
||
|
# Order:
|
||
|
# message
|
||
|
# work_package
|
||
|
# wiki_content
|
||
|
# news
|
||
|
# changeset
|
||
|
|
||
|
expect(latest_activity).to eql message.updated_on
|
||
|
end
|
||
|
end
|
||
|
end
|