Commit c9c759823fc6663e966f44028b7cf368515866a7
Committed by
Daniela Feitosa
1 parent
265fa719
Exists in
master
and in
29 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,7 +65,7 @@ module SearchHelper | ||
65 | data << content_tag('strong', _('Address: ')) + profile.address + '<br/>' | 65 | data << content_tag('strong', _('Address: ')) + profile.address + '<br/>' |
66 | end | 66 | end |
67 | unless profile.products.empty? | 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 | end | 69 | end |
70 | if profile.respond_to?(:distance) and !profile.distance.nil? | 70 | if profile.respond_to?(:distance) and !profile.distance.nil? |
71 | data << content_tag('strong', _('Distance: ')) + "%.2f%" % profile.distance + '<br/>' | 71 | data << content_tag('strong', _('Distance: ')) + "%.2f%" % profile.distance + '<br/>' |
test/test_helper.rb
@@ -189,7 +189,7 @@ end | @@ -189,7 +189,7 @@ end | ||
189 | 189 | ||
190 | module NoosferoTestHelper | 190 | module NoosferoTestHelper |
191 | def link_to(content, url, options = {}) | 191 | def link_to(content, url, options = {}) |
192 | - "<a href='#{url.to_s}'>#{content}</a>" | 192 | + "<a href='#{url.inspect}'>#{content}</a>" |
193 | end | 193 | end |
194 | 194 | ||
195 | def content_tag(tag, content, options = {}) | 195 | def content_tag(tag, content, options = {}) |
test/unit/search_helper_test.rb
@@ -10,25 +10,20 @@ class SearchHelperTest < Test::Unit::TestCase | @@ -10,25 +10,20 @@ class SearchHelperTest < Test::Unit::TestCase | ||
10 | 10 | ||
11 | def setup | 11 | def setup |
12 | @profile = mock | 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 | end | 20 | end |
14 | attr_reader :profile | 21 | attr_reader :profile |
15 | 22 | ||
16 | - include ActionView::Helpers::FormOptionsHelper | ||
17 | - include ActionView::Helpers::FormTagHelper | ||
18 | - include ActionView::Helpers::TagHelper | ||
19 | should 'display profile info' do | 23 | should 'display profile info' do |
20 | - profile.stubs(:name).returns('Name of Profile') | ||
21 | profile.stubs(:address).returns('Address of Profile') | 24 | profile.stubs(:address).returns('Address of Profile') |
22 | profile.stubs(:contact_email).returns('Email of Profile') | 25 | profile.stubs(:contact_email).returns('Email of Profile') |
23 | profile.stubs(:contact_phone).returns('Phone of Profile') | 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 | result = self.display_profile_info(profile) | 28 | result = self.display_profile_info(profile) |
34 | assert_match /profileimage.png/, result | 29 | assert_match /profileimage.png/, result |
@@ -39,18 +34,9 @@ class SearchHelperTest < Test::Unit::TestCase | @@ -39,18 +34,9 @@ class SearchHelperTest < Test::Unit::TestCase | ||
39 | end | 34 | end |
40 | 35 | ||
41 | should 'not display field if nil in profile info' do | 36 | should 'not display field if nil in profile info' do |
42 | - profile.stubs(:name).returns('Name of Profile') | ||
43 | profile.stubs(:address).returns('nil') | 37 | profile.stubs(:address).returns('nil') |
44 | profile.stubs(:contact_email).returns('nil') | 38 | profile.stubs(:contact_email).returns('nil') |
45 | profile.stubs(:contact_phone).returns('nil') | 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 | result = self.display_profile_info(profile) | 41 | result = self.display_profile_info(profile) |
56 | assert_match /profileimage.png/, result | 42 | assert_match /profileimage.png/, result |
@@ -60,4 +46,16 @@ class SearchHelperTest < Test::Unit::TestCase | @@ -60,4 +46,16 @@ class SearchHelperTest < Test::Unit::TestCase | ||
60 | assert_no_match /Address of Profile/, result | 46 | assert_no_match /Address of Profile/, result |
61 | end | 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 | end | 61 | end |