Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Commit

Permalink
Added new team_information and in_house method to client with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KrauseFx committed Jun 11, 2015
1 parent 06b682d commit 11f9d66
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
13 changes: 13 additions & 0 deletions lib/spaceship/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ def team_id=(team_id)
@current_team_id = team_id
end

# @return (Hash) Fetches all information of the currently used team
def team_information
teams.find do |t|
t['teamId'] == team_id
end
end

# Is the current session from an Enterprise In House account?
def in_house?
return @in_house unless @in_house.nil?
@in_house = (team_information['type'] == 'In-House')
end

#####################################################
# @!group Apps
#####################################################
Expand Down
24 changes: 23 additions & 1 deletion spec/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,28 @@
end
end

describe "#team_information" do
it 'returns all available information' do
s = subject.team_information
expect(s['status']).to eq('active')
expect(s['type']).to eq('Company/Organization')
expect(s['name']).to eq('SpaceShip')
end
end

describe "#in_house?", now: true do
it 'returns false for normal accounts' do
expect(subject.in_house?).to eq(false)
end

it 'returns true for enterprise accounts' do
stub_multiple_teams

subject.team_id = 'SecondTeam'
expect(subject.in_house?).to eq(true)
end
end

describe '#create_app' do
it 'should make a request create an explicit app id' do
response = subject.create_app!(:explicit, 'Production App', 'tools.fastlane.spaceship.some-explicit-app')
Expand Down Expand Up @@ -157,7 +179,7 @@
end
end

describe '#certificates', now: true do
describe '#certificates' do
let(:certificates) { subject.certificates(["5QPB9NHCEI"]) }
it 'returns a list of certificates hashes' do
expect(certificates).to be_instance_of(Array)
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/listTeams_multiple.action.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
{
"status": "active",
"teamId": "SecondTeam",
"type": "Company/Organization",
"type": "In-House",
"extendedTeamAttributes": {
},
"teamAgent": {
Expand Down

0 comments on commit 11f9d66

Please sign in to comment.