<%= investment.title %>
diff --git a/app/views/layouts/_common_head.html.erb b/app/views/layouts/_common_head.html.erb
index eb64eeced..369c5261e 100644
--- a/app/views/layouts/_common_head.html.erb
+++ b/app/views/layouts/_common_head.html.erb
@@ -10,4 +10,4 @@
<% end %>
<%= javascript_include_tag "application", "data-turbolinks-track" => "reload" %>
<%= csrf_meta_tags %>
-<%= favicon_link_tag "favicon.ico" %>
+<%= favicon_link_tag image_path_for("favicon.ico") %>
diff --git a/app/views/layouts/dashboard.html.erb b/app/views/layouts/dashboard.html.erb
index 2460ba948..cf33f6f4f 100644
--- a/app/views/layouts/dashboard.html.erb
+++ b/app/views/layouts/dashboard.html.erb
@@ -1,16 +1,9 @@
-
-
-
+ <%= render "layouts/common_head", default_title: setting["org_name"] %>
<%= render "layouts/meta_tags" %>
-
<%= content_for?(:title) ? yield(:title) : setting["org_name"] %>
<%= content_for :canonical %>
- <%= stylesheet_link_tag "application" %>
- <%= javascript_include_tag "application", "data-turbolinks-track" => "reload" %>
- <%= csrf_meta_tags %>
- <%= favicon_link_tag "favicon.ico" %>
<%= favicon_link_tag image_path_for("apple-touch-icon-200.png"),
rel: "icon apple-touch-icon",
sizes: "200x200",
diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb
index c781d4403..e9ebac423 100644
--- a/app/views/layouts/devise.html.erb
+++ b/app/views/layouts/devise.html.erb
@@ -9,7 +9,8 @@
<%= raw setting["html.per_page_code_body"] %>
-
+
)">
<%= link_to root_path do %>
<%= image_tag(image_path_for("logo_header.png"), class: "float-left", alt: setting["org_name"]) %>
diff --git a/spec/components/budgets/executions/image_component_spec.rb b/spec/components/budgets/executions/image_component_spec.rb
new file mode 100644
index 000000000..a40d8d1ce
--- /dev/null
+++ b/spec/components/budgets/executions/image_component_spec.rb
@@ -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
diff --git a/spec/components/budgets/investment_component_spec.rb b/spec/components/budgets/investment_component_spec.rb
index 7db17ae8d..fe25ac490 100644
--- a/spec/components/budgets/investment_component_spec.rb
+++ b/spec/components/budgets/investment_component_spec.rb
@@ -11,11 +11,26 @@ describe Budgets::InvestmentComponent do
expect(page).to have_css "img[alt='#{investment.image.title}']"
end
- it "shows the default image when investment has not an image defined" do
- investment = create(:budget_investment)
- render_inline Budgets::InvestmentComponent.new(investment)
+ context "investment without an image" do
+ let(:component) { Budgets::InvestmentComponent.new(create(:budget_investment)) }
- expect(page).to have_css "img[src*='budget_investment_no_image']"
+ it "shows the default image" do
+ render_inline component
+
+ expect(page).to have_css "img[src*='budget_investment_no_image']"
+ end
+
+ it "shows a custom default image when available" do
+ stub_const("#{SiteCustomization::Image}::VALID_IMAGES", { "budget_investment_no_image" => [260, 80] })
+ create(:site_customization_image,
+ name: "budget_investment_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_investment_no_image']"
+ end
end
it "shows supports count when budget is valuating" do
diff --git a/spec/components/widget/feeds/process_component_spec.rb b/spec/components/widget/feeds/process_component_spec.rb
index 0f0d2327f..a7be34f17 100644
--- a/spec/components/widget/feeds/process_component_spec.rb
+++ b/spec/components/widget/feeds/process_component_spec.rb
@@ -20,4 +20,24 @@ describe Widget::Feeds::ProcessComponent do
expect(page).to have_css("img[alt='1. No Poverty']")
end
+
+ describe "image" do
+ it "shows the default image" do
+ render_inline component
+
+ expect(page).to have_css "img[src*='welcome_process']"
+ end
+
+ it "shows a custom default image when available" do
+ stub_const("#{SiteCustomization::Image}::VALID_IMAGES", { "welcome_process" => [260, 80] })
+ create(:site_customization_image,
+ name: "welcome_process",
+ 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*='welcome_process']"
+ end
+ end
end
diff --git a/spec/fixtures/files/favicon_custom.ico b/spec/fixtures/files/favicon_custom.ico
new file mode 100644
index 000000000..187043296
Binary files /dev/null and b/spec/fixtures/files/favicon_custom.ico differ
diff --git a/spec/models/site_customization/image_spec.rb b/spec/models/site_customization/image_spec.rb
index 945046144..55534b535 100644
--- a/spec/models/site_customization/image_spec.rb
+++ b/spec/models/site_customization/image_spec.rb
@@ -44,4 +44,18 @@ describe SiteCustomization::Image do
expect(map).not_to be_valid
end
end
+
+ it "dynamically validates the valid mime types" do
+ stub_const("#{SiteCustomization::Image}::VALID_MIME_TYPES", ["image/gif"])
+
+ gif = build(:site_customization_image,
+ name: "logo_header",
+ image: fixture_file_upload("logo_header.gif"))
+ expect(gif).to be_valid
+
+ png = build(:site_customization_image,
+ name: "logo_header",
+ image: fixture_file_upload("logo_header.png"))
+ expect(png).not_to be_valid
+ end
end
diff --git a/spec/system/site_customization/images_spec.rb b/spec/system/site_customization/images_spec.rb
new file mode 100644
index 000000000..4674eaf1d
--- /dev/null
+++ b/spec/system/site_customization/images_spec.rb
@@ -0,0 +1,23 @@
+require "rails_helper"
+
+describe "Site customization images" do
+ scenario "Custom favicon" do
+ create(:site_customization_image, name: "favicon", image: fixture_file_upload("favicon_custom.ico"))
+
+ visit root_path
+
+ expect(page).to have_css("link[rel='shortcut icon'][href$='favicon_custom.ico']", visible: :hidden)
+ end
+
+ scenario "Custom auth background" do
+ stub_const("#{SiteCustomization::Image}::VALID_IMAGES", { "auth_bg" => [260, 80] })
+ create(:site_customization_image,
+ name: "auth_bg",
+ image: fixture_file_upload("logo_header-260x80.png"))
+
+ visit new_user_session_path
+
+ expect(page).to have_css "[style*='background-image:'][style*='logo_header-260x80.png']"
+ expect(page).not_to have_css "[style*='auth_bg']"
+ end
+end