parent
e3526d5d4e
commit
b71245d5b7
@ -1,99 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2022 the OpenProject GmbH |
||||
# |
||||
# 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: |
||||
# 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. |
||||
# |
||||
# See COPYRIGHT and LICENSE files for more details. |
||||
#++ |
||||
|
||||
--- |
||||
versions_001: |
||||
created_at: 2006-07-19 21:00:07 +02:00 |
||||
name: "0.1" |
||||
project_id: 1 |
||||
updated_at: 2006-07-19 21:00:07 +02:00 |
||||
id: 1 |
||||
description: Beta |
||||
effective_date: 2006-07-01 |
||||
status: closed |
||||
sharing: 'none' |
||||
versions_002: |
||||
created_at: 2006-07-19 21:00:33 +02:00 |
||||
name: "1.0" |
||||
project_id: 1 |
||||
updated_at: 2006-07-19 21:00:33 +02:00 |
||||
id: 2 |
||||
description: Stable release |
||||
effective_date: <%= 20.day.from_now.to_date.to_fs(:db) %> |
||||
status: locked |
||||
sharing: 'none' |
||||
versions_003: |
||||
created_at: 2006-07-19 21:00:33 +02:00 |
||||
name: "2.0" |
||||
project_id: 1 |
||||
updated_at: 2006-07-19 21:00:33 +02:00 |
||||
id: 3 |
||||
description: Future version |
||||
effective_date: |
||||
status: open |
||||
sharing: 'none' |
||||
versions_004: |
||||
created_at: 2006-07-19 21:00:33 +02:00 |
||||
name: "2.0" |
||||
project_id: 3 |
||||
updated_at: 2006-07-19 21:00:33 +02:00 |
||||
id: 4 |
||||
description: Future version on subproject |
||||
effective_date: |
||||
status: open |
||||
sharing: 'tree' |
||||
versions_005: |
||||
created_at: 2006-07-19 21:00:07 +02:00 |
||||
name: "Alpha" |
||||
project_id: 2 |
||||
updated_at: 2006-07-19 21:00:07 +02:00 |
||||
id: 5 |
||||
description: Private Alpha |
||||
effective_date: 2006-07-01 |
||||
status: open |
||||
sharing: 'none' |
||||
versions_006: |
||||
created_at: 2006-07-19 21:00:07 +02:00 |
||||
name: "Private Version of public subproject" |
||||
project_id: 5 |
||||
updated_at: 2006-07-19 21:00:07 +02:00 |
||||
id: 6 |
||||
description: "Should be done any day now..." |
||||
effective_date: |
||||
status: open |
||||
sharing: 'tree' |
||||
versions_007: |
||||
created_at: 2006-07-19 21:00:07 +02:00 |
||||
name: "Systemwide visible version" |
||||
project_id: 2 |
||||
updated_at: 2006-07-19 21:00:07 +02:00 |
||||
id: 7 |
||||
description: |
||||
effective_date: |
||||
status: open |
||||
sharing: 'system' |
@ -1,40 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2022 the OpenProject GmbH |
||||
# |
||||
# 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: |
||||
# 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. |
||||
# |
||||
# See COPYRIGHT and LICENSE files for more details. |
||||
#++ |
||||
|
||||
module LegacyFileHelpers |
||||
module_function |
||||
|
||||
def mock_uploaded_file(name: 'test.txt', |
||||
content_type: 'text/plain', |
||||
content: 'test content', |
||||
binary: false) |
||||
|
||||
tmp = ::OpenProject::Files.create_temp_file name: name, content: content, binary: binary |
||||
Rack::Test::UploadedFile.new tmp.path, content_type, binary |
||||
end |
||||
end |
@ -1,97 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2022 the OpenProject GmbH |
||||
# |
||||
# 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: |
||||
# 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. |
||||
# |
||||
# See COPYRIGHT and LICENSE files for more details. |
||||
#++ |
||||
require_relative './../legacy_spec_helper' |
||||
|
||||
describe Enumeration, type: :model do |
||||
before do |
||||
WorkPackage.delete_all |
||||
@low_priority = create :priority_low |
||||
@issues = create_list :work_package, 6, priority: @low_priority |
||||
@default_enumeration = create :default_enumeration |
||||
end |
||||
|
||||
it 'ins use' do |
||||
assert @low_priority.in_use? |
||||
assert !create(:priority).in_use? |
||||
end |
||||
|
||||
it 'defaults' do |
||||
e = Enumeration.default |
||||
assert e.is_a?(Enumeration) |
||||
assert e.is_default? |
||||
assert_equal 'Default Enumeration', e.name |
||||
end |
||||
|
||||
it 'creates' do |
||||
e = Enumeration.new(name: 'Not default', is_default: false) |
||||
e.type = 'Enumeration' |
||||
assert e.save |
||||
assert_equal @default_enumeration.name, Enumeration.default.name |
||||
end |
||||
|
||||
it 'creates as default' do |
||||
e = Enumeration.new(name: 'Very urgent', is_default: true) |
||||
e.type = 'Enumeration' |
||||
assert e.save |
||||
assert_equal e, Enumeration.default |
||||
end |
||||
|
||||
it 'updates default' do |
||||
@default_enumeration.update(name: 'Changed', is_default: true) |
||||
assert_equal @default_enumeration, Enumeration.default |
||||
end |
||||
|
||||
it 'updates default to non default' do |
||||
@default_enumeration.update(name: 'Changed', is_default: false) |
||||
assert_nil Enumeration.default |
||||
end |
||||
|
||||
it 'changes default' do |
||||
e = Enumeration.find_by(name: @default_enumeration.name) |
||||
e.update(name: 'Changed Enumeration', is_default: true) |
||||
assert_equal e, Enumeration.default |
||||
end |
||||
|
||||
it 'destroys with reassign' do |
||||
new_priority = create :priority |
||||
Enumeration.find(@low_priority.id).destroy(new_priority) |
||||
assert_nil WorkPackage.find_by(priority_id: @low_priority.id) |
||||
assert_equal @issues.size, new_priority.objects_count |
||||
end |
||||
|
||||
it 'belongs to a project' do |
||||
association = Enumeration.reflect_on_association(:project) |
||||
assert association, 'No Project association found' |
||||
assert_equal :belongs_to, association.macro |
||||
end |
||||
|
||||
it 'acts as tree' do |
||||
assert @low_priority.respond_to?(:parent) |
||||
assert @low_priority.respond_to?(:children) |
||||
end |
||||
end |
@ -1,132 +0,0 @@ |
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2022 the OpenProject GmbH |
||||
# |
||||
# 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: |
||||
# 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. |
||||
# |
||||
# See COPYRIGHT and LICENSE files for more details. |
||||
#++ |
||||
require_relative '../legacy_spec_helper' |
||||
|
||||
describe Version, type: :model do |
||||
fixtures :all |
||||
|
||||
it 'progresses should be 0 with no assigned issues' do |
||||
project = Project.find(1) |
||||
(v = Version.new.tap do |v| |
||||
v.attributes = { project:, name: 'Progress' } |
||||
end).save! |
||||
assert_equal 0, v.completed_percent |
||||
assert_equal 0, v.closed_percent |
||||
end |
||||
|
||||
it 'progresses should be 0 with unbegun assigned issues' do |
||||
project = Project.find(1) |
||||
(v = Version.new.tap do |v| |
||||
v.attributes = { project:, name: 'Progress' } |
||||
end).save! |
||||
add_work_package(v) |
||||
add_work_package(v, done_ratio: 0) |
||||
assert_progress_equal 0, v.completed_percent |
||||
assert_progress_equal 0, v.closed_percent |
||||
end |
||||
|
||||
it 'progresses should be 100 with closed assigned issues' do |
||||
project = Project.find(1) |
||||
status = Status.where(is_closed: true).first |
||||
(v = Version.new.tap do |v| |
||||
v.attributes = { project:, name: 'Progress' } |
||||
end).save! |
||||
add_work_package(v, status:) |
||||
add_work_package(v, status:, done_ratio: 20) |
||||
add_work_package(v, status:, done_ratio: 70, estimated_hours: 25) |
||||
add_work_package(v, status:, estimated_hours: 15) |
||||
assert_progress_equal 100.0, v.completed_percent |
||||
assert_progress_equal 100.0, v.closed_percent |
||||
end |
||||
|
||||
it 'progresses should consider done ratio of open assigned issues' do |
||||
project = Project.find(1) |
||||
(v = Version.new.tap do |v| |
||||
v.attributes = { project:, name: 'Progress' } |
||||
end).save! |
||||
add_work_package(v) |
||||
add_work_package(v, done_ratio: 20) |
||||
add_work_package(v, done_ratio: 70) |
||||
assert_progress_equal (0.0 + 20.0 + 70.0) / 3, v.completed_percent |
||||
assert_progress_equal 0, v.closed_percent |
||||
end |
||||
|
||||
it 'progresses should consider closed issues as completed' do |
||||
project = Project.find(1) |
||||
(v = Version.new.tap do |v| |
||||
v.attributes = { project:, name: 'Progress' } |
||||
end).save! |
||||
add_work_package(v) |
||||
add_work_package(v, done_ratio: 20) |
||||
add_work_package(v, status: Status.where(is_closed: true).first) |
||||
assert_progress_equal (0.0 + 20.0 + 100.0) / 3, v.completed_percent |
||||
assert_progress_equal 100.0 / 3, v.closed_percent |
||||
end |
||||
|
||||
it 'progresses should consider estimated hours to weight issues' do |
||||
project = Project.find(1) |
||||
(v = Version.new.tap do |v| |
||||
v.attributes = { project:, name: 'Progress' } |
||||
end).save! |
||||
add_work_package(v, estimated_hours: 10) |
||||
add_work_package(v, estimated_hours: 20, done_ratio: 30) |
||||
add_work_package(v, estimated_hours: 40, done_ratio: 10) |
||||
add_work_package(v, estimated_hours: 25, status: Status.where(is_closed: true).first) |
||||
assert_progress_equal ((10.0 * 0) + (20.0 * 0.3) + (40 * 0.1) + (25.0 * 1)) / 95.0 * 100, v.completed_percent |
||||
assert_progress_equal 25.0 / 95.0 * 100, v.closed_percent |
||||
end |
||||
|
||||
it 'progresses should consider average estimated hours to weight unestimated issues' do |
||||
project = Project.find(1) |
||||
(v = Version.new.tap do |v| |
||||
v.attributes = { project:, name: 'Progress' } |
||||
end).save! |
||||
add_work_package(v, done_ratio: 20) |
||||
add_work_package(v, status: Status.where(is_closed: true).first) |
||||
add_work_package(v, estimated_hours: 10, done_ratio: 30) |
||||
add_work_package(v, estimated_hours: 40, done_ratio: 10) |
||||
assert_progress_equal ((25.0 * 0.2) + (25.0 * 1) + (10.0 * 0.3) + (40.0 * 0.1)) / 100.0 * 100, v.completed_percent |
||||
assert_progress_equal 25.0 / 100.0 * 100, v.closed_percent |
||||
end |
||||
|
||||
private |
||||
|
||||
def add_work_package(version, attributes = {}) |
||||
WorkPackage.create!({ project: version.project, |
||||
priority_id: 5, |
||||
status_id: 1, |
||||
version:, |
||||
subject: 'Test', |
||||
author: User.first, |
||||
type: version.project.types.first }.merge(attributes)) |
||||
end |
||||
|
||||
def assert_progress_equal(expected_float, actual_float, _message = '') |
||||
assert_in_delta(expected_float, actual_float, 0.000001, '') |
||||
end |
||||
end |
Loading…
Reference in new issue