diff --git a/app/helpers/categories_helper.rb b/app/helpers/categories_helper.rb index 4454141..d6aea24 100644 --- a/app/helpers/categories_helper.rb +++ b/app/helpers/categories_helper.rb @@ -12,7 +12,7 @@ module CategoriesHelper end def category_color_style(category) - return '' if category.display_color.blank? + return '' if category.nil? or category.display_color.blank? 'background-color: #'+category.display_color+';' end diff --git a/test/unit/categories_helper_test.rb b/test/unit/categories_helper_test.rb index e8fed85..768e235 100644 --- a/test/unit/categories_helper_test.rb +++ b/test/unit/categories_helper_test.rb @@ -31,4 +31,10 @@ class CategoriesHelperTest < ActiveSupport::TestCase assert_equal '', category_color_style(category2) end + should 'not return category parent color if category is nil' do + assert_nothing_raised do + assert_equal '', category_color_style(nil) + end + end + end -- libgit2 0.21.2