Fixes #possible_values_options when given an object with nil project.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5273 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2011-04-01 13:56:25 +00:00 committed by Eric Davis
parent d8fbdca760
commit 8fae4e2ee5
2 changed files with 6 additions and 1 deletions

View File

@ -51,7 +51,7 @@ class CustomField < ActiveRecord::Base
def possible_values_options(obj=nil)
case field_format
when 'user', 'version'
if obj.respond_to?(:project)
if obj.respond_to?(:project) && obj.project
case field_format
when 'user'
obj.project.users.sort.collect {|u| [u.to_s, u.id.to_s]}

View File

@ -36,6 +36,11 @@ class CustomFieldUserFormatTest < ActiveSupport::TestCase
assert_equal project.users.sort.collect(&:id).map(&:to_s), possible_values
end
def test_possible_values_with_nil_project_resource
project = Project.find(1)
assert_equal [], @field.possible_values(Issue.new)
end
def test_possible_values_options_with_no_arguments
assert_equal [], @field.possible_values_options
assert_equal [], @field.possible_values_options(nil)