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.
117 lines
3.8 KiB
117 lines
3.8 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 Enumeration, type: :model do
|
||
|
before do
|
||
11 years ago
|
WorkPackage.delete_all
|
||
12 years ago
|
@low_priority = FactoryGirl.create :priority_low
|
||
10 years ago
|
@issues = FactoryGirl.create_list :work_package, 6, priority: @low_priority
|
||
12 years ago
|
@default_enumeration = FactoryGirl.create :default_enumeration
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should objects count' do
|
||
12 years ago
|
assert_equal @issues.size, @low_priority.objects_count
|
||
|
assert_equal 0, FactoryGirl.create(:priority).objects_count
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should in use' do
|
||
12 years ago
|
assert @low_priority.in_use?
|
||
|
assert !FactoryGirl.create(:priority).in_use?
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should default' do
|
||
16 years ago
|
e = Enumeration.default
|
||
16 years ago
|
assert e.is_a?(Enumeration)
|
||
|
assert e.is_default?
|
||
16 years ago
|
assert_equal 'Default Enumeration', e.name
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should create' do
|
||
10 years ago
|
e = Enumeration.new(name: 'Not default', is_default: false)
|
||
16 years ago
|
e.type = 'Enumeration'
|
||
16 years ago
|
assert e.save
|
||
12 years ago
|
assert_equal @default_enumeration.name, Enumeration.default.name
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should create as default' do
|
||
10 years ago
|
e = Enumeration.new(name: 'Very urgent', is_default: true)
|
||
16 years ago
|
e.type = 'Enumeration'
|
||
16 years ago
|
assert e.save
|
||
16 years ago
|
assert_equal e, Enumeration.default
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should update default' do
|
||
10 years ago
|
@default_enumeration.update_attributes(name: 'Changed', is_default: true)
|
||
12 years ago
|
assert_equal @default_enumeration, Enumeration.default
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should update default to non default' do
|
||
10 years ago
|
@default_enumeration.update_attributes(name: 'Changed', is_default: false)
|
||
16 years ago
|
assert_nil Enumeration.default
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should change default' do
|
||
10 years ago
|
e = Enumeration.find_by(name: @default_enumeration.name)
|
||
10 years ago
|
e.update_attributes(name: 'Changed Enumeration', is_default: true)
|
||
16 years ago
|
assert_equal e, Enumeration.default
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should destroy with reassign' do
|
||
12 years ago
|
new_priority = FactoryGirl.create :priority
|
||
|
Enumeration.find(@low_priority).destroy(new_priority)
|
||
9 years ago
|
assert_nil WorkPackage.find_by(priority_id: @low_priority.id)
|
||
12 years ago
|
assert_equal @issues.size, new_priority.objects_count
|
||
17 years ago
|
end
|
||
15 years ago
|
|
||
11 years ago
|
it 'should be customizable' do
|
||
15 years ago
|
assert Enumeration.included_modules.include?(Redmine::Acts::Customizable::InstanceMethods)
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should belong to a project' do
|
||
15 years ago
|
association = Enumeration.reflect_on_association(:project)
|
||
10 years ago
|
assert association, 'No Project association found'
|
||
15 years ago
|
assert_equal :belongs_to, association.macro
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should act as tree' do
|
||
12 years ago
|
assert @low_priority.respond_to?(:parent)
|
||
|
assert @low_priority.respond_to?(:children)
|
||
15 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should is override' do
|
||
15 years ago
|
# Defaults to off
|
||
12 years ago
|
assert !@low_priority.is_override?
|
||
15 years ago
|
|
||
|
# Setup as an override
|
||
12 years ago
|
@low_priority.parent = FactoryGirl.create :priority
|
||
|
assert @low_priority.is_override?
|
||
15 years ago
|
end
|
||
17 years ago
|
end
|