Commit 9b43a97d33f42397c5138acf20961abcb2dffbba
1 parent
8c270900
Exists in
master
and in
22 other branches
ActionItem18: creating block that lists recent documents of current profile
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@432 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
40 additions
and
0 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -99,6 +99,10 @@ module ApplicationHelper |
| 99 | 99 | link_to text, { :profile => profile }.merge(url), options |
| 100 | 100 | end |
| 101 | 101 | |
| 102 | + def link_to_document(doc) | |
| 103 | + link_homepage(doc.title, doc.profile.identifier, :page => doc.full_path) | |
| 104 | + end | |
| 105 | + | |
| 102 | 106 | # TODO: add the actual links |
| 103 | 107 | # TODO: test this helper |
| 104 | 108 | def user_links | ... | ... |
| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | +require File.dirname(__FILE__) + '/../test_helper' | |
| 2 | + | |
| 3 | +class RecentDocumentsBlockTest < Test::Unit::TestCase | |
| 4 | + | |
| 5 | + # Replace this with your real tests. | |
| 6 | + def test_should_output_list_with_links_to_recent_documents | |
| 7 | + profile = mock | |
| 8 | + profile.stubs(:identifier).returns('a_test_profile') | |
| 9 | + | |
| 10 | + doc1 = mock | |
| 11 | + doc2 = mock | |
| 12 | + doc3 = mock | |
| 13 | + profile.expects(:recent_documents).returns([doc1, doc2, doc3]) | |
| 14 | + | |
| 15 | + helper = mock | |
| 16 | + helper.expects(:profile).returns(profile) | |
| 17 | + helper.expects(:link_to_document).with(doc1).returns('doc1') | |
| 18 | + helper.expects(:link_to_document).with(doc2).returns('doc2') | |
| 19 | + helper.expects(:link_to_document).with(doc3).returns('doc3') | |
| 20 | + helper.expects(:content_tag).with('ul', "doc1\ndoc2\ndoc3").returns('the_tag') | |
| 21 | + | |
| 22 | + assert_equal('the_tag', helper.instance_eval(&RecentDocumentsBlock.new.content)) | |
| 23 | + end | |
| 24 | +end | ... | ... |