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 Status, type: :model do
|
||
12 years ago
|
fixtures :all
|
||
18 years ago
|
|
||
11 years ago
|
it 'should create' do
|
||
10 years ago
|
status = Status.new name: 'Assigned'
|
||
18 years ago
|
assert !status.save
|
||
|
# status name uniqueness
|
||
|
assert_equal 1, status.errors.count
|
||
14 years ago
|
|
||
10 years ago
|
status.name = 'Test Status'
|
||
18 years ago
|
assert status.save
|
||
|
assert !status.is_default
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should destroy' do
|
||
11 years ago
|
status = Status.find(3)
|
||
|
assert_difference 'Status.count', -1 do
|
||
15 years ago
|
assert status.destroy
|
||
|
end
|
||
10 years ago
|
assert_equal 0, Workflow.where(old_status_id: status.id).count
|
||
|
assert_equal 0, Workflow.where(new_status_id: status.id).count
|
||
16 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should destroy status in use' do
|
||
16 years ago
|
# Status assigned to an Issue
|
||
11 years ago
|
status = WorkPackage.find(1).status
|
||
9 years ago
|
assert_raises(RuntimeError, "Can't delete status") { status.destroy }
|
||
16 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should default' do
|
||
11 years ago
|
status = Status.default
|
||
|
assert_kind_of Status, status
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should change default' do
|
||
11 years ago
|
status = Status.find(2)
|
||
18 years ago
|
assert !status.is_default
|
||
|
status.is_default = true
|
||
|
assert status.save
|
||
|
status.reload
|
||
14 years ago
|
|
||
11 years ago
|
assert_equal status, Status.default
|
||
|
assert !Status.find(1).is_default
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should reorder should not clear default status' do
|
||
11 years ago
|
status = Status.default
|
||
16 years ago
|
status.move_to_bottom
|
||
|
status.reload
|
||
|
assert status.is_default?
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
context '#update_done_ratios' do
|
||
11 years ago
|
before do
|
||
11 years ago
|
@issue = WorkPackage.find(1)
|
||
11 years ago
|
@status = Status.find(1)
|
||
|
@status.update_attribute(:default_done_ratio, 50)
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
context 'with Setting.work_package_done_ratio using the field' do
|
||
11 years ago
|
before do
|
||
11 years ago
|
Setting.work_package_done_ratio = 'field'
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should change nothing' do
|
||
11 years ago
|
Status.update_work_package_done_ratios
|
||
15 years ago
|
|
||
10 years ago
|
assert_equal 0, WorkPackage.where(done_ratio: 50).count
|
||
15 years ago
|
end
|
||
|
end
|
||
|
|
||
10 years ago
|
context 'with Setting.work_package_done_ratio using the status' do
|
||
11 years ago
|
before do
|
||
11 years ago
|
Setting.work_package_done_ratio = 'status'
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it "should update all of the issue's done_ratios to match their Issue Status" do
|
||
11 years ago
|
Status.update_work_package_done_ratios
|
||
14 years ago
|
|
||
10 years ago
|
issues = WorkPackage.find([1, 3, 4, 5, 6, 7, 9, 10])
|
||
15 years ago
|
issues.each do |issue|
|
||
11 years ago
|
assert_equal @status, issue.status
|
||
15 years ago
|
assert_equal 50, issue.read_attribute(:done_ratio)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
18 years ago
|
end
|