Merge pull request #8100 from denschub/hotfix/fix-raw-photos
Re-add `raw` to a photo's json.
This commit is contained in:
commit
08d4f87a2d
5 changed files with 26 additions and 6 deletions
|
|
@ -6,7 +6,8 @@ class AvatarPresenter < BasePresenter
|
|||
avatar = {
|
||||
small: small(with_default),
|
||||
medium: medium(with_default),
|
||||
large: large(with_default)
|
||||
large: large(with_default),
|
||||
raw: raw(with_default) # rubocop:disable Rails/OutputSafety
|
||||
}.compact
|
||||
|
||||
avatar unless avatar.empty?
|
||||
|
|
@ -21,6 +22,11 @@ class AvatarPresenter < BasePresenter
|
|||
end
|
||||
|
||||
def large(with_default=false)
|
||||
image_url(size: :scaled_full, fallback_to_default: with_default)
|
||||
end
|
||||
|
||||
def raw(with_default=false)
|
||||
# TODO: Replace me with the actual raw photo.
|
||||
image_url(fallback_to_default: with_default)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@ class PhotoPresenter < BasePresenter
|
|||
sizes: {
|
||||
small: url(:thumb_small),
|
||||
medium: url(:thumb_medium),
|
||||
large: url(:scaled_full)
|
||||
large: url(:scaled_full),
|
||||
raw: url
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
@ -26,7 +27,8 @@ class PhotoPresenter < BasePresenter
|
|||
sizes: {
|
||||
small: url(:thumb_small),
|
||||
medium: url(:thumb_medium),
|
||||
large: url(:scaled_full)
|
||||
large: url(:scaled_full),
|
||||
raw: url
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -205,12 +205,13 @@
|
|||
"photo_sizes": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"raw": { "$ref": "https://diaspora.software/api/v1/schema.json#/definitions/url" },
|
||||
"large": { "$ref": "https://diaspora.software/api/v1/schema.json#/definitions/url" },
|
||||
"medium": { "$ref": "https://diaspora.software/api/v1/schema.json#/definitions/url" },
|
||||
"small": { "$ref": "https://diaspora.software/api/v1/schema.json#/definitions/url" }
|
||||
},
|
||||
"required": ["large", "medium", "small"],
|
||||
"additionalProperties": true
|
||||
"required": ["raw", "large", "medium", "small"],
|
||||
"additionalProperties": false
|
||||
},
|
||||
|
||||
"photo_dimensions": {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ describe AvatarPresenter do
|
|||
it "calls image_url() for the avatars" do
|
||||
profile = FactoryGirl.create(:profile_with_image_url, person: alice.person)
|
||||
presenter = AvatarPresenter.new(profile)
|
||||
expect(profile).to receive(:image_url).exactly(3).times.and_call_original
|
||||
expect(profile).to receive(:image_url).exactly(4).times.and_call_original
|
||||
expect(presenter.base_hash).to be_present
|
||||
end
|
||||
|
||||
|
|
@ -14,5 +14,15 @@ describe AvatarPresenter do
|
|||
presenter = AvatarPresenter.new(profile)
|
||||
expect(presenter.base_hash).to be_nil
|
||||
end
|
||||
|
||||
it "returns all relevant sizes" do
|
||||
profile = FactoryGirl.create(:profile_with_image_url, person: alice.person)
|
||||
base_hash = AvatarPresenter.new(profile).base_hash
|
||||
|
||||
expect(base_hash[:small]).to be_truthy
|
||||
expect(base_hash[:medium]).to be_truthy
|
||||
expect(base_hash[:large]).to be_truthy
|
||||
expect(base_hash[:raw]).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ describe PhotoPresenter do
|
|||
expect(photo[:sizes][:small]).to be_truthy
|
||||
expect(photo[:sizes][:medium]).to be_truthy
|
||||
expect(photo[:sizes][:large]).to be_truthy
|
||||
expect(photo[:sizes][:raw]).to be_truthy
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue