Commit 6c2e04aadc3d6c21971e0239ff892bf0dbc7ca36
1 parent
6ee76529
Exists in
master
and in
29 other branches
gravatar: don't hardcode protocol
Showing
5 changed files
with
9 additions
and
9 deletions
Show diff stats
features/gravatar_support.feature
@@ -20,11 +20,11 @@ Feature: Gravatar Support | @@ -20,11 +20,11 @@ Feature: Gravatar Support | ||
20 | Scenario: The Aurium's gravatar picture must link to his gravatar profile | 20 | Scenario: The Aurium's gravatar picture must link to his gravatar profile |
21 | # because Aurium has his picture registered at garvatar.com. | 21 | # because Aurium has his picture registered at garvatar.com. |
22 | When I go to article "My Article" | 22 | When I go to article "My Article" |
23 | - Then I should see "Aurium" linking to "http://www.gravatar.com/24a625896a07aa37fdb2352e302e96de" | 23 | + Then I should see "Aurium" linking to "//www.gravatar.com/24a625896a07aa37fdb2352e302e96de" |
24 | 24 | ||
25 | @selenium | 25 | @selenium |
26 | Scenario: The NoOne's gravatar picture must link to Gravatar homepage | 26 | Scenario: The NoOne's gravatar picture must link to Gravatar homepage |
27 | # because NoOne <nobody@colivre.coop.br> has no picture registered. | 27 | # because NoOne <nobody@colivre.coop.br> has no picture registered. |
28 | When I go to article "My Article" | 28 | When I go to article "My Article" |
29 | - Then I should see "NoOne" linking to "http://www.gravatar.com" | 29 | + Then I should see "NoOne" linking to "//www.gravatar.com" |
30 | 30 |
lib/noosfero/gravatar.rb
1 | module Noosfero::Gravatar | 1 | module Noosfero::Gravatar |
2 | def gravatar_profile_image_url(email, options = {}) | 2 | def gravatar_profile_image_url(email, options = {}) |
3 | - "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.to_s)}?" + { | 3 | + "//www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.to_s)}?" + { |
4 | :only_path => false, | 4 | :only_path => false, |
5 | }.merge(options).map{|k,v| '%s=%s' % [ k,v ] }.join('&') | 5 | }.merge(options).map{|k,v| '%s=%s' % [ k,v ] }.join('&') |
6 | end | 6 | end |
7 | 7 | ||
8 | def gravatar_profile_url(email) | 8 | def gravatar_profile_url(email) |
9 | - 'http://www.gravatar.com/'+ Digest::MD5.hexdigest(email.to_s) | 9 | + '//www.gravatar.com/'+ Digest::MD5.hexdigest(email.to_s) |
10 | end | 10 | end |
11 | end | 11 | end |
public/javascripts/application.js
@@ -799,7 +799,7 @@ function original_image_dimensions(src) { | @@ -799,7 +799,7 @@ function original_image_dimensions(src) { | ||
799 | 799 | ||
800 | function gravatarCommentFailback(img) { | 800 | function gravatarCommentFailback(img) { |
801 | var link = img.parentNode; | 801 | var link = img.parentNode; |
802 | - link.href = "http://www.gravatar.com"; | 802 | + link.href = "//www.gravatar.com"; |
803 | img.src = img.getAttribute("data-gravatar"); | 803 | img.src = img.getAttribute("data-gravatar"); |
804 | } | 804 | } |
805 | 805 |
test/unit/gravatar_test.rb
@@ -9,18 +9,18 @@ class GravatarTest < ActiveSupport::TestCase | @@ -9,18 +9,18 @@ class GravatarTest < ActiveSupport::TestCase | ||
9 | 9 | ||
10 | should 'generate a gravatar image url' do | 10 | should 'generate a gravatar image url' do |
11 | url = @object.gravatar_profile_image_url( 'rms@gnu.org', :size => 50, :d => 'crazyvatar' ) | 11 | url = @object.gravatar_profile_image_url( 'rms@gnu.org', :size => 50, :d => 'crazyvatar' ) |
12 | - assert_match(/^http:\/\/www\.gravatar\.com\/avatar\/ed5214d4b49154ba0dc397a28ee90eb7?/, url) | 12 | + assert_match(/^\/\/www\.gravatar\.com\/avatar\/ed5214d4b49154ba0dc397a28ee90eb7?/, url) |
13 | assert_match(/(\?|&)d=crazyvatar(&|$)/, url) | 13 | assert_match(/(\?|&)d=crazyvatar(&|$)/, url) |
14 | assert_match(/(\?|&)size=50(&|$)/, url) | 14 | assert_match(/(\?|&)size=50(&|$)/, url) |
15 | 15 | ||
16 | url = @object.gravatar_profile_image_url( 'rms@gnu.org', :size => 50, :d => 'nicevatar' ) | 16 | url = @object.gravatar_profile_image_url( 'rms@gnu.org', :size => 50, :d => 'nicevatar' ) |
17 | - assert_match(/^http:\/\/www\.gravatar\.com\/avatar\/ed5214d4b49154ba0dc397a28ee90eb7?/, url) | 17 | + assert_match(/^\/\/www\.gravatar\.com\/avatar\/ed5214d4b49154ba0dc397a28ee90eb7?/, url) |
18 | assert_match(/(\?|&)d=nicevatar(&|$)/, url) | 18 | assert_match(/(\?|&)d=nicevatar(&|$)/, url) |
19 | assert_match(/(\?|&)size=50(&|$)/, url) | 19 | assert_match(/(\?|&)size=50(&|$)/, url) |
20 | end | 20 | end |
21 | 21 | ||
22 | should 'generate a gravatar profile url' do | 22 | should 'generate a gravatar profile url' do |
23 | url = @object.gravatar_profile_url( 'rms@gnu.org' ) | 23 | url = @object.gravatar_profile_url( 'rms@gnu.org' ) |
24 | - assert_equal('http://www.gravatar.com/ed5214d4b49154ba0dc397a28ee90eb7', url) | 24 | + assert_equal('//www.gravatar.com/ed5214d4b49154ba0dc397a28ee90eb7', url) |
25 | end | 25 | end |
26 | end | 26 | end |
test/unit/user_test.rb
@@ -349,7 +349,7 @@ class UserTest < ActiveSupport::TestCase | @@ -349,7 +349,7 @@ class UserTest < ActiveSupport::TestCase | ||
349 | assert_equal expected_hash['since_year'], person.user.data_hash['since_year'] | 349 | assert_equal expected_hash['since_year'], person.user.data_hash['since_year'] |
350 | 350 | ||
351 | # Avatar stuff | 351 | # Avatar stuff |
352 | - assert_match 'http://www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e', person.user.data_hash['avatar'] | 352 | + assert_match '/www.gravatar.com/avatar/a0517761d5125820c28d87860bc7c02e', person.user.data_hash['avatar'] |
353 | assert_match 'only_path=false', person.user.data_hash['avatar'] | 353 | assert_match 'only_path=false', person.user.data_hash['avatar'] |
354 | assert_match 'd=', person.user.data_hash['avatar'] | 354 | assert_match 'd=', person.user.data_hash['avatar'] |
355 | assert_match 'size=20', person.user.data_hash['avatar'] | 355 | assert_match 'size=20', person.user.data_hash['avatar'] |