diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index f4a7659..377c9b4 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -65,7 +65,7 @@ module SearchHelper
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(', ') + '
'
+ data << content_tag('strong', _('Products/Services: ')) + profile.products.map{|i| link_to(i.name, :controller => 'catalog', :profile => profile.identifier, :action => 'show', :id => i.id)}.join(', ') + '
'
end
if profile.respond_to?(:distance) and !profile.distance.nil?
data << content_tag('strong', _('Distance: ')) + "%.2f%" % profile.distance + '
'
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 0a81ad6..1e2eea4 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -189,7 +189,7 @@ end
module NoosferoTestHelper
def link_to(content, url, options = {})
- "#{content}"
+ "#{content}"
end
def content_tag(tag, content, options = {})
diff --git a/test/unit/search_helper_test.rb b/test/unit/search_helper_test.rb
index b197181..8840a83 100644
--- a/test/unit/search_helper_test.rb
+++ b/test/unit/search_helper_test.rb
@@ -10,25 +10,20 @@ class SearchHelperTest < Test::Unit::TestCase
def setup
@profile = mock
+ self.stubs(:profile_image).returns('profileimage.png')
+ self.stubs(:url_for).returns('link to profile')
+ profile.stubs(:name).returns('Name of Profile')
+ profile.stubs(:url).returns('')
+ profile.stubs(:products).returns([Product.new(:name => 'product test')])
+ profile.stubs(:identifier).returns('name-of-profile')
+ profile.stubs(:region).returns(Region.new(:name => 'Brazil'))
end
attr_reader :profile
- include ActionView::Helpers::FormOptionsHelper
- include ActionView::Helpers::FormTagHelper
- include ActionView::Helpers::TagHelper
should 'display profile info' do
- 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')
- profile.stubs(:region).returns(Region.new(:name => 'Brazil'))
-
- 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
@@ -39,18 +34,9 @@ class SearchHelperTest < Test::Unit::TestCase
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')
- profile.stubs(:region).returns(Region.new(:name => 'Brazil'))
-
- 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
@@ -60,4 +46,16 @@ class SearchHelperTest < Test::Unit::TestCase
assert_no_match /Address of Profile/, result
end
+ should 'link to products and services of an profile' do
+ enterprise = fast_create(Enterprise)
+ product1 = fast_create(Product, :enterprise_id => enterprise.id)
+ product2 = fast_create(Product, :enterprise_id => enterprise.id)
+ result = display_profile_info(enterprise)
+ assert_tag_in_string result, :tag => 'a', :attributes => {:href => /:id=>#{product1.id}/}, :content => product1.name
+ assert_tag_in_string result, :tag => 'a', :attributes => {:href => /:id=>#{product2.id}/}, :content => product2.name
+ end
+
+ protected
+ include NoosferoTestHelper
+
end
--
libgit2 0.21.2