From 6c2e04aadc3d6c21971e0239ff892bf0dbc7ca36 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Thu, 4 Dec 2014 18:22:52 -0200 Subject: [PATCH] gravatar: don't hardcode protocol --- features/gravatar_support.feature | 4 ++-- lib/noosfero/gravatar.rb | 4 ++-- public/javascripts/application.js | 2 +- test/unit/gravatar_test.rb | 6 +++--- test/unit/user_test.rb | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/features/gravatar_support.feature b/features/gravatar_support.feature index f16c158..d012cd0 100644 --- a/features/gravatar_support.feature +++ b/features/gravatar_support.feature @@ -20,11 +20,11 @@ Feature: Gravatar Support Scenario: The Aurium's gravatar picture must link to his gravatar profile # because Aurium has his picture registered at garvatar.com. When I go to article "My Article" - Then I should see "Aurium" linking to "http://www.gravatar.com/24a625896a07aa37fdb2352e302e96de" + Then I should see "Aurium" linking to "//www.gravatar.com/24a625896a07aa37fdb2352e302e96de" @selenium Scenario: The NoOne's gravatar picture must link to Gravatar homepage # because NoOne has no picture registered. When I go to article "My Article" - Then I should see "NoOne" linking to "http://www.gravatar.com" + Then I should see "NoOne" linking to "//www.gravatar.com" diff --git a/lib/noosfero/gravatar.rb b/lib/noosfero/gravatar.rb index 5f4d743..2204650 100644 --- a/lib/noosfero/gravatar.rb +++ b/lib/noosfero/gravatar.rb @@ -1,11 +1,11 @@ module Noosfero::Gravatar def gravatar_profile_image_url(email, options = {}) - "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.to_s)}?" + { + "//www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.to_s)}?" + { :only_path => false, }.merge(options).map{|k,v| '%s=%s' % [ k,v ] }.join('&') end def gravatar_profile_url(email) - 'http://www.gravatar.com/'+ Digest::MD5.hexdigest(email.to_s) + '//www.gravatar.com/'+ Digest::MD5.hexdigest(email.to_s) end end diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 3aa0171..240b612 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -799,7 +799,7 @@ function original_image_dimensions(src) { function gravatarCommentFailback(img) { var link = img.parentNode; - link.href = "http://www.gravatar.com"; + link.href = "//www.gravatar.com"; img.src = img.getAttribute("data-gravatar"); } diff --git a/test/unit/gravatar_test.rb b/test/unit/gravatar_test.rb index 6954d5a..1e6bf3c 100644 --- a/test/unit/gravatar_test.rb +++ b/test/unit/gravatar_test.rb @@ -9,18 +9,18 @@ class GravatarTest < ActiveSupport::TestCase should 'generate a gravatar image url' do url = @object.gravatar_profile_image_url( 'rms@gnu.org', :size => 50, :d => 'crazyvatar' ) - assert_match(/^http:\/\/www\.gravatar\.com\/avatar\/ed5214d4b49154ba0dc397a28ee90eb7?/, url) + assert_match(/^\/\/www\.gravatar\.com\/avatar\/ed5214d4b49154ba0dc397a28ee90eb7?/, url) assert_match(/(\?|&)d=crazyvatar(&|$)/, url) assert_match(/(\?|&)size=50(&|$)/, url) url = @object.gravatar_profile_image_url( 'rms@gnu.org', :size => 50, :d => 'nicevatar' ) - assert_match(/^http:\/\/www\.gravatar\.com\/avatar\/ed5214d4b49154ba0dc397a28ee90eb7?/, url) + assert_match(/^\/\/www\.gravatar\.com\/avatar\/ed5214d4b49154ba0dc397a28ee90eb7?/, url) assert_match(/(\?|&)d=nicevatar(&|$)/, url) assert_match(/(\?|&)size=50(&|$)/, url) end should 'generate a gravatar profile url' do url = @object.gravatar_profile_url( 'rms@gnu.org' ) - assert_equal('http://www.gravatar.com/ed5214d4b49154ba0dc397a28ee90eb7', url) + assert_equal('//www.gravatar.com/ed5214d4b49154ba0dc397a28ee90eb7', url) end end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 8ceb5ec..13c56bd 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -349,7 +349,7 @@ class UserTest < ActiveSupport::TestCase assert_equal expected_hash['since_year'], person.user.data_hash['since_year'] # Avatar stuff - assert_match 'http://www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e', person.user.data_hash['avatar'] + assert_match '/www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e', person.user.data_hash['avatar'] assert_match 'only_path=false', person.user.data_hash['avatar'] assert_match 'd=', person.user.data_hash['avatar'] assert_match 'size=20', person.user.data_hash['avatar'] -- libgit2 0.21.2