Remove unused image_default parameter

This parameter isn't used since commit b4a6f664b.

Note we're changing the tests to use proposals instead of debates
because proposals may have images attached, while debates may not.
This commit is contained in:
Javi Martín
2025-02-22 23:10:31 +01:00
parent 74a9b48076
commit d18510e102
4 changed files with 14 additions and 20 deletions

View File

@@ -18,17 +18,15 @@ module WelcomeHelper
end
end
def render_recommendation_image(recommended, image_default)
image_path = calculate_image_path(recommended, image_default)
def render_recommendation_image(recommended)
image_path = calculate_image_path(recommended)
image_tag(image_path) if image_path.present?
end
def calculate_image_path(recommended, image_default)
def calculate_image_path(recommended)
if recommended.respond_to?(:image) && recommended.image.present? &&
recommended.image.attachment.attached?
recommended.image.variant(:medium)
elsif image_default.present?
image_default
end
end

View File

@@ -13,7 +13,6 @@
key: "debates",
image_field: nil,
image_version: nil,
image_default: nil,
carousel_size: carousel_size,
btn_text_link: t("welcome.recommended.debates.btn_text_link"),
btn_path_link: debates_path(order: "recommendations") %>
@@ -25,7 +24,6 @@
key: "proposals",
image_field: :attachment,
image_version: :thumb,
image_default: nil,
carousel_size: carousel_size,
btn_text_link: t("welcome.recommended.proposals.btn_text_link"),
btn_path_link: proposals_path(order: "recommendations") %>

View File

@@ -11,7 +11,7 @@
<li class="orbit-slide <%= is_active_class(index) %>" data-slide="<%= index %>" style="position: relative; <%= slide_display(index) %>" aria-live="polite">
<div class="card">
<%= render_recommendation_image(recommended, image_default) %>
<%= render_recommendation_image(recommended) %>
<div class="card-section">
<%= link_to recommended_path(recommended) do %>
<h4 class="truncate-horizontal-text"><%= recommended.title %></h4>

View File

@@ -1,36 +1,34 @@
require "rails_helper"
RSpec.describe "welcome#index" do
it "Display images on orbit carrousel when we have defined image_default" do
debate = create(:debate)
it "displays images on the orbit carrousel when recommendations have an image" do
proposal = create(:proposal, :with_image)
render template: "welcome/_recommended_carousel",
locals: { key: "debates",
recommendeds: [debate],
recommendeds: [proposal],
image_field: nil,
image_version: nil,
image_default: "https://dummyimage.com/600x400/000/fff",
carousel_size: "medium-6 large-6 medium-centered large-centered",
btn_text_link: t("welcome.recommended.debates.btn_text_link"),
btn_path_link: debates_path(order: "recommendations") }
btn_text_link: t("welcome.recommended.proposals.btn_text_link"),
btn_path_link: proposals_path(order: "recommendations") }
within 'li[data-slide="0"] .card' do
expect(page).to have_css "img"
end
end
it "Not display images on orbit carrousel when we have not defined image_default" do
debate = create(:debate)
it "does not display images on the orbit carrousel when recommendations don't have an image" do
proposal = create(:proposal)
render template: "welcome/_recommended_carousel",
locals: { key: "debates",
recommendeds: [debate],
recommendeds: [proposal],
image_field: nil,
image_version: nil,
image_default: nil,
carousel_size: "medium-6 large-6 medium-centered large-centered",
btn_text_link: t("welcome.recommended.debates.btn_text_link"),
btn_path_link: debates_path(order: "recommendations") }
btn_text_link: t("welcome.recommended.proposals.btn_text_link"),
btn_path_link: proposals_path(order: "recommendations") }
within 'li[data-slide="0"] .card' do
expect(page).not_to have_css "img"