Commit 47b1c1809b43a27c448cf87a9bbc5631426802ab

Authored by Daniela Feitosa
1 parent c76b4bb6

Fixing broken tests with gravatar

(ActionItem2125)
app/helpers/application_helper.rb
... ... @@ -588,7 +588,7 @@ module ApplicationHelper
588 588 def gravatar_url_for(email, options = {})
589 589 # Ta dando erro de roteamento
590 590 default = theme_option['gravatar'] || NOOSFERO_CONF['gravatar'] || nil
591   - url_for( { :gravatar_id => Digest::MD5.hexdigest(email),
  591 + url_for( { :gravatar_id => Digest::MD5.hexdigest(email.to_s),
592 592 :host => 'www.gravatar.com',
593 593 :protocol => 'http://',
594 594 :only_path => false,
... ... @@ -600,7 +600,7 @@ module ApplicationHelper
600 600 def str_gravatar_url_for(email, options = {})
601 601 default = theme_option['gravatar'] || NOOSFERO_CONF['gravatar'] || nil
602 602 url = 'http://www.gravatar.com/avatar.php?gravatar_id=' +
603   - Digest::MD5.hexdigest(email)
  603 + Digest::MD5.hexdigest(email.to_s)
604 604 {
605 605 :only_path => false,
606 606 :d => default
... ... @@ -611,7 +611,7 @@ module ApplicationHelper
611 611 end
612 612  
613 613 def gravatar_profile_url(email)
614   - 'http://www.gravatar.com/'+ Digest::MD5.hexdigest(email)
  614 + 'http://www.gravatar.com/'+ Digest::MD5.hexdigest(email.to_s)
615 615 end
616 616  
617 617 attr_reader :environment
... ...
test/unit/application_helper_test.rb
... ... @@ -468,6 +468,9 @@ class ApplicationHelperTest < Test::Unit::TestCase
468 468 end
469 469  
470 470 should 'generate a gravatar image url' do
  471 + stubs(:environment).returns(Environment.default)
  472 + @controller = ApplicationController.new
  473 +
471 474 with_constants :NOOSFERO_CONF => {'gravatar' => 'crazyvatar'} do
472 475 url = str_gravatar_url_for( 'rms@gnu.org', :size => 50 )
473 476 assert_match(/^http:\/\/www\.gravatar\.com\/avatar\.php\?/, url)
... ...