From fbeeab75bc0981a49b7e14cd72a43c094a24cc34 Mon Sep 17 00:00:00 2001 From: Kriszta Matyi Date: Tue, 12 Sep 2023 11:24:25 +0200 Subject: [PATCH] Adds current Sponsor logo to the sponsor edit page --- app/views/admin/sponsors/_form.html.haml | 2 ++ config/locales/en.yml | 1 - spec/features/admin/manage_sponsor_spec.rb | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/views/admin/sponsors/_form.html.haml b/app/views/admin/sponsors/_form.html.haml index 93baa94bf..42e3c7d3c 100644 --- a/app/views/admin/sponsors/_form.html.haml +++ b/app/views/admin/sponsors/_form.html.haml @@ -8,6 +8,8 @@ - if current_user.has_role?(:admin) = f.input :level, collection: Sponsor.levels.keys, label_method: :humanize = f.input :avatar, as: :file, required: !@sponsor.avatar? + - if @sponsor.avatar? + = image_tag(@sponsor.avatar.url, alt: "#{@sponsor.name} logo", class: 'small-image mw-100 mb-4', 'data-test': 'sponsor-logo') = f.hidden_field :image_cache #contacts.card.bg-light.border-info.mb-4.mb-md-0 diff --git a/config/locales/en.yml b/config/locales/en.yml index ee76b214f..5d3f3cd83 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -755,7 +755,6 @@ en: remote: Only check if the role is fully remote only salary: Annual pay before tax, without commas or decimal points sponsor: - avatar: The avatar is displayed in sponsors and on the event pages. accessibility_info: Is the office on the second floor? Is there a lift? How can someone with a handicap get there. contacts: mailing_list_consent: Adds contact to sponsors mailing list and triggers email enabling contact to self opt-out. diff --git a/spec/features/admin/manage_sponsor_spec.rb b/spec/features/admin/manage_sponsor_spec.rb index afef974bd..fe732c1f3 100644 --- a/spec/features/admin/manage_sponsor_spec.rb +++ b/spec/features/admin/manage_sponsor_spec.rb @@ -63,6 +63,9 @@ sponsor = Fabricate(:sponsor) visit edit_admin_sponsor_path(sponsor) + puts page.body + + expect(page.find('.small-image')['alt']).to match("#{sponsor.name} logo") fill_in 'Accessibility information', with: 'This venue is fully accessible to wheelchair users.' fill_in 'Description', with: 'This sponsor has great WiFi.' @@ -75,6 +78,15 @@ expect(page).to have_content 'Office is located on the third floor.' end end + context 'with existing avatar' do + it 'shows the current avatar on the edit page' do + sponsor = Fabricate(:sponsor) + + visit edit_admin_sponsor_path(sponsor) + + expect(page.find('*[data-test=sponsor-logo]')['alt']).to match("#{sponsor.name} logo") + end + end end describe 'adding contact information to a sponsor' do