<%= milestone.title %>
-
- <%= t("budgets.investments.show.milestone_publish_date", publish_date: l(milestone.created_at.to_date)) %>
-
- <%= image_tag(milestone.image_url(:large), {alt: milestone.image.title, class: "margin", id: "image_#{milestone.id}"}) if milestone.image.present? %>
+ <% if milestone.publication_date.present? %>
+
+ <%= t("budgets.investments.show.milestone_publication_date",
+ publication_date: l(milestone.publication_date.to_date)) %>
+
+ <% end %>
+ <%= image_tag(milestone.image_url(:large), { alt: milestone.image.title, class: "margin", id: "image_#{milestone.id}" }) if milestone.image.present? %>
<%= milestone.description %>
<% if milestone.documents.present? %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index 89befa33b..f3952aaca 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -124,6 +124,7 @@ en:
budget/investment/milestone:
title: "Title"
description: "Description"
+ publication_date: "Publication date"
comment:
body: "Comment"
user: "User"
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml
index b53deffd7..071d9c6a4 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -193,6 +193,7 @@ en:
table_id: "ID"
table_title: "Title"
table_description: "Description"
+ table_publication_date: "Publication date"
table_actions: "Actions"
delete: "Delete milestone"
no_milestones: "Don't have defined milestones"
@@ -1079,4 +1080,4 @@ en:
updated_at: Updated at
status_draft: Draft
status_published: Published
- locale: Language
\ No newline at end of file
+ locale: Language
diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml
index ac6445329..3710daf8a 100644
--- a/config/locales/en/budgets.yml
+++ b/config/locales/en/budgets.yml
@@ -110,7 +110,7 @@ en:
comments_tab: Comments
milestones_tab: Milestones
no_milestones: Don't have defined milestones
- milestone_publish_date: "Published %{publish_date}"
+ milestone_publication_date: "Published %{publication_date}"
wrong_price_format: Only integer numbers
investment:
add: Vote
@@ -151,4 +151,4 @@ en:
amount_available: Available budget
accepted: "Accepted spending proposal: "
discarded: "Discarded spending proposal: "
- incompatibles: Incompatibles
\ No newline at end of file
+ incompatibles: Incompatibles
diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml
index 16885db63..fe3ae694c 100644
--- a/config/locales/es/activerecord.yml
+++ b/config/locales/es/activerecord.yml
@@ -119,6 +119,7 @@ es:
budget/investment/milestone:
title: "Título"
description: "Descripción"
+ publication_date: "Fecha de publicación"
comment:
body: "Comentario"
user: "Usuario"
@@ -287,4 +288,4 @@ es:
record_invalid: "La validación falló: %{errors}"
restrict_dependent_destroy:
has_one: No se puede eliminar el registro porque existe un %{record} dependiente
- has_many: No se puede eliminar el registro porque existen %{record} dependientes
\ No newline at end of file
+ has_many: No se puede eliminar el registro porque existen %{record} dependientes
diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml
index d7f55a83c..688d878e1 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -193,6 +193,7 @@ es:
table_id: "ID"
table_title: "Título"
table_description: "Descripción"
+ table_publication_date: "Fecha de publicación"
table_actions: "Acciones"
delete: "Eliminar hito"
no_milestones: "No hay hitos definidos"
diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml
index e3e92fe52..367bcecdc 100644
--- a/config/locales/es/budgets.yml
+++ b/config/locales/es/budgets.yml
@@ -110,7 +110,7 @@ es:
comments_tab: Comentarios
milestones_tab: Seguimiento
no_milestones: No hay hitos definidos
- milestone_publish_date: "Publicado el %{publish_date}"
+ milestone_publication_date: "Publicado el %{publication_date}"
wrong_price_format: Solo puede incluir caracteres numéricos
investment:
add: Votar
diff --git a/db/migrate/20171212154048_add_publication_date_to_milestones.rb b/db/migrate/20171212154048_add_publication_date_to_milestones.rb
new file mode 100644
index 000000000..e5e37bb24
--- /dev/null
+++ b/db/migrate/20171212154048_add_publication_date_to_milestones.rb
@@ -0,0 +1,13 @@
+class AddPublicationDateToMilestones < ActiveRecord::Migration
+ def up
+ change_table :budget_investment_milestones do |t|
+ t.datetime :publication_date
+ end
+ end
+
+ def down
+ change_table :budget_investment_milestones do |t|
+ t.remove :publication_date
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b9bfe1c21..c3e107aae 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -119,10 +119,11 @@ ActiveRecord::Schema.define(version: 20171212193323) do
create_table "budget_investment_milestones", force: :cascade do |t|
t.integer "investment_id"
- t.string "title", limit: 80
+ t.string "title", limit: 80
t.text "description"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.datetime "publication_date"
end
create_table "budget_investments", force: :cascade do |t|
diff --git a/spec/factories.rb b/spec/factories.rb
index 42bc57fd5..f7b68dd3c 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -362,6 +362,7 @@ FactoryGirl.define do
association :investment, factory: :budget_investment
sequence(:title) { |n| "Budget investment milestone #{n} title" }
description 'Milestone description'
+ publication_date Time.zone.today
end
factory :vote do
diff --git a/spec/features/admin/budget_investment_milestones_spec.rb b/spec/features/admin/budget_investment_milestones_spec.rb
index 7ea460c96..0b198f6ab 100644
--- a/spec/features/admin/budget_investment_milestones_spec.rb
+++ b/spec/features/admin/budget_investment_milestones_spec.rb
@@ -20,6 +20,7 @@ feature 'Admin budget investment milestones' do
expect(page).to have_content("Milestone")
expect(page).to have_content(milestone.title)
expect(page).to have_content(milestone.id)
+ expect(page).to have_content(milestone.publication_date.to_date)
expect(page).to have_link 'Show image'
expect(page).to have_link document.title
end
@@ -40,11 +41,13 @@ feature 'Admin budget investment milestones' do
fill_in 'budget_investment_milestone_title', with: 'New title milestone'
fill_in 'budget_investment_milestone_description', with: 'New description milestone'
+ fill_in 'budget_investment_milestone_publication_date', with: Time.zone.today.to_date
click_button 'Create milestone'
expect(page).to have_content 'New title milestone'
expect(page).to have_content 'New description milestone'
+ expect(page).to have_content Time.zone.today.to_date
end
scenario "Show validation errors on milestone form" do
@@ -57,7 +60,7 @@ feature 'Admin budget investment milestones' do
click_button 'Create milestone'
within "#new_budget_investment_milestone" do
- expect(page).to have_content "can't be blank"
+ expect(page).to have_content "can't be blank", count: 2
expect(page).to have_content 'New description milestone'
end
end
@@ -78,12 +81,14 @@ feature 'Admin budget investment milestones' do
fill_in 'budget_investment_milestone_title', with: 'Changed title'
fill_in 'budget_investment_milestone_description', with: 'Changed description'
+ fill_in 'budget_investment_milestone_publication_date', with: Time.zone.today.to_date
fill_in 'budget_investment_milestone_documents_attributes_0_title', with: 'New document title'
click_button 'Update milestone'
expect(page).to have_content 'Changed title'
expect(page).to have_content 'Changed description'
+ expect(page).to have_content Time.zone.today.to_date
expect(page).to have_link 'Show image'
expect(page).to have_link 'New document title'
end
diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb
index 9338ba9e3..dc0fd4feb 100644
--- a/spec/features/budgets/investments_spec.rb
+++ b/spec/features/budgets/investments_spec.rb
@@ -501,8 +501,7 @@ feature 'Budget Investments' do
scenario "Show milestones", :js do
user = create(:user)
investment = create(:budget_investment)
- milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show",
- created_at: DateTime.new(2015, 9, 19).utc)
+ milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show")
image = create(:image, imageable: milestone)
document = create(:document, documentable: milestone)
@@ -514,7 +513,7 @@ feature 'Budget Investments' do
within("#tab-milestones") do
expect(page).to have_content(milestone.title)
expect(page).to have_content(milestone.description)
- expect(page).to have_content("Published 2015-09-19")
+ expect(page).to have_content(Time.zone.today.to_date)
expect(page.find("#image_#{milestone.id}")['alt']).to have_content image.title
expect(page).to have_link document.title
end