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:
parent
1cd6a2aa84
commit
2be6f54f23
|
@ -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]}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue