diff --git a/lib/travis/api/v2/http/accounts.rb b/lib/travis/api/v2/http/accounts.rb index a5429d7e..5b8be3ef 100644 --- a/lib/travis/api/v2/http/accounts.rb +++ b/lib/travis/api/v2/http/accounts.rb @@ -21,13 +21,17 @@ module Travis private def account_data(account) - { + data = { 'id' => account.id, 'name' => account.name, 'login' => account.login, 'type' => account.type.underscore, 'repos_count' => account.repos_count } + + data['avatar_url'] = account.avatar_url if account.respond_to?(:avatar_url) + + data end end end diff --git a/spec/unit/api/v2/http/accounts_spec.rb b/spec/unit/api/v2/http/accounts_spec.rb index a409c2bf..d444c2fa 100644 --- a/spec/unit/api/v2/http/accounts_spec.rb +++ b/spec/unit/api/v2/http/accounts_spec.rb @@ -4,15 +4,15 @@ describe Travis::Api::V2::Http::Accounts do include Travis::Testing::Stubs, Support::Formats let(:user) { { 'id' => 1, 'type' => 'User', 'login' => 'sven', 'name' => 'Sven', 'repos_count' => 2 } } - let(:org) { { 'id' => 1, 'type' => 'Organization', 'login' => 'travis', 'name' => 'Travis', 'repos_count' => 1 } } + let(:org) { { 'id' => 1, 'type' => 'Organization', 'login' => 'travis', 'name' => 'Travis', 'repos_count' => 1, 'avatar_url' => 'https://example.org/avatar.png' } } let(:accounts) { [Account.new(user), Account.new(org)] } let(:data) { Travis::Api::V2::Http::Accounts.new(accounts).data } it 'accounts' do data[:accounts].should == [ - { 'id' => 1, 'login' => 'sven', 'name' => 'Sven', 'type' => 'user', 'repos_count' => 2 }, - { 'id' => 1, 'login' => 'travis', 'name' => 'Travis', 'type' => 'organization', 'repos_count' => 1 } + { 'id' => 1, 'login' => 'sven', 'name' => 'Sven', 'type' => 'user', 'repos_count' => 2, 'avatar_url' => nil }, + { 'id' => 1, 'login' => 'travis', 'name' => 'Travis', 'type' => 'organization', 'repos_count' => 1, 'avatar_url' => 'https://example.org/avatar.png' } ] end end