From c001a4d8303ae1d8f803660a2bb490c3174dd17d Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 18 Jun 2015 15:28:02 +0200 Subject: [PATCH] Return channels for a user record --- lib/travis/api/v2/http/user.rb | 5 +++++ spec/unit/api/v2/http/user_spec.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/travis/api/v2/http/user.rb b/lib/travis/api/v2/http/user.rb index 0d06a901..51f17a99 100644 --- a/lib/travis/api/v2/http/user.rb +++ b/lib/travis/api/v2/http/user.rb @@ -32,8 +32,13 @@ module Travis 'synced_at' => format_date(user.synced_at), 'correct_scopes' => user.correct_scopes?, 'created_at' => format_date(user.created_at), + 'channels' => channels } end + + def channels + ["user-#{user.id}"] + user.repository_ids.map { |id| "repo-#{id}" } + end end end end diff --git a/spec/unit/api/v2/http/user_spec.rb b/spec/unit/api/v2/http/user_spec.rb index e586a34c..71232484 100644 --- a/spec/unit/api/v2/http/user_spec.rb +++ b/spec/unit/api/v2/http/user_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe Travis::Api::V2::Http::User do include Travis::Testing::Stubs, Support::Formats + let(:user) { stub_user(repository_ids: [1, 4, 8]) } let(:data) { Travis::Api::V2::Http::User.new(user).data } it 'user' do @@ -17,6 +18,7 @@ describe Travis::Api::V2::Http::User do 'synced_at' => json_format_time(Time.now.utc - 1.hour), 'correct_scopes' => true, 'created_at' => json_format_time(Time.now.utc - 2.hours), + 'channels' => ["user-1", "repo-1", "repo-4", "repo-8"] } end end