diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2011-11-09 06:23:53 -0800 |
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2011-11-09 06:23:53 -0800 |
| commit | a0a1b9e5075134d2730b519c6a2c1a29961e23e1 (patch) | |
| tree | 8f1f42116c6e5a580ca1d465b3ae0e3350f9decd | |
| parent | 7066444fdabf8f1f151bb590f6513e34ce12a214 (diff) | |
| parent | 4dbed7ca88c2fe8f127deb752f82a5ee9ab4cade (diff) | |
| download | gitlab-ce-a0a1b9e5075134d2730b519c6a2c1a29961e23e1.tar.gz | |
Merge pull request #79 from ariejan/fix_https_gravatar
Use secure.gravatar.com when running over SSL
| -rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
| -rw-r--r-- | spec/helpers/application_helper_spec.rb | 35 |
2 files changed, 38 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 70047c41014..a49d3dea217 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,7 +1,9 @@ require 'digest/md5' module ApplicationHelper + def gravatar_icon(user_email) - "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(user_email)}?s=40&d=identicon" + gravatar_host = request.ssl? ? "https://secure.gravatar.com" : "http://www.gravatar.com" + "#{gravatar_host}/avatar/#{Digest::MD5.hexdigest(user_email)}?s=40&d=identicon" end def fixed_mode? diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb new file mode 100644 index 00000000000..3e174ca47ab --- /dev/null +++ b/spec/helpers/application_helper_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe ApplicationHelper do + context ".gravatar_icon" do + context "over http" do + it "returns the correct URL to www.gravatar.com" do + expected = "http://www.gravatar.com/avatar/f7daa65b2aa96290bb47c4d68d11fe6a?s=40&d=identicon" + + # Pretend we're running over HTTP + helper.stub(:request) do + request = double('request') + request.stub(:ssl?) { false } + request + end + + helper.gravatar_icon("admin@local.host").should == expected + end + end + + context "over https" do + it "returns the correct URL to secure.gravatar.com" do + expected = "https://secure.gravatar.com/avatar/f7daa65b2aa96290bb47c4d68d11fe6a?s=40&d=identicon" + + # Pretend we're running over HTTPS + helper.stub(:request) do + request = double('request') + request.stub(:ssl?) { true } + request + end + + helper.gravatar_icon("admin@local.host").should == expected + end + end + end +end |
