From dbbf7439200de62ffa5ed6131c1b8d7fe7a3d98a Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Tue, 4 Feb 2020 14:38:49 +0100 Subject: [PATCH] Add the scaled_full image as a raw image in AvatarPresenter as well. This is a temporary workaround. Adding the real raw photo is quite a challange and touches multiple components nobody wants to touch right now. As this change is blocking an actual hotfix, this is fine, and will be properly fixed at a later time. --- app/presenters/avatar_presenter.rb | 8 +++++++- spec/presenters/avatar_presenter_spec.rb | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/presenters/avatar_presenter.rb b/app/presenters/avatar_presenter.rb index c3656cc69..7b7847fa1 100644 --- a/app/presenters/avatar_presenter.rb +++ b/app/presenters/avatar_presenter.rb @@ -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 diff --git a/spec/presenters/avatar_presenter_spec.rb b/spec/presenters/avatar_presenter_spec.rb index d85d43a47..a2269b9bc 100644 --- a/spec/presenters/avatar_presenter_spec.rb +++ b/spec/presenters/avatar_presenter_spec.rb @@ -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