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.
282 lines
9.3 KiB
282 lines
9.3 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 Changeset, type: :model do
|
||
12 years ago
|
fixtures :all
|
||
17 years ago
|
|
||
11 years ago
|
it 'should ref keywords any' do
|
||
10 years ago
|
with_settings notified_events: %w(work_package_updated) do
|
||
|
WorkPackage.all.each(&:recreate_initial_journal!)
|
||
11 years ago
|
|
||
10 years ago
|
Setting.commit_fix_status_id = Status.where(['is_closed = ?', true]).first.id
|
||
10 years ago
|
Setting.commit_fix_done_ratio = '90'
|
||
|
Setting.commit_ref_keywords = '*'
|
||
|
Setting.commit_fix_keywords = 'fixes , closes'
|
||
14 years ago
|
|
||
10 years ago
|
c = Changeset.new(repository: Project.find(1).repository,
|
||
|
committed_on: Time.now,
|
||
|
comments: 'New commit (#2). Fixes #1')
|
||
|
c.scan_comment_for_work_package_ids
|
||
14 years ago
|
|
||
10 years ago
|
assert_equal [1, 2], c.work_package_ids.sort
|
||
|
fixed = WorkPackage.find(1)
|
||
|
assert fixed.closed?
|
||
|
assert_equal 90, fixed.done_ratio
|
||
|
assert_equal 2, ActionMailer::Base.deliveries.size
|
||
|
end
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should ref keywords' do
|
||
14 years ago
|
Setting.commit_ref_keywords = 'refs'
|
||
|
Setting.commit_fix_keywords = ''
|
||
14 years ago
|
|
||
10 years ago
|
c = Changeset.new(repository: Project.find(1).repository,
|
||
|
committed_on: Time.now,
|
||
|
comments: 'Ignores #2. Refs #1')
|
||
11 years ago
|
c.scan_comment_for_work_package_ids
|
||
14 years ago
|
|
||
11 years ago
|
assert_equal [1], c.work_package_ids.sort
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should ref keywords any only' do
|
||
14 years ago
|
Setting.commit_ref_keywords = '*'
|
||
|
Setting.commit_fix_keywords = ''
|
||
14 years ago
|
|
||
10 years ago
|
c = Changeset.new(repository: Project.find(1).repository,
|
||
|
committed_on: Time.now,
|
||
|
comments: 'Ignores #2. Refs #1')
|
||
11 years ago
|
c.scan_comment_for_work_package_ids
|
||
14 years ago
|
|
||
11 years ago
|
assert_equal [1, 2], c.work_package_ids.sort
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should ref keywords any with timelog' do
|
||
14 years ago
|
Setting.commit_ref_keywords = '*'
|
||
|
Setting.commit_logtime_enabled = '1'
|
||
|
|
||
14 years ago
|
{
|
||
|
'2' => 2.0,
|
||
|
'2h' => 2.0,
|
||
|
'2hours' => 2.0,
|
||
|
'15m' => 0.25,
|
||
|
'15min' => 0.25,
|
||
|
'3h15' => 3.25,
|
||
|
'3h15m' => 3.25,
|
||
|
'3h15min' => 3.25,
|
||
|
'3:15' => 3.25,
|
||
|
'3.25' => 3.25,
|
||
|
'3.25h' => 3.25,
|
||
|
'3,25' => 3.25,
|
||
|
'3,25h' => 3.25,
|
||
|
}.each do |syntax, expected_hours|
|
||
10 years ago
|
c = Changeset.new(repository: Project.find(1).repository,
|
||
|
committed_on: 24.hours.ago,
|
||
|
comments: "Worked on this work_package #1 @#{syntax}",
|
||
|
revision: '520',
|
||
|
user: User.find(2))
|
||
14 years ago
|
assert_difference 'TimeEntry.count' do
|
||
11 years ago
|
c.scan_comment_for_work_package_ids
|
||
14 years ago
|
end
|
||
11 years ago
|
assert_equal [1], c.work_package_ids.sort
|
||
14 years ago
|
|
||
10 years ago
|
time = TimeEntry.order('id DESC').first
|
||
12 years ago
|
assert_equal 1, time.work_package_id
|
||
14 years ago
|
assert_equal 1, time.project_id
|
||
|
assert_equal 2, time.user_id
|
||
|
assert_equal expected_hours, time.hours, "@#{syntax} should be logged as #{expected_hours} hours but was #{time.hours}"
|
||
|
assert_equal Date.yesterday, time.spent_on
|
||
|
assert time.activity.is_default?
|
||
|
assert time.comments.include?('r520'), "r520 was expected in time_entry comments: #{time.comments}"
|
||
14 years ago
|
end
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should ref keywords closing with timelog' do
|
||
10 years ago
|
Setting.commit_fix_status_id = Status.where(['is_closed = ?', true]).first.id
|
||
14 years ago
|
Setting.commit_ref_keywords = '*'
|
||
|
Setting.commit_fix_keywords = 'fixes , closes'
|
||
|
Setting.commit_logtime_enabled = '1'
|
||
14 years ago
|
|
||
10 years ago
|
c = Changeset.new(repository: Project.find(1).repository,
|
||
|
committed_on: Time.now,
|
||
|
comments: 'This is a comment. Fixes #1 @4.5, #2 @1',
|
||
|
user: User.find(2))
|
||
14 years ago
|
assert_difference 'TimeEntry.count', 2 do
|
||
11 years ago
|
c.scan_comment_for_work_package_ids
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
assert_equal [1, 2], c.work_package_ids.sort
|
||
11 years ago
|
assert WorkPackage.find(1).closed?
|
||
|
assert WorkPackage.find(2).closed?
|
||
14 years ago
|
|
||
10 years ago
|
times = TimeEntry.order('id desc').limit(2)
|
||
10 years ago
|
assert_equal [1, 2], times.map(&:work_package_id).sort
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should ref keywords any line start' do
|
||
17 years ago
|
Setting.commit_ref_keywords = '*'
|
||
|
|
||
10 years ago
|
c = Changeset.new(repository: Project.find(1).repository,
|
||
|
committed_on: Time.now,
|
||
|
comments: '#1 is the reason of this commit')
|
||
11 years ago
|
c.scan_comment_for_work_package_ids
|
||
17 years ago
|
|
||
11 years ago
|
assert_equal [1], c.work_package_ids.sort
|
||
17 years ago
|
end
|
||
17 years ago
|
|
||
11 years ago
|
it 'should ref keywords allow brackets around a work package number' do
|
||
15 years ago
|
Setting.commit_ref_keywords = '*'
|
||
|
|
||
10 years ago
|
c = Changeset.new(repository: Project.find(1).repository,
|
||
|
committed_on: Time.now,
|
||
|
comments: '[#1] Worked on this work_package')
|
||
11 years ago
|
c.scan_comment_for_work_package_ids
|
||
15 years ago
|
|
||
11 years ago
|
assert_equal [1], c.work_package_ids.sort
|
||
15 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should ref keywords allow brackets around multiple work package numbers' do
|
||
15 years ago
|
Setting.commit_ref_keywords = '*'
|
||
|
|
||
10 years ago
|
c = Changeset.new(repository: Project.find(1).repository,
|
||
|
committed_on: Time.now,
|
||
|
comments: '[#1 #2, #3] Worked on these')
|
||
11 years ago
|
c.scan_comment_for_work_package_ids
|
||
15 years ago
|
|
||
10 years ago
|
assert_equal [1, 2, 3], c.work_package_ids.sort
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should commit referencing a subproject work package' do
|
||
10 years ago
|
c = Changeset.new(repository: Project.find(1).repository,
|
||
|
committed_on: Time.now,
|
||
|
comments: 'refs #5, a subproject work_package')
|
||
11 years ago
|
c.scan_comment_for_work_package_ids
|
||
14 years ago
|
|
||
11 years ago
|
assert_equal [5], c.work_package_ids.sort
|
||
|
assert c.work_packages.first.project != c.project
|
||
15 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should commit referencing a parent project work package' do
|
||
15 years ago
|
# repository of child project
|
||
14 years ago
|
r = Repository::Subversion.create!(
|
||
11 years ago
|
project: Project.find(3),
|
||
10 years ago
|
scm_type: 'existing',
|
||
|
url: 'svn://localhost/test')
|
||
14 years ago
|
|
||
10 years ago
|
c = Changeset.new(repository: r,
|
||
|
committed_on: Time.now,
|
||
|
comments: 'refs #2, an work_package of a parent project')
|
||
11 years ago
|
c.scan_comment_for_work_package_ids
|
||
14 years ago
|
|
||
11 years ago
|
assert_equal [2], c.work_package_ids.sort
|
||
|
assert c.work_packages.first.project != c.project
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should text tag revision' do
|
||
10 years ago
|
c = Changeset.new(revision: '520')
|
||
14 years ago
|
assert_equal 'r520', c.text_tag
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should text tag hash' do
|
||
14 years ago
|
c = Changeset.new(
|
||
11 years ago
|
scmid: '7234cb2750b63f47bff735edc50a1c0a433c2518',
|
||
|
revision: '7234cb2750b63f47bff735edc50a1c0a433c2518')
|
||
14 years ago
|
assert_equal 'commit:7234cb2750b63f47bff735edc50a1c0a433c2518', c.text_tag
|
||
|
end
|
||
15 years ago
|
|
||
11 years ago
|
it 'should text tag hash all number' do
|
||
10 years ago
|
c = Changeset.new(scmid: '0123456789', revision: '0123456789')
|
||
14 years ago
|
assert_equal 'commit:0123456789', c.text_tag
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should previous' do
|
||
10 years ago
|
changeset = Changeset.find_by(revision: '3')
|
||
|
assert_equal Changeset.find_by(revision: '2'), changeset.previous
|
||
17 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should previous nil' do
|
||
10 years ago
|
changeset = Changeset.find_by(revision: '1')
|
||
17 years ago
|
assert_nil changeset.previous
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should next' do
|
||
10 years ago
|
changeset = Changeset.find_by(revision: '2')
|
||
|
assert_equal Changeset.find_by(revision: '3'), changeset.next
|
||
17 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should next nil' do
|
||
10 years ago
|
changeset = Changeset.find_by(revision: '10')
|
||
17 years ago
|
assert_nil changeset.next
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should comments nil' do
|
||
9 years ago
|
with_settings enabled_scm: ['subversion'] do
|
||
9 years ago
|
proj = Project.find(3)
|
||
|
r = FactoryGirl.create(:repository_subversion,
|
||
|
project: proj)
|
||
|
assert r
|
||
|
|
||
|
c = Changeset.new(repository: r,
|
||
|
committed_on: Time.now,
|
||
|
revision: '123',
|
||
|
scmid: '12345',
|
||
|
comments: nil)
|
||
|
assert(c.save)
|
||
|
assert_equal '', c.comments
|
||
|
if c.comments.respond_to?(:force_encoding)
|
||
|
assert_equal 'UTF-8', c.comments.encoding.to_s
|
||
14 years ago
|
end
|
||
12 years ago
|
end
|
||
14 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should comments empty' do
|
||
9 years ago
|
with_settings enabled_scm: ['subversion'] do
|
||
10 years ago
|
proj = Project.find(3)
|
||
9 years ago
|
r = FactoryGirl.create(:repository_subversion)
|
||
|
|
||
10 years ago
|
assert r
|
||
10 years ago
|
c = Changeset.new(repository: r,
|
||
|
committed_on: Time.now,
|
||
|
revision: '123',
|
||
|
scmid: '12345',
|
||
|
comments: '')
|
||
|
assert(c.save)
|
||
|
assert_equal '', c.comments
|
||
10 years ago
|
if c.comments.respond_to?(:force_encoding)
|
||
10 years ago
|
assert_equal 'UTF-8', c.comments.encoding.to_s
|
||
10 years ago
|
end
|
||
14 years ago
|
end
|
||
12 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should identifier' do
|
||
10 years ago
|
c = Changeset.find_by(revision: '1')
|
||
14 years ago
|
assert_equal c.revision, c.identifier
|
||
|
end
|
||
17 years ago
|
end
|