Commit 58babac309e80534c299ba0ff1b6b3d61cbfbb94

Authored by JoenioCosta
1 parent 7a857453

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
app/helpers/search_helper.rb
@@ -43,20 +43,21 @@ module SearchHelper @@ -43,20 +43,21 @@ module SearchHelper
43 # FIXME add distance 43 # FIXME add distance
44 data = '' 44 data = ''
45 unless profile.contact_email.nil? 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 end 47 end
48 unless profile.contact_phone.nil? 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 end 50 end
51 unless profile.address.nil? 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 end 56 end
54 content_tag('table', 57 content_tag('table',
55 content_tag('tr', 58 content_tag('tr',
56 content_tag('td', content_tag('div', profile_image(profile, :thumb), :class => 'profile-info-picture')) + 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 :class => 'profile-info' 63 :class => 'profile-info'
test/unit/search_helper.rb
@@ -4,6 +4,10 @@ class SearchHelperTest &lt; Test::Unit::TestCase @@ -4,6 +4,10 @@ class SearchHelperTest &lt; Test::Unit::TestCase
4 4
5 include SearchHelper 5 include SearchHelper
6 6
  7 + def _(any)
  8 + any
  9 + end
  10 +
7 def setup 11 def setup
8 @profile = mock 12 @profile = mock
9 end 13 end
@@ -13,17 +17,45 @@ class SearchHelperTest &lt; Test::Unit::TestCase @@ -13,17 +17,45 @@ class SearchHelperTest &lt; Test::Unit::TestCase
13 include ActionView::Helpers::FormTagHelper 17 include ActionView::Helpers::FormTagHelper
14 include ActionView::Helpers::TagHelper 18 include ActionView::Helpers::TagHelper
15 should 'display profile info' do 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 profile.stubs(:url).returns('') 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 result = self.display_profile_info(profile) 53 result = self.display_profile_info(profile)
24 assert_match /profileimage.png/, result 54 assert_match /profileimage.png/, result
25 assert_match /link to profile/, result 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 end 59 end
28 60
29 end 61 end