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