Commit 73a5446e4b7bd9de266618cf8e4515fe62168e81
1 parent
270edd9e
Exists in
master
and in
28 other branches
Display top ancestor category at track card title
Showing
2 changed files
with
7 additions
and
5 deletions
Show diff stats
plugins/community_track/lib/community_track_plugin/track.rb
@@ -57,7 +57,7 @@ class CommunityTrackPlugin::Track < Folder | @@ -57,7 +57,7 @@ class CommunityTrackPlugin::Track < Folder | ||
57 | 57 | ||
58 | def category_name | 58 | def category_name |
59 | category = categories.first | 59 | category = categories.first |
60 | - category ? category.name : '' | 60 | + category ? category.top_ancestor.name : '' |
61 | end | 61 | end |
62 | 62 | ||
63 | def to_html(options = {}) | 63 | def to_html(options = {}) |
plugins/community_track/test/unit/community_track_plugin/track_test.rb
@@ -39,10 +39,12 @@ class TrackTest < ActiveSupport::TestCase | @@ -39,10 +39,12 @@ class TrackTest < ActiveSupport::TestCase | ||
39 | assert_equal [@step], @track.steps_unsorted | 39 | assert_equal [@step], @track.steps_unsorted |
40 | end | 40 | end |
41 | 41 | ||
42 | - should 'return category name' do | ||
43 | - category = fast_create(Category, :name => 'category') | ||
44 | - @track.add_category(category, true) | ||
45 | - assert_equal 'category', @track.category_name | 42 | + should 'return name of the top category' do |
43 | + top = fast_create(Category, :name => 'top category') | ||
44 | + category1 = fast_create(Category, :name => 'category1', :parent_id => top.id ) | ||
45 | + category2 = fast_create(Category, :name => 'category2', :parent_id => category1.id ) | ||
46 | + @track.add_category(category2, true) | ||
47 | + assert_equal 'top category', @track.category_name | ||
46 | end | 48 | end |
47 | 49 | ||
48 | should 'return empty for category name if it has no category' do | 50 | should 'return empty for category name if it has no category' do |