Rename image_description column to image_title on budget investments.

This commit is contained in:
Senén Rodero Rodríguez
2017-06-20 13:28:50 +02:00
parent 673fc66011
commit 515d6d7e70
12 changed files with 24 additions and 19 deletions

View File

@@ -108,7 +108,7 @@ module Budgets
params.require(:budget_investment)
.permit(:title, :description, :external_url, :heading_id,
:tag_list, :organization_name, :location, :terms_of_service,
:image, :image_description,
:image, :image_title,
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id])
end

View File

@@ -42,8 +42,8 @@ class Budget
validates :description, length: { maximum: Budget::Investment.description_max_length }
validates :terms_of_service, acceptance: { allow_nil: false }, on: :create
validates_attachment :image, content_type: { content_type: ["image/jpeg"] }
validates :image_description, presence: true, if: -> { image.present? }
validates :image_description, length: { in: 4..Budget::Investment.title_max_length }, if: -> { image.present? }
validates :image_title, presence: true, if: -> { image.present? }
validates :image_title, length: { in: 4..Budget::Investment.title_max_length }, if: -> { image.present? }
scope :sort_by_confidence_score, -> { reorder(confidence_score: :desc, id: :desc) }
scope :sort_by_ballots, -> { reorder(ballot_lines_count: :desc, id: :desc) }

View File

@@ -58,7 +58,7 @@
</div>
<div class="small-12 column">
<%= f.text_field :image_description %>
<%= f.text_field :image_title %>
</div>
<% unless current_user.manager? %>

View File

@@ -6,8 +6,8 @@
<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" %>
title: investment.image_title,
alt: investment.image_title, class: "th" %>
<% else %>
<!-- TODO: ROCK&ROR: Create colored placeholder or default image -->
<% end %>

View File

@@ -40,8 +40,8 @@
<!-- TODO: ROCK&ROR: Markup rework accordingly to mockup definition -->
<% if investment.image.exists? %>
<%= image_tag investment.image.url(:medium),
title: investment.image_description,
alt: investment.image_description %>
title: investment.image_title,
alt: investment.image_title %>
<% end %>
<%= render 'shared/tags', taggable: investment %>

View File

@@ -105,7 +105,7 @@ en:
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"
image_title: "Image description"
budget/investment/milestone:
title: "Title"
description: "Description"

View File

@@ -100,7 +100,7 @@ es:
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"
image_title: "Texto descriptivo de la imagen"
comment:
body: "Comentario"
user: "Usuario"

View File

@@ -0,0 +1,5 @@
class RenameImageDescriptionToImageTitleOnBudgetInvestments < ActiveRecord::Migration
def change
rename_column :budget_investments, :image_description, :image_title
end
end

View File

@@ -165,7 +165,7 @@ ActiveRecord::Schema.define(version: 20170918231410) do
t.string "image_content_type"
t.integer "image_file_size"
t.datetime "image_updated_at"
t.string "image_description"
t.string "image_title"
end
add_index "budget_investments", ["administrator_id"], name: "index_budget_investments_on_administrator_id", using: :btree

View File

@@ -321,7 +321,7 @@ FactoryGirl.define do
trait :with_descriptive_image do
image { File.new("spec/fixtures/files/logo_header.jpg") }
image_description "Lorem ipsum dolor sit amet"
image_title "Lorem ipsum dolor sit amet"
end
end

View File

@@ -39,7 +39,7 @@ feature 'Budget Investments' do
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}']")
expect(page).to have_css("img.th[alt='#{investment_with_image.image_title}'][title='#{investment_with_image.image_title}']")
end
end
@@ -377,7 +377,7 @@ feature 'Budget Investments' do
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}']")
expect(page).to have_css("img[alt='#{investment_with_image.image_title}'][title='#{investment_with_image.image_title}']")
end
scenario "Show back link contains heading id" do

View File

@@ -58,27 +58,27 @@ describe Budget::Investment do
describe "description" do
it "should be valid when image and image_description are not defined" do
it "should be valid when image and image_title are not defined" do
investment_with_image.image = nil
investment_with_image.image_description = nil
investment_with_image.image_title = nil
expect(investment_with_image).to be_valid
end
it "should not be valid when correct image attached but no image description provided" do
investment_with_image.image_description = ''
investment_with_image.image_title = ''
expect(investment_with_image).to_not be_valid
end
it "should not be valid when image description is too short" do
investment_with_image.image_description = 'a'*3
investment_with_image.image_title = 'a'*3
expect(investment_with_image).to_not be_valid
end
it "should not be valid when image description is too long" do
investment_with_image.image_description = 'a'*81
investment_with_image.image_title = 'a'*81
expect(investment_with_image).to_not be_valid
end