Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

account: add 'name' field in response #314

Merged
merged 3 commits into from
Jul 18, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ Gemspec/RequireMFA:
Gemspec/RubyVersionGlobalsUsage:
Enabled: false

RSpec/IndexedLet:
Enabled: false

RSpec/MatchArray:
Enabled: false

Gemspec/DevelopmentDependencies:
Enabled: false

RSpec:
Language:
Expectations:
- check_droplet
- check_droplet
16 changes: 16 additions & 0 deletions lib/droplet_kit/mappings/account_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,25 @@ class AccountMapping
scoped :read do
property :droplet_limit
property :floating_ip_limit
property :name
property :email
property :uuid
property :email_verified
property :team
end
end
end

class AccountTeamMapping
include Kartograph::DSL

kartograph do
root_key singular: 'team', scopes: [:read]
mapping AccountTeam

scoped :read do
property :uuid
property :name
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions lib/droplet_kit/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ module DropletKit
class Account < BaseModel
attribute :droplet_limit
attribute :floating_ip_limit
attribute :name
attribute :email
attribute :uuid
attribute :email_verified
attribute :team
end

class AccountTeam < BaseModel
attribute :uuid
attribute :name
end
end
9 changes: 7 additions & 2 deletions spec/fixtures/account/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"account": {
"droplet_limit": 200,
"email": "droplet_kit@digitalocean.com",
"name": "Sammy the Shark",
"uuid": "alksdjfhlakjdsfh12983712",
"email_verified": true
"email_verified": true,
"team": {
"uuid": "00000000-0000-4000-00000000000000000",
"name": "My Team"
}
}
}
}
2 changes: 2 additions & 0 deletions spec/lib/droplet_kit/resources/account_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
expect(account_info.droplet_limit).to eq(parsed['account']['droplet_limit'])
expect(account_info.floating_ip_limit).to eq(parsed['account']['floating_ip_limit'])
expect(account_info.email).to eq(parsed['account']['email'])
expect(account_info.name).to eq(parsed['account']['name'])
expect(account_info.uuid).to eq(parsed['account']['uuid'])
expect(account_info.email_verified).to eq(parsed['account']['email_verified'])
expect(account_info.team).to eq(parsed['account']['team'])
end

it_behaves_like 'resource that handles common errors' do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/droplet_kit/resources/database_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
expect(database_cluster.db_names).to eq(['defaultdb'])
expect(database_cluster.maintenance_window.day).to eq('saturday')
expect(database_cluster.maintenance_window.hour).to eq('08:45:12')
expect(database_cluster.maintenance_window.pending).to be(true) # rubocop:disable RSpec/PendingWithoutReason https://github.com/rubocop/rubocop-rspec/pull/1516
expect(database_cluster.maintenance_window.pending).to be(true)
expect(database_cluster.maintenance_window.description.first).to eq('Update TimescaleDB to version 1.2.1')
expect(database_cluster.maintenance_window.description.last).to eq('Upgrade to PostgreSQL 11.2 and 10.7 bugfix releases')
end
Expand Down