diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 9d1ae17..a6caf3d 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -43,20 +43,21 @@ module SearchHelper
# FIXME add distance
data = ''
unless profile.contact_email.nil?
- data << content_tag('strong', _('E-Mail:')) + profile.contact_email + '
'
+ data << content_tag('strong', _('E-Mail: ')) + profile.contact_email + '
'
end
unless profile.contact_phone.nil?
- data << content_tag('strong', _('Phone:')) + profile.contact_phone + '
'
+ data << content_tag('strong', _('Phone(s): ')) + profile.contact_phone + '
'
end
unless profile.address.nil?
- data << content_tag('strong', _('Address:')) + profile.address + '
'
+ data << content_tag('strong', _('Address: ')) + profile.address + '
'
+ end
+ unless profile.products.empty?
+ data << content_tag('strong', _('Products/Services: ')) + profile.products.map{|i| link_to(i.name, :controller => 'catalog', :profile => profile.identifier, :action => 'show', :id => i)}.join(', ') + '
'
end
content_tag('table',
content_tag('tr',
content_tag('td', content_tag('div', profile_image(profile, :thumb), :class => 'profile-info-picture')) +
- content_tag('td', content_tag('strong', profile.name) + '
' +
- link_to(url_for(profile.url), profile.url) + '
' + data +
- link_to(_('Products/Services'), :controller => 'catalog', :profile => profile.identifier)
+ content_tag('td', content_tag('strong', link_to(profile.name, url_for(profile.url))) + '
' + data
)
),
:class => 'profile-info'
diff --git a/test/unit/search_helper.rb b/test/unit/search_helper.rb
index 0dfeabd..0e66f1d 100644
--- a/test/unit/search_helper.rb
+++ b/test/unit/search_helper.rb
@@ -4,6 +4,10 @@ class SearchHelperTest < Test::Unit::TestCase
include SearchHelper
+ def _(any)
+ any
+ end
+
def setup
@profile = mock
end
@@ -13,17 +17,45 @@ class SearchHelperTest < Test::Unit::TestCase
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::TagHelper
should 'display profile info' do
- profile.expects(:name).returns('Name of Profile')
+ profile.stubs(:name).returns('Name of Profile')
+ profile.stubs(:address).returns('Address of Profile')
+ profile.stubs(:contact_email).returns('Email of Profile')
+ profile.stubs(:contact_phone).returns('Phone of Profile')
+ profile.stubs(:url).returns('')
+ profile.stubs(:products).returns([Product.new(:name => 'product test')])
+ profile.stubs(:identifier).returns('name-of-profile')
+
+ self.stubs(:profile_image).returns('profileimage.png')
+ self.stubs(:url_for).returns('merda')
+ self.stubs(:link_to).returns('link to profile')
+
+ result = self.display_profile_info(profile)
+ assert_match /profileimage.png/, result
+ assert_match /link to profile/, result
+ assert_match /Email of Profile/, result
+ assert_match /Phone of Profile/, result
+ assert_match /Address of Profile/, result
+ end
+
+ should 'not display field if nil in profile info' do
+ profile.stubs(:name).returns('Name of Profile')
+ profile.stubs(:address).returns('nil')
+ profile.stubs(:contact_email).returns('nil')
+ profile.stubs(:contact_phone).returns('nil')
profile.stubs(:url).returns('')
+ profile.stubs(:products).returns([Product.new(:name => 'product test')])
+ profile.stubs(:identifier).returns('name-of-profile')
- self.expects(:profile_image).returns('profileimage.png')
- self.expects(:url_for).returns('merda')
- self.expects(:link_to).returns('link to profile')
+ self.stubs(:profile_image).returns('profileimage.png')
+ self.stubs(:url_for).returns('merda')
+ self.stubs(:link_to).returns('link to profile')
result = self.display_profile_info(profile)
assert_match /profileimage.png/, result
assert_match /link to profile/, result
- assert_match /Name of Profile<\/strong>/, result
+ assert_no_match /Email of Profile/, result
+ assert_no_match /Phone of Profile/, result
+ assert_no_match /Address of Profile/, result
end
end
--
libgit2 0.21.2