Commit 84bc45839645ab539c231ef39afff5d20fafe546
1 parent
6d682759
Exists in
master
and in
29 other branches
ActionItem70: implementing explode_path
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@545 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
11 additions
and
0 deletions
Show diff stats
app/models/category.rb
@@ -81,4 +81,8 @@ class Category < ActiveRecord::Base | @@ -81,4 +81,8 @@ class Category < ActiveRecord::Base | ||
81 | self.top_level? ? self : self.parent.top_ancestor | 81 | self.top_level? ? self : self.parent.top_ancestor |
82 | end | 82 | end |
83 | 83 | ||
84 | + def explode_path | ||
85 | + path.split(/\//) | ||
86 | + end | ||
87 | + | ||
84 | end | 88 | end |
test/unit/category_test.rb
@@ -195,4 +195,11 @@ class CategoryTest < Test::Unit::TestCase | @@ -195,4 +195,11 @@ class CategoryTest < Test::Unit::TestCase | ||
195 | assert_equal c1, c3.top_ancestor | 195 | assert_equal c1, c3.top_ancestor |
196 | end | 196 | end |
197 | 197 | ||
198 | + should 'explode path' do | ||
199 | + c1 = Category.create!(:name => 'parent', :environment_id => @env.id) | ||
200 | + c2 = Category.create!(:name => 'child', :environment_id => @env.id, :parent_id => c1.id) | ||
201 | + | ||
202 | + assert_equal [ 'parent', 'child'], c2.explode_path | ||
203 | + end | ||
204 | + | ||
198 | end | 205 | end |