Commit 47b1c1809b43a27c448cf87a9bbc5631426802ab
1 parent
c76b4bb6
Exists in
master
and in
29 other branches
Fixing broken tests with gravatar
(ActionItem2125)
Showing
2 changed files
with
6 additions
and
3 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -588,7 +588,7 @@ module ApplicationHelper | @@ -588,7 +588,7 @@ module ApplicationHelper | ||
588 | def gravatar_url_for(email, options = {}) | 588 | def gravatar_url_for(email, options = {}) |
589 | # Ta dando erro de roteamento | 589 | # Ta dando erro de roteamento |
590 | default = theme_option['gravatar'] || NOOSFERO_CONF['gravatar'] || nil | 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 | :host => 'www.gravatar.com', | 592 | :host => 'www.gravatar.com', |
593 | :protocol => 'http://', | 593 | :protocol => 'http://', |
594 | :only_path => false, | 594 | :only_path => false, |
@@ -600,7 +600,7 @@ module ApplicationHelper | @@ -600,7 +600,7 @@ module ApplicationHelper | ||
600 | def str_gravatar_url_for(email, options = {}) | 600 | def str_gravatar_url_for(email, options = {}) |
601 | default = theme_option['gravatar'] || NOOSFERO_CONF['gravatar'] || nil | 601 | default = theme_option['gravatar'] || NOOSFERO_CONF['gravatar'] || nil |
602 | url = 'http://www.gravatar.com/avatar.php?gravatar_id=' + | 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 | :only_path => false, | 605 | :only_path => false, |
606 | :d => default | 606 | :d => default |
@@ -611,7 +611,7 @@ module ApplicationHelper | @@ -611,7 +611,7 @@ module ApplicationHelper | ||
611 | end | 611 | end |
612 | 612 | ||
613 | def gravatar_profile_url(email) | 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 | end | 615 | end |
616 | 616 | ||
617 | attr_reader :environment | 617 | attr_reader :environment |
test/unit/application_helper_test.rb
@@ -468,6 +468,9 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -468,6 +468,9 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
468 | end | 468 | end |
469 | 469 | ||
470 | should 'generate a gravatar image url' do | 470 | should 'generate a gravatar image url' do |
471 | + stubs(:environment).returns(Environment.default) | ||
472 | + @controller = ApplicationController.new | ||
473 | + | ||
471 | with_constants :NOOSFERO_CONF => {'gravatar' => 'crazyvatar'} do | 474 | with_constants :NOOSFERO_CONF => {'gravatar' => 'crazyvatar'} do |
472 | url = str_gravatar_url_for( 'rms@gnu.org', :size => 50 ) | 475 | url = str_gravatar_url_for( 'rms@gnu.org', :size => 50 ) |
473 | assert_match(/^http:\/\/www\.gravatar\.com\/avatar\.php\?/, url) | 476 | assert_match(/^http:\/\/www\.gravatar\.com\/avatar\.php\?/, url) |