]> source.dussan.org Git - redmine.git/commitdiff
Merged r12848 (#16032).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 7 Feb 2014 08:09:36 +0000 (08:09 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 7 Feb 2014 08:09:36 +0000 (08:09 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/2.4-stable@12853 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/repository.rb
test/unit/repository_test.rb

index de3ca99a6fb25d5c583269d30e8cf060291c5e0a..a752fdf2ff14c013546df4cdbf6fd95959efd4ed 100644 (file)
@@ -153,6 +153,12 @@ class Repository < ActiveRecord::Base
     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)
     h = extra_info || {}
     return h if arg.nil?
index c269df7bb7f7192d1a3633843e4a3389d4a3f1fc..1c8ce5a854d4e3a9720d58d24a17e73629f2c063 100644 (file)
@@ -326,6 +326,12 @@ class RepositoryTest < ActiveSupport::TestCase
     assert_equal true, klass.scm_available
   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
     repo = Repository::Subversion.new(:project => Project.find(3))
     assert !repo.save