Commit 58babac309e80534c299ba0ff1b6b3d61cbfbb94
1 parent
7a857453
Exists in
master
and in
29 other branches
ActionItem512: add more info to box of google map
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2130 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
44 additions
and
11 deletions
Show diff stats
app/helpers/search_helper.rb
... | ... | @@ -43,20 +43,21 @@ module SearchHelper |
43 | 43 | # FIXME add distance |
44 | 44 | data = '' |
45 | 45 | unless profile.contact_email.nil? |
46 | - data << content_tag('strong', _('E-Mail:')) + profile.contact_email + '<br/>' | |
46 | + data << content_tag('strong', _('E-Mail: ')) + profile.contact_email + '<br/>' | |
47 | 47 | end |
48 | 48 | unless profile.contact_phone.nil? |
49 | - data << content_tag('strong', _('Phone:')) + profile.contact_phone + '<br/>' | |
49 | + data << content_tag('strong', _('Phone(s): ')) + profile.contact_phone + '<br/>' | |
50 | 50 | end |
51 | 51 | unless profile.address.nil? |
52 | - data << content_tag('strong', _('Address:')) + profile.address + '<br/>' | |
52 | + data << content_tag('strong', _('Address: ')) + profile.address + '<br/>' | |
53 | + end | |
54 | + unless profile.products.empty? | |
55 | + data << content_tag('strong', _('Products/Services: ')) + profile.products.map{|i| link_to(i.name, :controller => 'catalog', :profile => profile.identifier, :action => 'show', :id => i)}.join(', ') + '<br/>' | |
53 | 56 | end |
54 | 57 | content_tag('table', |
55 | 58 | content_tag('tr', |
56 | 59 | content_tag('td', content_tag('div', profile_image(profile, :thumb), :class => 'profile-info-picture')) + |
57 | - content_tag('td', content_tag('strong', profile.name) + '<br/>' + | |
58 | - link_to(url_for(profile.url), profile.url) + '<br/>' + data + | |
59 | - link_to(_('Products/Services'), :controller => 'catalog', :profile => profile.identifier) | |
60 | + content_tag('td', content_tag('strong', link_to(profile.name, url_for(profile.url))) + '<br/>' + data | |
60 | 61 | ) |
61 | 62 | ), |
62 | 63 | :class => 'profile-info' | ... | ... |
test/unit/search_helper.rb
... | ... | @@ -4,6 +4,10 @@ class SearchHelperTest < Test::Unit::TestCase |
4 | 4 | |
5 | 5 | include SearchHelper |
6 | 6 | |
7 | + def _(any) | |
8 | + any | |
9 | + end | |
10 | + | |
7 | 11 | def setup |
8 | 12 | @profile = mock |
9 | 13 | end |
... | ... | @@ -13,17 +17,45 @@ class SearchHelperTest < Test::Unit::TestCase |
13 | 17 | include ActionView::Helpers::FormTagHelper |
14 | 18 | include ActionView::Helpers::TagHelper |
15 | 19 | should 'display profile info' do |
16 | - profile.expects(:name).returns('Name of Profile') | |
20 | + profile.stubs(:name).returns('Name of Profile') | |
21 | + profile.stubs(:address).returns('Address of Profile') | |
22 | + profile.stubs(:contact_email).returns('Email of Profile') | |
23 | + profile.stubs(:contact_phone).returns('Phone of Profile') | |
24 | + profile.stubs(:url).returns('') | |
25 | + profile.stubs(:products).returns([Product.new(:name => 'product test')]) | |
26 | + profile.stubs(:identifier).returns('name-of-profile') | |
27 | + | |
28 | + self.stubs(:profile_image).returns('profileimage.png') | |
29 | + self.stubs(:url_for).returns('merda') | |
30 | + self.stubs(:link_to).returns('link to profile') | |
31 | + | |
32 | + result = self.display_profile_info(profile) | |
33 | + assert_match /profileimage.png/, result | |
34 | + assert_match /link to profile/, result | |
35 | + assert_match /Email of Profile/, result | |
36 | + assert_match /Phone of Profile/, result | |
37 | + assert_match /Address of Profile/, result | |
38 | + end | |
39 | + | |
40 | + should 'not display field if nil in profile info' do | |
41 | + profile.stubs(:name).returns('Name of Profile') | |
42 | + profile.stubs(:address).returns('nil') | |
43 | + profile.stubs(:contact_email).returns('nil') | |
44 | + profile.stubs(:contact_phone).returns('nil') | |
17 | 45 | profile.stubs(:url).returns('') |
46 | + profile.stubs(:products).returns([Product.new(:name => 'product test')]) | |
47 | + profile.stubs(:identifier).returns('name-of-profile') | |
18 | 48 | |
19 | - self.expects(:profile_image).returns('profileimage.png') | |
20 | - self.expects(:url_for).returns('merda') | |
21 | - self.expects(:link_to).returns('link to profile') | |
49 | + self.stubs(:profile_image).returns('profileimage.png') | |
50 | + self.stubs(:url_for).returns('merda') | |
51 | + self.stubs(:link_to).returns('link to profile') | |
22 | 52 | |
23 | 53 | result = self.display_profile_info(profile) |
24 | 54 | assert_match /profileimage.png/, result |
25 | 55 | assert_match /link to profile/, result |
26 | - assert_match /<strong>Name of Profile<\/strong>/, result | |
56 | + assert_no_match /Email of Profile/, result | |
57 | + assert_no_match /Phone of Profile/, result | |
58 | + assert_no_match /Address of Profile/, result | |
27 | 59 | end |
28 | 60 | |
29 | 61 | end | ... | ... |