Commit ca91bfe73db3c28191cc769e7e0606bf8299021d

Authored by Joenio Costa
1 parent 90b02139

test if category is nil before try to get color

(ActionItem2915)
app/helpers/categories_helper.rb
... ... @@ -12,7 +12,7 @@ module CategoriesHelper
12 12 end
13 13  
14 14 def category_color_style(category)
15   - return '' if category.display_color.blank?
  15 + return '' if category.nil? or category.display_color.blank?
16 16 'background-color: #'+category.display_color+';'
17 17 end
18 18  
... ...
test/unit/categories_helper_test.rb
... ... @@ -31,4 +31,10 @@ class CategoriesHelperTest < ActiveSupport::TestCase
31 31 assert_equal '', category_color_style(category2)
32 32 end
33 33  
  34 + should 'not return category parent color if category is nil' do
  35 + assert_nothing_raised do
  36 + assert_equal '', category_color_style(nil)
  37 + end
  38 + end
  39 +
34 40 end
... ...