summaryrefslogtreecommitdiff
path: root/spec/services/gravatar_service_spec.rb
blob: 9ce1df0f76f90dd761def498c0e3dc5b7dd40e71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require 'spec_helper'

describe GravatarService do
  describe '#execute' do
    let(:url) { 'http://example.com/avatar?hash=%{hash}&size=%{size}&email=%{email}&username=%{username}' }

    before do
      allow(Gitlab.config.gravatar).to receive(:plain_url).and_return(url)
    end

    it 'replaces the placeholders' do
      avatar_url = described_class.new.execute('user@example.com', 100, 2, username: 'user')

      expect(avatar_url).to include("hash=#{Digest::MD5.hexdigest('user@example.com')}")
      expect(avatar_url).to include("size=200")
      expect(avatar_url).to include("email=user%40example.com")
      expect(avatar_url).to include("username=user")
    end
  end
end