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.
86 lines
3.2 KiB
86 lines
3.2 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
|
#
|
||
14 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'
|
||
14 years ago
|
|
||
11 years ago
|
describe 'CustomFieldFormat' do # TODO: what is this?
|
||
|
before do
|
||
12 years ago
|
@project = FactoryGirl.create :valid_project
|
||
10 years ago
|
role = FactoryGirl.create :role, permissions: [:view_work_packages, :edit_work_packages]
|
||
12 years ago
|
@users = FactoryGirl.create_list(:user, 5)
|
||
10 years ago
|
@users.each do |user| @project.add_member!(user, role) end
|
||
11 years ago
|
@issue = FactoryGirl.create :work_package,
|
||
10 years ago
|
project: @project,
|
||
|
author: @users.first,
|
||
|
type: @project.types.first
|
||
10 years ago
|
@field = WorkPackageCustomField.create!(name: 'Tester', field_format: 'user')
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should possible_values_with_no_arguments' do
|
||
14 years ago
|
assert_equal [], @field.possible_values
|
||
|
assert_equal [], @field.possible_values(nil)
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should possible_values_with_project_resource' do
|
||
12 years ago
|
possible_values = @field.possible_values(@project.work_packages.first)
|
||
14 years ago
|
assert possible_values.any?
|
||
10 years ago
|
assert_equal @project.users.sort.map(&:id).map(&:to_s), possible_values
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should possible_values_with_nil_project_resource' do
|
||
11 years ago
|
assert_equal [], @field.possible_values(WorkPackage.new)
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should possible_values_options_with_no_arguments' do
|
||
14 years ago
|
assert_equal [], @field.possible_values_options
|
||
|
assert_equal [], @field.possible_values_options(nil)
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should possible_values_options_with_project_resource' do
|
||
12 years ago
|
possible_values_options = @field.possible_values_options(@project.work_packages.first)
|
||
14 years ago
|
assert possible_values_options.any?
|
||
10 years ago
|
assert_equal @project.users.sort.map { |u| [u.name, u.id.to_s] }, possible_values_options
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should cast_blank_value' do
|
||
14 years ago
|
assert_equal nil, @field.cast_value(nil)
|
||
10 years ago
|
assert_equal nil, @field.cast_value('')
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should cast_valid_value' do
|
||
12 years ago
|
user = @field.cast_value("#{@users.first.id}")
|
||
14 years ago
|
assert_kind_of User, user
|
||
12 years ago
|
assert_equal @users.first, user
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should cast_invalid_value' do
|
||
12 years ago
|
User.delete_all
|
||
10 years ago
|
assert_equal nil, @field.cast_value('1')
|
||
14 years ago
|
end
|
||
|
end
|