Commit 9dae005ffc0a96c3382d11ebe6ef6406809a582e
Exists in
master
and in
29 other branches
Merge commit 'refs/merge-requests/58' of git://gitorious.org/noosfero/noosfero
Showing
2 changed files
with
12 additions
and
2 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -587,17 +587,18 @@ module ApplicationHelper | @@ -587,17 +587,18 @@ module ApplicationHelper | ||
587 | 587 | ||
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 | url_for( { :gravatar_id => Digest::MD5.hexdigest(email), | 591 | url_for( { :gravatar_id => Digest::MD5.hexdigest(email), |
591 | :host => 'www.gravatar.com', | 592 | :host => 'www.gravatar.com', |
592 | :protocol => 'http://', | 593 | :protocol => 'http://', |
593 | :only_path => false, | 594 | :only_path => false, |
594 | :controller => 'avatar.php', | 595 | :controller => 'avatar.php', |
595 | - :d => NOOSFERO_CONF['gravatar'] ? NOOSFERO_CONF['gravatar'] : nil | 596 | + :d => default |
596 | }.merge(options) ) | 597 | }.merge(options) ) |
597 | end | 598 | end |
598 | 599 | ||
599 | def str_gravatar_url_for(email, options = {}) | 600 | def str_gravatar_url_for(email, options = {}) |
600 | - default = NOOSFERO_CONF['gravatar'] ? NOOSFERO_CONF['gravatar'] : nil | 601 | + default = theme_option['gravatar'] || NOOSFERO_CONF['gravatar'] || nil |
601 | url = 'http://www.gravatar.com/avatar.php?gravatar_id=' + | 602 | url = 'http://www.gravatar.com/avatar.php?gravatar_id=' + |
602 | Digest::MD5.hexdigest(email) | 603 | Digest::MD5.hexdigest(email) |
603 | { | 604 | { |
test/unit/application_helper_test.rb
@@ -468,6 +468,7 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -468,6 +468,7 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
468 | end | 468 | end |
469 | 469 | ||
470 | should 'generate a gravatar url' do | 470 | should 'generate a gravatar url' do |
471 | + stubs(:theme_option).returns({}) | ||
471 | with_constants :NOOSFERO_CONF => {'gravatar' => 'crazyvatar'} do | 472 | with_constants :NOOSFERO_CONF => {'gravatar' => 'crazyvatar'} do |
472 | url = str_gravatar_url_for( 'rms@gnu.org', :size => 50 ) | 473 | url = str_gravatar_url_for( 'rms@gnu.org', :size => 50 ) |
473 | assert_match(/^http:\/\/www\.gravatar\.com\/avatar\.php\?/, url) | 474 | assert_match(/^http:\/\/www\.gravatar\.com\/avatar\.php\?/, url) |
@@ -475,6 +476,14 @@ class ApplicationHelperTest < Test::Unit::TestCase | @@ -475,6 +476,14 @@ class ApplicationHelperTest < Test::Unit::TestCase | ||
475 | assert_match(/(\?|&)d=crazyvatar(&|$)/, url) | 476 | assert_match(/(\?|&)d=crazyvatar(&|$)/, url) |
476 | assert_match(/(\?|&)size=50(&|$)/, url) | 477 | assert_match(/(\?|&)size=50(&|$)/, url) |
477 | end | 478 | end |
479 | + stubs(:theme_option).returns('gravatar' => 'nicevatar') | ||
480 | + with_constants :NOOSFERO_CONF => {'gravatar' => 'crazyvatar'} do | ||
481 | + url = str_gravatar_url_for( 'rms@gnu.org', :size => 50 ) | ||
482 | + assert_match(/^http:\/\/www\.gravatar\.com\/avatar\.php\?/, url) | ||
483 | + assert_match(/(\?|&)gravatar_id=ed5214d4b49154ba0dc397a28ee90eb7(&|$)/, url) | ||
484 | + assert_match(/(\?|&)d=nicevatar(&|$)/, url) | ||
485 | + assert_match(/(\?|&)size=50(&|$)/, url) | ||
486 | + end | ||
478 | end | 487 | end |
479 | 488 | ||
480 | should 'use theme passed via param when in development mode' do | 489 | should 'use theme passed via param when in development mode' do |