Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/gitlab/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Client < API

# Please keep in alphabetical order
include AccessRequests
include Avatar
include AwardEmojis
include Boards
include Branches
Expand Down
21 changes: 21 additions & 0 deletions lib/gitlab/client/avatar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

class Gitlab::Client
# Defines methods related to avatar.
# @see https://docs.gitlab.com/ce/api/avatar.html
module Avatar
# Get a single avatar URL for a user with the given email address.
#
# @example
# Gitlab.avatar(email: '[email protected]')
# Gitlab.avatar(email: '[email protected]', size: 32)
#
# @param [Hash] options A customizable set of options.
# @option options [String] :email(required) Public email address of the user.
# @option options [Integer] :size(optional) Single pixel dimension (since images are squares). Only used for avatar lookups at Gravatar or at the configured Libravatar server.
# @return <Gitlab::ObjectifiedHash>
def avatar(options = {})
get('/avatar', query: options)
end
end
end
3 changes: 3 additions & 0 deletions spec/fixtures/avatar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=64&d=identicon"
}
17 changes: 17 additions & 0 deletions spec/gitlab/client/avatar_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::Client do
describe '.avatar' do
before do
stub_get('/avatar', 'avatar').with(query: { email: '[email protected]', size: 32 })
@avatar = Gitlab.avatar(email: '[email protected]', size: 32)
end

it 'gets the correct resource' do
expect(a_get('/avatar')
.with(query: { email: '[email protected]', size: 32 })).to have_been_made
end
end
end