Commit b55cda261bed13d84803aafbcf598734643e5235

Authored by AntonioTerceiro
1 parent 40552448

ActionItem21: to display the public path of the article



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@979 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/article.rb
... ... @@ -45,4 +45,8 @@ class Article < ActiveRecord::Base
45 45 name
46 46 end
47 47  
  48 + def public_path
  49 + "/" + [profile.identifier, path].join('/')
  50 + end
  51 +
48 52 end
... ...
test/unit/article_test.rb
... ... @@ -104,4 +104,17 @@ class ArticleTest < Test::Unit::TestCase
104 104 assert a4.errors.invalid?(:slug)
105 105 end
106 106  
  107 + should 'calculate public path' do
  108 + # top level
  109 + a = profile.articles.build(:name => 'aaa')
  110 + a.save!
  111 + assert_equal "/#{profile.identifier}/aaa", a.public_path
  112 +
  113 + # child articles
  114 + b = profile.articles.build(:name => 'bbb')
  115 + b.parent = a
  116 + b.save!
  117 + assert_equal "/#{profile.identifier}/aaa/bbb", b.public_path
  118 + end
  119 +
107 120 end
... ...