<% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %>
@@ -43,12 +54,6 @@
<% unless investment.unfeasible? %>
- <% if investment.image.exists? %>
-
- <%= image_tag investment.image.url(:medium) %>
-
- <% end %>
-
<% if investment.should_show_votes? %>
diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb
index 7bda0e8f4..ee7532afd 100644
--- a/app/views/budgets/investments/_investment_show.html.erb
+++ b/app/views/budgets/investments/_investment_show.html.erb
@@ -37,8 +37,11 @@
<% end %>
+
<% if investment.image.exists? %>
- <%= image_tag investment.image.url(:large) %>
+ <%= image_tag investment.image.url(:medium),
+ title: investment.image_description,
+ alt: investment.image_description %>
<% end %>
<%= render 'shared/tags', taggable: investment %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index 79982150c..87864229e 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -104,6 +104,8 @@ en:
title: "Title"
location: "Location"
organization_name: "If you are proposing in the name of a collective/organization, write its name"
+ image: "Proposal descriptive image"
+ image_description: "Image description"
budget/investment/milestone:
title: "Title"
description: "Description"
diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml
index d409d1c5e..4bff6f5a9 100644
--- a/config/locales/es/activerecord.yml
+++ b/config/locales/es/activerecord.yml
@@ -99,6 +99,8 @@ es:
title: "Título"
location: "Ubicación"
organization_name: "Si estás proponiendo en nombre de una organización o colectivo, escribe su nombre"
+ image: "Imagen descriptiva de la propueta"
+ image_description: "Texto descriptivo de la imagen"
comment:
body: "Comentario"
user: "Usuario"
diff --git a/db/schema.rb b/db/schema.rb
index a44bf62aa..816648ac9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -257,10 +257,10 @@ ActiveRecord::Schema.define(version: 20170918231410) do
t.string "visit_id"
t.datetime "hidden_at"
t.integer "flags_count", default: 0
+ t.datetime "ignored_flag_at"
t.integer "cached_votes_total", default: 0
t.integer "cached_votes_up", default: 0
t.integer "cached_votes_down", default: 0
- t.datetime "ignored_flag_at"
t.integer "comments_count", default: 0
t.datetime "confirmed_hide_at"
t.integer "cached_anonymous_votes_total", default: 0
@@ -279,7 +279,6 @@ ActiveRecord::Schema.define(version: 20170918231410) do
add_index "debates", ["cached_votes_total"], name: "index_debates_on_cached_votes_total", using: :btree
add_index "debates", ["cached_votes_up"], name: "index_debates_on_cached_votes_up", using: :btree
add_index "debates", ["confidence_score"], name: "index_debates_on_confidence_score", using: :btree
- add_index "debates", ["description"], name: "index_debates_on_description", using: :btree
add_index "debates", ["geozone_id"], name: "index_debates_on_geozone_id", using: :btree
add_index "debates", ["hidden_at"], name: "index_debates_on_hidden_at", using: :btree
add_index "debates", ["hot_score"], name: "index_debates_on_hot_score", using: :btree
@@ -786,7 +785,6 @@ ActiveRecord::Schema.define(version: 20170918231410) do
add_index "proposals", ["cached_votes_up"], name: "index_proposals_on_cached_votes_up", using: :btree
add_index "proposals", ["community_id"], name: "index_proposals_on_community_id", using: :btree
add_index "proposals", ["confidence_score"], name: "index_proposals_on_confidence_score", using: :btree
- add_index "proposals", ["description"], name: "index_proposals_on_description", using: :btree
add_index "proposals", ["geozone_id"], name: "index_proposals_on_geozone_id", using: :btree
add_index "proposals", ["hidden_at"], name: "index_proposals_on_hidden_at", using: :btree
add_index "proposals", ["hot_score"], name: "index_proposals_on_hot_score", using: :btree
diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb
index afc564496..2cd4bd4ff 100644
--- a/spec/features/budgets/investments_spec.rb
+++ b/spec/features/budgets/investments_spec.rb
@@ -28,6 +28,21 @@ feature 'Budget Investments' do
end
end
+ scenario 'Index should show investment descriptive image only when is defined' do
+ investment = create(:budget_investment, heading: heading)
+ investment_with_image = create(:budget_investment, :with_descriptive_image, heading: heading)
+
+ visit budget_investments_path(budget, heading_id: heading.id)
+
+ within("#budget_investment_#{investment.id}") do
+ expect(page).not_to have_css("img.th")
+ end
+
+ within("#budget_investment_#{investment_with_image.id}") do
+ expect(page).to have_css("img.th[alt='#{investment_with_image.image_description}'][title='#{investment_with_image.image_description}']")
+ end
+ end
+
context("Search") do
scenario 'Search by text' do
@@ -355,6 +370,16 @@ feature 'Budget Investments' do
expect(page).not_to have_selector ".js-follow"
end
+ scenario "Show descriptive image when exists" do
+ user = create(:user)
+ login_as(user)
+ investment_with_image = create(:budget_investment, :with_descriptive_image, heading: heading)
+
+ visit budget_investment_path(budget_id: budget.id, id: investment_with_image.id)
+
+ expect(page).to have_css("img[alt='#{investment_with_image.image_description}'][title='#{investment_with_image.image_description}']")
+ end
+
scenario "Show back link contains heading id" do
investment = create(:budget_investment, heading: heading)
visit budget_investment_path(budget, investment)