diff --git a/app/controllers/admin/budget_investment_milestones_controller.rb b/app/controllers/admin/budget_investment_milestones_controller.rb
index 49f2df5bf..f63fee025 100644
--- a/app/controllers/admin/budget_investment_milestones_controller.rb
+++ b/app/controllers/admin/budget_investment_milestones_controller.rb
@@ -46,8 +46,8 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
def milestone_params
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
- attributes = [:title, :description, :publication_date, :budget_investment_id, :status_id,
- *translation_params(Budget::Investment::Milestone),
+ attributes = [:publication_date, :budget_investment_id, :status_id,
+ translation_params(Budget::Investment::Milestone),
image_attributes: image_attributes, documents_attributes: documents_attributes]
params.require(:budget_investment_milestone).permit(*attributes)
diff --git a/app/models/budget/investment/milestone.rb b/app/models/budget/investment/milestone.rb
index 1790f7323..84b312867 100644
--- a/app/models/budget/investment/milestone.rb
+++ b/app/models/budget/investment/milestone.rb
@@ -9,11 +9,11 @@ class Budget
translates :title, :description, touch: true
globalize_accessors
+ accepts_nested_attributes_for :translations, allow_destroy: true
belongs_to :investment
belongs_to :status, class_name: 'Budget::Investment::Status'
- validates :title, presence: true
validates :investment, presence: true
validates :publication_date, presence: true
validate :description_or_status_present?
diff --git a/app/views/admin/budget_investment_milestones/_form.html.erb b/app/views/admin/budget_investment_milestones/_form.html.erb
index ab3ee6cf6..8b335e29a 100644
--- a/app/views/admin/budget_investment_milestones/_form.html.erb
+++ b/app/views/admin/budget_investment_milestones/_form.html.erb
@@ -2,9 +2,6 @@
<%= translatable_form_for [:admin, @investment.budget, @investment, @milestone] do |f| %>
- <%= f.hidden_field :title, value: l(Time.current, format: :datetime),
- maxlength: Budget::Investment::Milestone.title_max_length %>
-
<%= f.select :status_id,
@statuses.collect { |s| [s.name, s.id] },
@@ -14,9 +11,14 @@
admin_budget_investment_statuses_path %>
- <%= f.translatable_text_area :description,
- rows: 5,
- label: t("admin.milestones.new.description") %>
+ <%= f.translatable_fields do |translations_form| %>
+ <%= translations_form.hidden_field :title, value: l(Time.current, format: :datetime),
+ maxlength: Budget::Investment::Milestone.title_max_length %>
+
+ <%= translations_form.text_area :description,
+ rows: 5,
+ label: t("admin.milestones.new.description") %>
+ <% end %>
<%= f.label :publication_date, t("admin.milestones.new.date") %>
<%= f.text_field :publication_date,
diff --git a/spec/features/admin/budget_investment_milestones_spec.rb b/spec/features/admin/budget_investment_milestones_spec.rb
index 3b2777792..35ed69089 100644
--- a/spec/features/admin/budget_investment_milestones_spec.rb
+++ b/spec/features/admin/budget_investment_milestones_spec.rb
@@ -47,7 +47,7 @@ feature 'Admin budget investment milestones' do
click_link 'Create new milestone'
select status.name, from: 'budget_investment_milestone_status_id'
- fill_in 'budget_investment_milestone_description_en', with: 'New description milestone'
+ fill_in 'Description', with: 'New description milestone'
fill_in 'budget_investment_milestone_publication_date', with: Date.current
click_button 'Create milestone'
@@ -69,7 +69,7 @@ feature 'Admin budget investment milestones' do
click_link 'Create new milestone'
- fill_in 'budget_investment_milestone_description_en', with: 'New description milestone'
+ fill_in 'Description', with: 'New description milestone'
click_button 'Create milestone'
@@ -93,7 +93,7 @@ feature 'Admin budget investment milestones' do
expect(page).to have_css("img[alt='#{milestone.image.title}']")
- fill_in 'budget_investment_milestone_description_en', with: 'Changed description'
+ fill_in 'Description', with: 'Changed description'
fill_in 'budget_investment_milestone_publication_date', with: Date.current
fill_in 'budget_investment_milestone_documents_attributes_0_title', with: 'New document title'
diff --git a/spec/models/budget/investment/milestone_spec.rb b/spec/models/budget/investment/milestone_spec.rb
index ad844865d..59cbe1a68 100644
--- a/spec/models/budget/investment/milestone_spec.rb
+++ b/spec/models/budget/investment/milestone_spec.rb
@@ -9,9 +9,9 @@ describe Budget::Investment::Milestone do
expect(milestone).to be_valid
end
- it "is not valid without a title" do
+ it "is valid without a title" do
milestone.title = nil
- expect(milestone).not_to be_valid
+ expect(milestone).to be_valid
end
it "is not valid without a description if status is empty" do