Fix customization of budget_execution_no_image
We forgot to change the line rendering the image in commits3574bf867cand810bdae37a, and so the custom image was being ignored. Note that, in the test, we're stubbing a constant instead of adding a new image. The main reason is that, if we add a new image, forks would have to change the image when they change the `VALID_IMAGES` constant; otherwise the tests would fail.
This commit is contained in:
@@ -3,5 +3,5 @@
|
||||
<% elsif investment.image.present? %>
|
||||
<%= image_tag investment.image.variant(:large), alt: investment.image.title %>
|
||||
<% else %>
|
||||
<%= image_tag "budget_execution_no_image.jpg", alt: investment.title %>
|
||||
<%= image_tag image_path_for("budget_execution_no_image.jpg"), alt: investment.title %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Budgets::Executions::ImageComponent < ApplicationComponent
|
||||
attr_reader :investment
|
||||
delegate :image_path_for, to: :helpers
|
||||
|
||||
def initialize(investment)
|
||||
@investment = investment
|
||||
|
||||
25
spec/components/budgets/executions/image_component_spec.rb
Normal file
25
spec/components/budgets/executions/image_component_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Budgets::Executions::ImageComponent do
|
||||
context "investment and milestone without image" do
|
||||
let(:component) { Budgets::Executions::ImageComponent.new(Budget::Investment.new) }
|
||||
|
||||
it "shows the default image" do
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_css "img[src*='budget_execution_no_image']"
|
||||
end
|
||||
|
||||
it "shows a custom default image when available" do
|
||||
stub_const("#{SiteCustomization::Image}::VALID_IMAGES", { "budget_execution_no_image" => [260, 80] })
|
||||
create(:site_customization_image,
|
||||
name: "budget_execution_no_image",
|
||||
image: fixture_file_upload("logo_header-260x80.png"))
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_css "img[src$='logo_header-260x80.png']"
|
||||
expect(page).not_to have_css "img[src*='budget_execution_no_image']"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user