Make sure that Repository#extra_info returns a Hash or nil (#16032).
git-svn-id: http://svn.redmine.org/redmine/trunk@12848 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
a0baf7ee5d
commit
09b95905dc
|
@ -153,6 +153,12 @@ class Repository < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: should return an empty hash instead of nil to avoid many ||{}
|
||||||
|
def extra_info
|
||||||
|
h = read_attribute(:extra_info)
|
||||||
|
h.is_a?(Hash) ? h : nil
|
||||||
|
end
|
||||||
|
|
||||||
def merge_extra_info(arg)
|
def merge_extra_info(arg)
|
||||||
h = extra_info || {}
|
h = extra_info || {}
|
||||||
return h if arg.nil?
|
return h if arg.nil?
|
||||||
|
|
|
@ -348,6 +348,12 @@ class RepositoryTest < ActiveSupport::TestCase
|
||||||
assert_equal true, klass.scm_available
|
assert_equal true, klass.scm_available
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_extra_info_should_not_return_non_hash_value
|
||||||
|
repo = Repository.new
|
||||||
|
repo.extra_info = "foo"
|
||||||
|
assert_nil repo.extra_info
|
||||||
|
end
|
||||||
|
|
||||||
def test_merge_extra_info
|
def test_merge_extra_info
|
||||||
repo = Repository::Subversion.new(:project => Project.find(3))
|
repo = Repository::Subversion.new(:project => Project.find(3))
|
||||||
assert !repo.save
|
assert !repo.save
|
||||||
|
|
Loading…
Reference in New Issue