From 860aec96b995ead404a96fd8ecceafa3b7a1f16b Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Mon, 28 Aug 2017 01:58:26 +0200 Subject: [PATCH] Make height and width optional for photos --- docs/_entities/photo.md | 4 ++-- lib/diaspora_federation/entities/photo.rb | 4 ++-- .../diaspora_federation/validators/photo_validator_spec.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/_entities/photo.md b/docs/_entities/photo.md index dc7ac86..caf9acd 100644 --- a/docs/_entities/photo.md +++ b/docs/_entities/photo.md @@ -14,8 +14,6 @@ This entity represents a photo. It can be standalone or nested in a [StatusMessa | `created_at` | [Timestamp][timestamp] | The create timestamp of the photo. | | `remote_photo_path` | [URL][url] | The URL to the photo, without filename (see `remote_photo_name`) | | `remote_photo_name` | [String][string] (255) | The filename of the photo. | -| `height` | [Integer][integer] | The height of the photo in pixels. | -| `width` | [Integer][integer] | The width of the photo in pixels. | ## Optional Properties @@ -23,6 +21,8 @@ This entity represents a photo. It can be standalone or nested in a [StatusMessa | --------------------- | ------------------------ | ------------------------------------------------------------------------------- | | `text` | [String][string] (65535) | Description text for the photo. | | `status_message_guid` | [GUID][guid] | The GUID of the [StatusMessage][status_message] to which the photo is attached. | +| `height` | [Integer][integer] | The height of the photo in pixels. | +| `width` | [Integer][integer] | The width of the photo in pixels. | ## Example diff --git a/lib/diaspora_federation/entities/photo.rb b/lib/diaspora_federation/entities/photo.rb index e3c17a5..b6c847d 100644 --- a/lib/diaspora_federation/entities/photo.rb +++ b/lib/diaspora_federation/entities/photo.rb @@ -48,12 +48,12 @@ module DiasporaFederation # @!attribute [r] height # Photo height # @return [Integer] height - property :height, :integer + property :height, :integer, optional: true # @!attribute [r] width # Photo width # @return [Integer] width - property :width, :integer + property :width, :integer, optional: true end end end diff --git a/spec/lib/diaspora_federation/validators/photo_validator_spec.rb b/spec/lib/diaspora_federation/validators/photo_validator_spec.rb index ce6ce1b..97682cc 100644 --- a/spec/lib/diaspora_federation/validators/photo_validator_spec.rb +++ b/spec/lib/diaspora_federation/validators/photo_validator_spec.rb @@ -38,7 +38,7 @@ module DiasporaFederation it_behaves_like "a property with a value validation/restriction" do let(:property) { prop } let(:wrong_values) { [true, :num, "asdf"] } - let(:correct_values) { [123, "123"] } + let(:correct_values) { [123, "123", nil] } end end end