diff --git a/app/models/category.rb b/app/models/category.rb index 939e888..3e6995e 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -81,4 +81,8 @@ class Category < ActiveRecord::Base self.top_level? ? self : self.parent.top_ancestor end + def explode_path + path.split(/\//) + end + end diff --git a/test/unit/category_test.rb b/test/unit/category_test.rb index d4216c1..0be0cbe 100644 --- a/test/unit/category_test.rb +++ b/test/unit/category_test.rb @@ -195,4 +195,11 @@ class CategoryTest < Test::Unit::TestCase assert_equal c1, c3.top_ancestor end + should 'explode path' do + c1 = Category.create!(:name => 'parent', :environment_id => @env.id) + c2 = Category.create!(:name => 'child', :environment_id => @env.id, :parent_id => c1.id) + + assert_equal [ 'parent', 'child'], c2.explode_path + end + end -- libgit2 0.21.2