From 256c448556bd16bd054e868bd2afef87aeae45a0 Mon Sep 17 00:00:00 2001 From: Karine Vieira <62672837+karinevieira@users.noreply.github.com> Date: Sat, 4 May 2024 10:35:44 -0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20display=20default=20avatar?= =?UTF-8?q?=20if=20user=20doesn't=20have=20a=20profile=20picture=20(#83)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/images/users/avatar.png | Bin 0 -> 15441 bytes app/components/users/avatar_component.rb | 12 +++++----- app/pages/users/show_page.html.erb | 2 +- .../components/users/avatar_component_spec.rb | 21 ++++++++++++------ 4 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 app/assets/images/users/avatar.png diff --git a/app/assets/images/users/avatar.png b/app/assets/images/users/avatar.png new file mode 100644 index 0000000000000000000000000000000000000000..a4c14c6338ce44748f3b6a22d9853db6a59dd3a3 GIT binary patch literal 15441 zcmeHug;!Kx)b<^6C<%!n6p)r0kxpqrTIrS!N$DD;lvGk$TDo(H0R)r|X@?L2>F)Y2 zzxVwkzHhB>t(i4zoqf(e`|k7XXYX^)osSx7ibVJ{_y7P9DLt3d0ssue-4}`hwggw0 zyafPpn3A0IEAQE@2{C*O2qB=k8>FIny7|C}oPd;oRzDrLLOC@rwQHRZ0Hi#p*YttC z1uPf{}wppQa=5#@~xSwY!v9PFU9Jb?lcp4EOUZABjq_eUY%-%S*uFJ>I`u>o*|9p|z z=-LftS_*5E5ATXSJmuKPdxYTFIPK2(==Y2>!RqVVXos$;O^UUzLQtxBeK;)odj9LS zS4PZ&TWj-peVSVSJl7midR@Uw=O&^lckzW|q)EjBeN4}|NDqFCZj?OW8|+OUi|$a_ z9`yytMvRi%@55km|NG`>Oqf3YPSfKIS4rXT;B?{PA}<6$x*6K{Zton zkXg&Q|CwuE+SS6#fp%p z4Os;30%sVfLI$ z_Avja%417)&3OyG?)gVy9m zTK`qmZMn)nb*SIm35?wDJiPxo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686kC8}Ewe$)qF;qtH275|oDWc8ob~2uZI@+4 zxIoPSJ>JAH4?m%3s|{R{Xc)#BeYdNd6tO)e_)unpA6DdIy5gTkv$@&QqHe@B9*fZv zrnEx<2gSy1)umcr=ln5Gp4xhdIDt%^-e6Dx1P_>un|IHyBLbt~JzOxA`-B(+CCZ0B z31b}M!BHN!W|qL5&canHE_Zh73;VGajt!idKh?@Nf3v$&5}G;qd={s&uR3@9FpjY? z2nQjcU1x-xn5d&x8U`{$HB+rx8<67QajwA}|Mt&cQwP*~!(a$7tB@_#`+xvCW=R@G zQ3ab9FF&me1D6M+p9Zg&f(#Ip!F`jperx6j$ai&wi_eO{(5>vigaf5b#V)BCWy~x1 zz7Ni%zfneRqXQlyAkQ!b`dhPbKYNzo2@o#gRwa0r7*Y)S2dV&wtX&))>d6V)(gk}N zB1~bmzu&W*s{t4=nYAa%BI_@FA={ok(u`dxMVzOlJGHEZevL^6lp-gDW9E@){(fuU zGWjt$BC#)K_#$c%03=?O6(k|wfwOQKZf!kCC_-TX+`ry5ST_Zdg!xXGuT!Fk|4TO7 zNqd+Gp2tKE{$fg&#p6#aoxo^(H{qiH9t%h%F|p|)Sqsj#cKH03U{UyUe33dhtF46q zvBT}2T#b*O0rp-smZ)Lkv$Wq*mfgX+HTfs+%Mx^2dFfdS+!MYPJ8J? zOQ0-(P-GX{+Dt<-YtR0=Gh8#yz@$)t7&JuAJ0rSTXRZ(Vo zoEzpp;U5PGw*~o2dLhe$HcxqTH9>&y k=7IM<0QLV}1DA;38t6Z_#zbR*cP4<6yqa9OjM@AD1J=E}+W-In literal 0 HcmV?d00001 diff --git a/app/components/users/avatar_component.rb b/app/components/users/avatar_component.rb index 952d2fc..9daf3ff 100644 --- a/app/components/users/avatar_component.rb +++ b/app/components/users/avatar_component.rb @@ -2,16 +2,16 @@ module Users class AvatarComponent < ViewComponent::Base - attr_reader :image_url - - def initialize(image_url:) - @image_url = image_url + def initialize(user:) + @user = user end private - def render? - image_url.present? + attr_reader :user + + def image_url + user.profile.avatar.present? ? url_for(user.profile.avatar) : "users/avatar.png" end end end diff --git a/app/pages/users/show_page.html.erb b/app/pages/users/show_page.html.erb index 43696f3..82dc7cb 100644 --- a/app/pages/users/show_page.html.erb +++ b/app/pages/users/show_page.html.erb @@ -1,6 +1,6 @@
- <%= render Users::AvatarComponent.new(image_url: "https://i.pravatar.cc/150?img=3") %> + <%= render Users::AvatarComponent.new(user: user) %>

<%= user.profile.display_name %>

@<%= user.profile.username %>

diff --git a/spec/components/users/avatar_component_spec.rb b/spec/components/users/avatar_component_spec.rb index 779650c..867c1f5 100644 --- a/spec/components/users/avatar_component_spec.rb +++ b/spec/components/users/avatar_component_spec.rb @@ -3,19 +3,26 @@ require "rails_helper" RSpec.describe Users::AvatarComponent, type: :component do - context "when image_url is given" do + context "when user has an avatar" do it "renders user's avatar image" do - rendered = render_inline(described_class.new(image_url: "https://i.pravatar.cc/150?img=3")) + avatar = Rack::Test::UploadedFile.new( + Rails.root.join("spec/fixtures/files/image.png"), "image/png" + ) + profile = create(:user_profile, avatar: avatar) + user = create(:user, profile: profile) - expect(rendered).to have_css("img[src*='https://i.pravatar.cc/150?img=3']") + rendered = render_inline(described_class.new(user: user)) + + expect(rendered).to have_css("img[src*='image.png']") end end - context "when image_url isn't given" do - it "doesn't render user's avatar image" do - rendered = render_inline(described_class.new(image_url: nil)) + context "when user doesn't have an avatar" do + it "renders default avatar" do + user = create(:user) + rendered = render_inline(described_class.new(user: user)) - expect(rendered.to_html).to be_empty + expect(rendered).to have_css("img[src*='users/avatar']") end end end