Commit b5a1db58d6df8c9cfc70deec35d6fe260384a8dd
1 parent
563fd3cc
Exists in
master
and in
29 other branches
ActionItem265: add tests for search_helper
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1972 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
22 additions
and
10 deletions
Show diff stats
app/helpers/search_helper.rb
... | ... | @@ -40,13 +40,10 @@ module SearchHelper |
40 | 40 | end |
41 | 41 | |
42 | 42 | def display_profile_info(profile) |
43 | - profile_info = '' | |
44 | - profile_info << content_tag('strong', profile.name) + '<br/>' | |
45 | - profile_info << link_to(url_for(profile.url), profile.url) + '<br/>' | |
46 | - content_tag( 'table', | |
47 | - content_tag( 'tr', | |
43 | + content_tag('table', | |
44 | + content_tag('tr', | |
48 | 45 | content_tag('td', content_tag('div', profile_image(profile, :thumb), :class => 'profile-info-picture')) + |
49 | - content_tag('td', profile_info) | |
46 | + content_tag('td', content_tag('strong', profile.name) + '<br/>' + link_to(url_for(profile.url), profile.url) + '<br/>') | |
50 | 47 | ), |
51 | 48 | :class => 'profile-info' |
52 | 49 | ) | ... | ... |
test/unit/search_helper.rb
... | ... | @@ -2,13 +2,28 @@ require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | |
3 | 3 | class SearchHelperTest < Test::Unit::TestCase |
4 | 4 | |
5 | + include SearchHelper | |
6 | + | |
5 | 7 | def setup |
6 | 8 | @profile = mock |
7 | - @helper = mock | |
8 | - helper.extend(SearchHelper) | |
9 | 9 | end |
10 | - attr_reader :profile, :helper | |
10 | + attr_reader :profile | |
11 | + | |
12 | + include ActionView::Helpers::FormOptionsHelper | |
13 | + include ActionView::Helpers::FormTagHelper | |
14 | + include ActionView::Helpers::TagHelper | |
15 | + should 'display profile info' do | |
16 | + profile.expects(:name).returns('Name of Profile') | |
17 | + profile.stubs(:url).returns('') | |
11 | 18 | |
12 | - should 'display profile info' | |
19 | + self.expects(:profile_image).returns('profileimage.png') | |
20 | + self.expects(:url_for).returns('merda') | |
21 | + self.expects(:link_to).returns('link to profile') | |
22 | + | |
23 | + result = self.display_profile_info(profile) | |
24 | + assert_match /profileimage.png/, result | |
25 | + assert_match /link to profile/, result | |
26 | + assert_match /<strong>Name of Profile<\/strong>/, result | |
27 | + end | |
13 | 28 | |
14 | 29 | end | ... | ... |