summaryrefslogtreecommitdiff
path: root/spec/helpers/application_helper_spec.rb
blob: 3e174ca47ab79c5af965361c581c15d24a7c3534 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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