Add budget investements images specs
This commit is contained in:
@@ -105,9 +105,11 @@ module Budgets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def investment_params
|
def investment_params
|
||||||
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list,
|
params.require(:budget_investment)
|
||||||
:organization_name, :location, :terms_of_service, :image,
|
.permit(:title, :description, :external_url, :heading_id,
|
||||||
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id])
|
:tag_list, :organization_name, :location, :terms_of_service,
|
||||||
|
:image, :image_description,
|
||||||
|
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_ballot
|
def load_ballot
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class Budget
|
|||||||
acts_as_paranoid column: :hidden_at
|
acts_as_paranoid column: :hidden_at
|
||||||
include ActsAsParanoidAliases
|
include ActsAsParanoidAliases
|
||||||
|
|
||||||
|
# TODO: ROCK&ROR: Set image versions sizes acordingly to enhance page load
|
||||||
has_attached_file :image, styles: { large: "600x600>", medium: "300x300>", thumb: "100x100>" }
|
has_attached_file :image, styles: { large: "600x600>", medium: "300x300>", thumb: "100x100>" }
|
||||||
|
|
||||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||||
|
|||||||
@@ -53,8 +53,12 @@
|
|||||||
data: {js_url: suggest_tags_path} %>
|
data: {js_url: suggest_tags_path} %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="budget_investment_image">
|
<div class="small-12 column">
|
||||||
<%= f.file_field :image %>
|
<%= f.file_field :image, accept: 'image/jpeg' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-12 column">
|
||||||
|
<%= f.text_field :image_description %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% unless current_user.manager? %>
|
<% unless current_user.manager? %>
|
||||||
|
|||||||
@@ -2,7 +2,18 @@
|
|||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="small-12 medium-9 column">
|
<!-- TODO: ROCK&ROR: Temporal markup. Place it as needed to reflect mockup -->
|
||||||
|
<div class="small-2 medium-2 large-2 column">
|
||||||
|
<% if investment.image.exists? %>
|
||||||
|
<%= image_tag investment.image.url(:thumb),
|
||||||
|
title: investment.image_description,
|
||||||
|
alt: investment.image_description, class: "th" %>
|
||||||
|
<% else %>
|
||||||
|
<!-- TODO: ROCK&ROR: Create colored placeholder or default image -->
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="small-10 medium-7 large-10 column">
|
||||||
<div class="budget-investment-content">
|
<div class="budget-investment-content">
|
||||||
|
|
||||||
<% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %>
|
<% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %>
|
||||||
@@ -43,12 +54,6 @@
|
|||||||
|
|
||||||
<% unless investment.unfeasible? %>
|
<% unless investment.unfeasible? %>
|
||||||
|
|
||||||
<% if investment.image.exists? %>
|
|
||||||
<div class="small-12 medium-3 column">
|
|
||||||
<%= image_tag investment.image.url(:medium) %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% if investment.should_show_votes? %>
|
<% if investment.should_show_votes? %>
|
||||||
<div id="<%= dom_id(investment) %>_votes"
|
<div id="<%= dom_id(investment) %>_votes"
|
||||||
class="small-12 medium-3 column text-center">
|
class="small-12 medium-3 column text-center">
|
||||||
|
|||||||
@@ -37,8 +37,11 @@
|
|||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<!-- TODO: ROCK&ROR: Markup rework accordingly to mockup definition -->
|
||||||
<% if investment.image.exists? %>
|
<% 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 %>
|
<% end %>
|
||||||
|
|
||||||
<%= render 'shared/tags', taggable: investment %>
|
<%= render 'shared/tags', taggable: investment %>
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ en:
|
|||||||
title: "Title"
|
title: "Title"
|
||||||
location: "Location"
|
location: "Location"
|
||||||
organization_name: "If you are proposing in the name of a collective/organization, write its name"
|
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:
|
budget/investment/milestone:
|
||||||
title: "Title"
|
title: "Title"
|
||||||
description: "Description"
|
description: "Description"
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ es:
|
|||||||
title: "Título"
|
title: "Título"
|
||||||
location: "Ubicación"
|
location: "Ubicación"
|
||||||
organization_name: "Si estás proponiendo en nombre de una organización o colectivo, escribe su nombre"
|
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:
|
comment:
|
||||||
body: "Comentario"
|
body: "Comentario"
|
||||||
user: "Usuario"
|
user: "Usuario"
|
||||||
|
|||||||
@@ -257,10 +257,10 @@ ActiveRecord::Schema.define(version: 20170918231410) do
|
|||||||
t.string "visit_id"
|
t.string "visit_id"
|
||||||
t.datetime "hidden_at"
|
t.datetime "hidden_at"
|
||||||
t.integer "flags_count", default: 0
|
t.integer "flags_count", default: 0
|
||||||
|
t.datetime "ignored_flag_at"
|
||||||
t.integer "cached_votes_total", default: 0
|
t.integer "cached_votes_total", default: 0
|
||||||
t.integer "cached_votes_up", default: 0
|
t.integer "cached_votes_up", default: 0
|
||||||
t.integer "cached_votes_down", default: 0
|
t.integer "cached_votes_down", default: 0
|
||||||
t.datetime "ignored_flag_at"
|
|
||||||
t.integer "comments_count", default: 0
|
t.integer "comments_count", default: 0
|
||||||
t.datetime "confirmed_hide_at"
|
t.datetime "confirmed_hide_at"
|
||||||
t.integer "cached_anonymous_votes_total", default: 0
|
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_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", ["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", ["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", ["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", ["hidden_at"], name: "index_debates_on_hidden_at", using: :btree
|
||||||
add_index "debates", ["hot_score"], name: "index_debates_on_hot_score", 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", ["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", ["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", ["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", ["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", ["hidden_at"], name: "index_proposals_on_hidden_at", using: :btree
|
||||||
add_index "proposals", ["hot_score"], name: "index_proposals_on_hot_score", using: :btree
|
add_index "proposals", ["hot_score"], name: "index_proposals_on_hot_score", using: :btree
|
||||||
|
|||||||
@@ -28,6 +28,21 @@ feature 'Budget Investments' do
|
|||||||
end
|
end
|
||||||
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
|
context("Search") do
|
||||||
|
|
||||||
scenario 'Search by text' do
|
scenario 'Search by text' do
|
||||||
@@ -355,6 +370,16 @@ feature 'Budget Investments' do
|
|||||||
expect(page).not_to have_selector ".js-follow"
|
expect(page).not_to have_selector ".js-follow"
|
||||||
end
|
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
|
scenario "Show back link contains heading id" do
|
||||||
investment = create(:budget_investment, heading: heading)
|
investment = create(:budget_investment, heading: heading)
|
||||||
visit budget_investment_path(budget, investment)
|
visit budget_investment_path(budget, investment)
|
||||||
|
|||||||
Reference in New Issue
Block a user