Commit ca91bfe73db3c28191cc769e7e0606bf8299021d
1 parent
90b02139
Exists in
master
and in
29 other branches
test if category is nil before try to get color
(ActionItem2915)
Showing
2 changed files
with
7 additions
and
1 deletions
Show diff stats
app/helpers/categories_helper.rb
@@ -12,7 +12,7 @@ module CategoriesHelper | @@ -12,7 +12,7 @@ module CategoriesHelper | ||
12 | end | 12 | end |
13 | 13 | ||
14 | def category_color_style(category) | 14 | def category_color_style(category) |
15 | - return '' if category.display_color.blank? | 15 | + return '' if category.nil? or category.display_color.blank? |
16 | 'background-color: #'+category.display_color+';' | 16 | 'background-color: #'+category.display_color+';' |
17 | end | 17 | end |
18 | 18 |
test/unit/categories_helper_test.rb
@@ -31,4 +31,10 @@ class CategoriesHelperTest < ActiveSupport::TestCase | @@ -31,4 +31,10 @@ class CategoriesHelperTest < ActiveSupport::TestCase | ||
31 | assert_equal '', category_color_style(category2) | 31 | assert_equal '', category_color_style(category2) |
32 | end | 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 | end | 40 | end |