From af59bf326512d191f28f35f75d0cbdd91b704f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Sat, 27 Apr 2019 16:03:55 +0200 Subject: [PATCH] API: Do not return redundant author for photos --- app/presenters/photo_presenter.rb | 2 +- spec/integration/api/photos_controller_spec.rb | 10 +--------- spec/presenters/photo_presenter_spec.rb | 12 ++---------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/app/presenters/photo_presenter.rb b/app/presenters/photo_presenter.rb index 728d5a90e..2d2659400 100644 --- a/app/presenters/photo_presenter.rb +++ b/app/presenters/photo_presenter.rb @@ -19,7 +19,6 @@ class PhotoPresenter < BasePresenter def as_api_json(full=false) api_json = { - author: PersonPresenter.new(author).as_api_json, dimensions: { height: height, width: width @@ -32,6 +31,7 @@ class PhotoPresenter < BasePresenter } 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 end diff --git a/spec/integration/api/photos_controller_spec.rb b/spec/integration/api/photos_controller_spec.rb index db8beff53..c945e7dfe 100644 --- a/spec/integration/api/photos_controller_spec.rb +++ b/spec/integration/api/photos_controller_spec.rb @@ -215,7 +215,7 @@ describe Api::V1::PhotosController do expect(photo.has_key?("post")).to be_falsey ref_photo = auth.user.photos.reload.find_by(guid: photo["guid"]) expect(ref_photo.pending).to be_falsey - confirm_photo_format(photo, ref_photo, auth.user) + confirm_photo_format(photo, ref_photo) post( api_v1_photos_path, @@ -379,14 +379,6 @@ describe Api::V1::PhotosController do expect(photo["sizes"]["small"]).to be_truthy expect(photo["sizes"]["medium"]).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 # rubocop:enable Metrics/AbcSize end diff --git a/spec/presenters/photo_presenter_spec.rb b/spec/presenters/photo_presenter_spec.rb index bc7ba1fcf..e5bcb5677 100644 --- a/spec/presenters/photo_presenter_spec.rb +++ b/spec/presenters/photo_presenter_spec.rb @@ -13,7 +13,7 @@ describe PhotoPresenter do it "presents full API JSON" do photo_json = PhotoPresenter.new(@photo).as_api_json(true) expect(photo_json[:guid]).to eq(@photo.guid) - confirm_photo_format(photo_json, @photo, bob) + confirm_photo_format(photo_json, @photo) end it "defaults to limited API JSON" do @@ -23,7 +23,7 @@ describe PhotoPresenter do end # 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 expect(photo[:post]).to eq(ref_photo.status_message_guid) else @@ -34,14 +34,6 @@ describe PhotoPresenter do expect(photo[:sizes][:small]).to be_truthy expect(photo[:sizes][:medium]).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 # rubocop:enable Metrics/AbcSize end