Skip to content

Commit

Permalink
Adds extra attributes to the Image resource
Browse files Browse the repository at this point in the history
* `min_disk_size`, `size_gigabytes` & `created_at`
* Adds them as attributes and properties, and 
updates the specs and fixtures.
  • Loading branch information
petems committed Feb 28, 2017
1 parent 4d61b76 commit d3c3860
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/droplet_kit/mappings/image_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class ImageMapping
property :public, scopes: [:read, :read_snapshot, :read_backup]
property :regions, scopes: [:read, :read_snapshot, :read_backup]
property :type, scopes: [:read, :read_snapshot, :read_backup]

property :min_disk_size, scopes: [:read, :read_snapshot, :read_backup]
property :created_at, scopes: [:read, :read_snapshot, :read_backup]
property :size_gigabytes, scopes: [:read, :read_snapshot, :read_backup]
end
end
end
end
3 changes: 3 additions & 0 deletions lib/droplet_kit/models/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ class Image < BaseModel
attribute :public
attribute :regions
attribute :type
attribute :min_disk_size
attribute :size_gigabytes
attribute :created_at
end
end
6 changes: 4 additions & 2 deletions spec/fixtures/images/find.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"region--1"
],
"created_at": "2014-07-29T14:35:41Z",
"type": "snapshot"
"min_disk_size": 20,
"type": "snapshot",
"size_gigabytes":0.43
}
}
}
6 changes: 5 additions & 1 deletion spec/lib/droplet_kit/resources/image_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
expect(image.public).to eq(false)
expect(image.regions).to eq(["region--1"])
expect(image.type).to eq("snapshot")

expect(image.min_disk_size).to eq(20)
expect(image.size_gigabytes).to eq(0.43)
expect(image.created_at).to eq('2014-07-29T14:35:41Z')
end

it_behaves_like 'resource that handles common errors' do
Expand Down Expand Up @@ -86,4 +90,4 @@
expect(image.id).to eq(146)
end
end
end
end

0 comments on commit d3c3860

Please sign in to comment.