Commit c9c759823fc6663e966f44028b7cf368515866a7
Committed by
Daniela Feitosa
1 parent
265fa719
Exists in
staging
and in
42 other branches
Fixed links to product and services on enterprises map
(ActionItem1883)
Showing
3 changed files
with
21 additions
and
23 deletions
Show diff stats
app/helpers/search_helper.rb
| ... | ... | @@ -65,7 +65,7 @@ module SearchHelper |
| 65 | 65 | data << content_tag('strong', _('Address: ')) + profile.address + '<br/>' |
| 66 | 66 | end |
| 67 | 67 | unless profile.products.empty? |
| 68 | - 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/>' | |
| 68 | + 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(', ') + '<br/>' | |
| 69 | 69 | end |
| 70 | 70 | if profile.respond_to?(:distance) and !profile.distance.nil? |
| 71 | 71 | data << content_tag('strong', _('Distance: ')) + "%.2f%" % profile.distance + '<br/>' | ... | ... |
test/test_helper.rb
test/unit/search_helper_test.rb
| ... | ... | @@ -10,25 +10,20 @@ class SearchHelperTest < Test::Unit::TestCase |
| 10 | 10 | |
| 11 | 11 | def setup |
| 12 | 12 | @profile = mock |
| 13 | + self.stubs(:profile_image).returns('profileimage.png') | |
| 14 | + self.stubs(:url_for).returns('link to profile') | |
| 15 | + profile.stubs(:name).returns('Name of Profile') | |
| 16 | + profile.stubs(:url).returns('') | |
| 17 | + profile.stubs(:products).returns([Product.new(:name => 'product test')]) | |
| 18 | + profile.stubs(:identifier).returns('name-of-profile') | |
| 19 | + profile.stubs(:region).returns(Region.new(:name => 'Brazil')) | |
| 13 | 20 | end |
| 14 | 21 | attr_reader :profile |
| 15 | 22 | |
| 16 | - include ActionView::Helpers::FormOptionsHelper | |
| 17 | - include ActionView::Helpers::FormTagHelper | |
| 18 | - include ActionView::Helpers::TagHelper | |
| 19 | 23 | should 'display profile info' do |
| 20 | - profile.stubs(:name).returns('Name of Profile') | |
| 21 | 24 | profile.stubs(:address).returns('Address of Profile') |
| 22 | 25 | profile.stubs(:contact_email).returns('Email of Profile') |
| 23 | 26 | 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 | - profile.stubs(:region).returns(Region.new(:name => 'Brazil')) | |
| 28 | - | |
| 29 | - self.stubs(:profile_image).returns('profileimage.png') | |
| 30 | - self.stubs(:url_for).returns('merda') | |
| 31 | - self.stubs(:link_to).returns('link to profile') | |
| 32 | 27 | |
| 33 | 28 | result = self.display_profile_info(profile) |
| 34 | 29 | assert_match /profileimage.png/, result |
| ... | ... | @@ -39,18 +34,9 @@ class SearchHelperTest < Test::Unit::TestCase |
| 39 | 34 | end |
| 40 | 35 | |
| 41 | 36 | should 'not display field if nil in profile info' do |
| 42 | - profile.stubs(:name).returns('Name of Profile') | |
| 43 | 37 | profile.stubs(:address).returns('nil') |
| 44 | 38 | profile.stubs(:contact_email).returns('nil') |
| 45 | 39 | profile.stubs(:contact_phone).returns('nil') |
| 46 | - profile.stubs(:url).returns('') | |
| 47 | - profile.stubs(:products).returns([Product.new(:name => 'product test')]) | |
| 48 | - profile.stubs(:identifier).returns('name-of-profile') | |
| 49 | - profile.stubs(:region).returns(Region.new(:name => 'Brazil')) | |
| 50 | - | |
| 51 | - self.stubs(:profile_image).returns('profileimage.png') | |
| 52 | - self.stubs(:url_for).returns('merda') | |
| 53 | - self.stubs(:link_to).returns('link to profile') | |
| 54 | 40 | |
| 55 | 41 | result = self.display_profile_info(profile) |
| 56 | 42 | assert_match /profileimage.png/, result |
| ... | ... | @@ -60,4 +46,16 @@ class SearchHelperTest < Test::Unit::TestCase |
| 60 | 46 | assert_no_match /Address of Profile/, result |
| 61 | 47 | end |
| 62 | 48 | |
| 49 | + should 'link to products and services of an profile' do | |
| 50 | + enterprise = fast_create(Enterprise) | |
| 51 | + product1 = fast_create(Product, :enterprise_id => enterprise.id) | |
| 52 | + product2 = fast_create(Product, :enterprise_id => enterprise.id) | |
| 53 | + result = display_profile_info(enterprise) | |
| 54 | + assert_tag_in_string result, :tag => 'a', :attributes => {:href => /:id=>#{product1.id}/}, :content => product1.name | |
| 55 | + assert_tag_in_string result, :tag => 'a', :attributes => {:href => /:id=>#{product2.id}/}, :content => product2.name | |
| 56 | + end | |
| 57 | + | |
| 58 | + protected | |
| 59 | + include NoosferoTestHelper | |
| 60 | + | |
| 63 | 61 | end | ... | ... |