From 515d6d7e701c36575c84bb26e77f5b80fc16c6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Tue, 20 Jun 2017 13:28:50 +0200 Subject: [PATCH] Rename image_description column to image_title on budget investments. --- app/controllers/budgets/investments_controller.rb | 2 +- app/models/budget/investment.rb | 4 ++-- app/views/budgets/investments/_form.html.erb | 2 +- app/views/budgets/investments/_investment.html.erb | 4 ++-- .../budgets/investments/_investment_show.html.erb | 4 ++-- config/locales/en/activerecord.yml | 2 +- config/locales/es/activerecord.yml | 2 +- ...description_to_image_title_on_budget_investments.rb | 5 +++++ db/schema.rb | 2 +- spec/factories.rb | 2 +- spec/features/budgets/investments_spec.rb | 4 ++-- spec/models/budget/investment_spec.rb | 10 +++++----- 12 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 db/migrate/20170620105137_rename_image_description_to_image_title_on_budget_investments.rb diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index b3ed6022a..b0f0da189 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -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 diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 29e09a55d..ada8e986a 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -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) } diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index 2d0fa488a..1d6a12903 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -58,7 +58,7 @@
- <%= f.text_field :image_description %> + <%= f.text_field :image_title %>
<% unless current_user.manager? %> diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb index 2290b1d81..46732d1d9 100644 --- a/app/views/budgets/investments/_investment.html.erb +++ b/app/views/budgets/investments/_investment.html.erb @@ -6,8 +6,8 @@
<% 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 %> <% end %> diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index ee7532afd..d00f9fc38 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -40,8 +40,8 @@ <% 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 %> diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml index 87864229e..0c0cbd740 100644 --- a/config/locales/en/activerecord.yml +++ b/config/locales/en/activerecord.yml @@ -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" diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml index 4bff6f5a9..e362c8b7b 100644 --- a/config/locales/es/activerecord.yml +++ b/config/locales/es/activerecord.yml @@ -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" diff --git a/db/migrate/20170620105137_rename_image_description_to_image_title_on_budget_investments.rb b/db/migrate/20170620105137_rename_image_description_to_image_title_on_budget_investments.rb new file mode 100644 index 000000000..20734a348 --- /dev/null +++ b/db/migrate/20170620105137_rename_image_description_to_image_title_on_budget_investments.rb @@ -0,0 +1,5 @@ +class RenameImageDescriptionToImageTitleOnBudgetInvestments < ActiveRecord::Migration + def change + rename_column :budget_investments, :image_description, :image_title + end +end diff --git a/db/schema.rb b/db/schema.rb index 816648ac9..6fb359fee 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 diff --git a/spec/factories.rb b/spec/factories.rb index 647aeec5b..5cbbd26aa 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -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 diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 2cd4bd4ff..03755028b 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -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 diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 2b770f573..04acef461 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -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