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.
This commit is contained in:
parent
bf55d07580
commit
dbbf743920
2 changed files with 18 additions and 2 deletions
|
|
@ -6,7 +6,8 @@ class AvatarPresenter < BasePresenter
|
||||||
avatar = {
|
avatar = {
|
||||||
small: small(with_default),
|
small: small(with_default),
|
||||||
medium: medium(with_default),
|
medium: medium(with_default),
|
||||||
large: large(with_default)
|
large: large(with_default),
|
||||||
|
raw: raw(with_default) # rubocop:disable Rails/OutputSafety
|
||||||
}.compact
|
}.compact
|
||||||
|
|
||||||
avatar unless avatar.empty?
|
avatar unless avatar.empty?
|
||||||
|
|
@ -21,6 +22,11 @@ class AvatarPresenter < BasePresenter
|
||||||
end
|
end
|
||||||
|
|
||||||
def large(with_default=false)
|
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)
|
image_url(fallback_to_default: with_default)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ describe AvatarPresenter do
|
||||||
it "calls image_url() for the avatars" do
|
it "calls image_url() for the avatars" do
|
||||||
profile = FactoryGirl.create(:profile_with_image_url, person: alice.person)
|
profile = FactoryGirl.create(:profile_with_image_url, person: alice.person)
|
||||||
presenter = AvatarPresenter.new(profile)
|
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
|
expect(presenter.base_hash).to be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -14,5 +14,15 @@ describe AvatarPresenter do
|
||||||
presenter = AvatarPresenter.new(profile)
|
presenter = AvatarPresenter.new(profile)
|
||||||
expect(presenter.base_hash).to be_nil
|
expect(presenter.base_hash).to be_nil
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue