API: Do not return redundant author for photos
This commit is contained in:
parent
8afa17f940
commit
af59bf3265
3 changed files with 4 additions and 20 deletions
|
|
@ -19,7 +19,6 @@ class PhotoPresenter < BasePresenter
|
||||||
|
|
||||||
def as_api_json(full=false)
|
def as_api_json(full=false)
|
||||||
api_json = {
|
api_json = {
|
||||||
author: PersonPresenter.new(author).as_api_json,
|
|
||||||
dimensions: {
|
dimensions: {
|
||||||
height: height,
|
height: height,
|
||||||
width: width
|
width: width
|
||||||
|
|
@ -32,6 +31,7 @@ class PhotoPresenter < BasePresenter
|
||||||
}
|
}
|
||||||
|
|
||||||
api_json[:guid] = guid if full
|
api_json[:guid] = guid if full
|
||||||
|
api_json[:created_at] = created_at if full
|
||||||
api_json[:post] = status_message_guid if full && status_message_guid
|
api_json[:post] = status_message_guid if full && status_message_guid
|
||||||
api_json
|
api_json
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ describe Api::V1::PhotosController do
|
||||||
expect(photo.has_key?("post")).to be_falsey
|
expect(photo.has_key?("post")).to be_falsey
|
||||||
ref_photo = auth.user.photos.reload.find_by(guid: photo["guid"])
|
ref_photo = auth.user.photos.reload.find_by(guid: photo["guid"])
|
||||||
expect(ref_photo.pending).to be_falsey
|
expect(ref_photo.pending).to be_falsey
|
||||||
confirm_photo_format(photo, ref_photo, auth.user)
|
confirm_photo_format(photo, ref_photo)
|
||||||
|
|
||||||
post(
|
post(
|
||||||
api_v1_photos_path,
|
api_v1_photos_path,
|
||||||
|
|
@ -379,14 +379,6 @@ describe Api::V1::PhotosController do
|
||||||
expect(photo["sizes"]["small"]).to be_truthy
|
expect(photo["sizes"]["small"]).to be_truthy
|
||||||
expect(photo["sizes"]["medium"]).to be_truthy
|
expect(photo["sizes"]["medium"]).to be_truthy
|
||||||
expect(photo["sizes"]["large"]).to be_truthy
|
expect(photo["sizes"]["large"]).to be_truthy
|
||||||
confirm_person_format(photo["author"], ref_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def confirm_person_format(post_person, user)
|
|
||||||
expect(post_person["guid"]).to eq(user.guid)
|
|
||||||
expect(post_person["diaspora_id"]).to eq(user.diaspora_handle)
|
|
||||||
expect(post_person["name"]).to eq(user.name)
|
|
||||||
expect(post_person["avatar"]).to eq(user.profile.image_url)
|
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/AbcSize
|
# rubocop:enable Metrics/AbcSize
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ describe PhotoPresenter do
|
||||||
it "presents full API JSON" do
|
it "presents full API JSON" do
|
||||||
photo_json = PhotoPresenter.new(@photo).as_api_json(true)
|
photo_json = PhotoPresenter.new(@photo).as_api_json(true)
|
||||||
expect(photo_json[:guid]).to eq(@photo.guid)
|
expect(photo_json[:guid]).to eq(@photo.guid)
|
||||||
confirm_photo_format(photo_json, @photo, bob)
|
confirm_photo_format(photo_json, @photo)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "defaults to limited API JSON" do
|
it "defaults to limited API JSON" do
|
||||||
|
|
@ -23,7 +23,7 @@ describe PhotoPresenter do
|
||||||
end
|
end
|
||||||
|
|
||||||
# rubocop:disable Metrics/AbcSize
|
# rubocop:disable Metrics/AbcSize
|
||||||
def confirm_photo_format(photo, ref_photo, ref_user)
|
def confirm_photo_format(photo, ref_photo)
|
||||||
if ref_photo.status_message_guid
|
if ref_photo.status_message_guid
|
||||||
expect(photo[:post]).to eq(ref_photo.status_message_guid)
|
expect(photo[:post]).to eq(ref_photo.status_message_guid)
|
||||||
else
|
else
|
||||||
|
|
@ -34,14 +34,6 @@ describe PhotoPresenter do
|
||||||
expect(photo[:sizes][:small]).to be_truthy
|
expect(photo[:sizes][:small]).to be_truthy
|
||||||
expect(photo[:sizes][:medium]).to be_truthy
|
expect(photo[:sizes][:medium]).to be_truthy
|
||||||
expect(photo[:sizes][:large]).to be_truthy
|
expect(photo[:sizes][:large]).to be_truthy
|
||||||
confirm_person_format(photo[:author], ref_user)
|
|
||||||
end
|
|
||||||
|
|
||||||
def confirm_person_format(post_person, user)
|
|
||||||
expect(post_person[:guid]).to eq(user.guid)
|
|
||||||
expect(post_person[:diaspora_id]).to eq(user.diaspora_handle)
|
|
||||||
expect(post_person[:name]).to eq(user.name)
|
|
||||||
expect(post_person[:avatar]).to eq(user.profile.image_url)
|
|
||||||
end
|
end
|
||||||
# rubocop:enable Metrics/AbcSize
|
# rubocop:enable Metrics/AbcSize
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue