diff --git a/CHANGELOG.md b/CHANGELOG.md
index 09a2314d7..62b84114b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Deprecated
- Budget's `description_*` columns will be erased from database in next release. Please run rake task `budgets:phases:generate_missing` to migrate them. Details at Warning section of https://github.com/consul/consul/pull/2323
+- Budget::Investment's `internal_comments` attribute usage was removed, because of https://github.com/consul/consul/pull/2403, run rake task `investments:internal_comments:migrate_to_thread` to migrate existing values to the new internal comments thread. In next release database column will be removed.
### Removed
- Spending Proposals urls from sitemap, that model is getting entirely deprecated soon.
diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb
index 643ccbc74..a9064a301 100644
--- a/app/controllers/valuation/budget_investments_controller.rb
+++ b/app/controllers/valuation/budget_investments_controller.rb
@@ -95,7 +95,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
def valuation_params
params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation,
:feasibility, :unfeasibility_explanation,
- :duration, :valuation_finished, :internal_comments)
+ :duration, :valuation_finished)
end
def restrict_access_to_assigned_items
diff --git a/app/views/valuation/budget_investments/_written_by_valuators.html.erb b/app/views/valuation/budget_investments/_written_by_valuators.html.erb
index eb2d0e81d..c4c091389 100644
--- a/app/views/valuation/budget_investments/_written_by_valuators.html.erb
+++ b/app/views/valuation/budget_investments/_written_by_valuators.html.erb
@@ -47,11 +47,6 @@
<% end %>
-<% if @investment.internal_comments.present? %>
- <%= t("valuation.budget_investments.show.internal_comments") %>
- <%= explanation_field @investment.internal_comments %>
-<% end %>
-
-
-
- <%= f.label :internal_comments, t("valuation.budget_investments.edit.internal_comments_html") %>
- <%= f.text_area :internal_comments, label: false, rows: 3 %>
-
-
-
<%= f.submit(class: "button expanded large", value: t("valuation.budget_investments.edit.save")) %>
diff --git a/config/locales/en/valuation.yml b/config/locales/en/valuation.yml
index d1c267305..fa53a432c 100644
--- a/config/locales/en/valuation.yml
+++ b/config/locales/en/valuation.yml
@@ -53,7 +53,6 @@ en:
undefined: Undefined
valuation_finished: Valuation finished
duration: Time scope
- internal_comments: Internal comments
responsibles: Responsibles
assigned_admin: Assigned admin
assigned_valuators: Assigned valuators
@@ -71,7 +70,6 @@ en:
valuation_finished_alert: "Are you sure you want to mark this report as completed? If you do it, it can no longer be modified."
not_feasible_alert: "An email will be sent immediately to the author of the project with the report of unfeasibility."
duration_html: Time scope
- internal_comments_html: Internal comments
save: Save changes
notice:
valuate: "Dossier updated"
diff --git a/config/locales/es/valuation.yml b/config/locales/es/valuation.yml
index 15c0c6d2c..9ddb2d009 100644
--- a/config/locales/es/valuation.yml
+++ b/config/locales/es/valuation.yml
@@ -53,7 +53,6 @@ es:
undefined: Sin definir
valuation_finished: Informe finalizado
duration: Plazo de ejecución
- internal_comments: Comentarios internos
responsibles: Responsables
assigned_admin: Administrador asignado
assigned_valuators: Evaluadores asignados
@@ -71,7 +70,6 @@ es:
valuation_finished_alert: "¿Estás seguro/a de querer marcar este informe como completado? Una vez hecho, no se puede deshacer la acción."
not_feasible_alert: "Un email será enviado inmediatamente al autor del proyecto con el informe de inviabilidad."
duration_html: Plazo de ejecución (opcional, dato no público)
- internal_comments_html: Comentarios y observaciones (para responsables internos, dato no público)
save: Guardar Cambios
notice:
valuate: "Dossier actualizado"
diff --git a/lib/tasks/investments.rake b/lib/tasks/investments.rake
new file mode 100644
index 000000000..f9619b5ed
--- /dev/null
+++ b/lib/tasks/investments.rake
@@ -0,0 +1,12 @@
+namespace :investments do
+ namespace :internal_comments do
+ desc "Migrate internal_comments textarea to a first comment on internal thread"
+ task migrate_to_thread: :environment do
+ comments_author_id = Administrator.first.user.id
+ Budget::Investment.where.not(internal_comments: [nil, '']).find_each do |investment|
+ Comment.create(commentable: investment, user_id: comments_author_id,
+ body: investment.internal_comments, valuation: true)
+ end
+ end
+ end
+end
diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb
index 91bf20985..7d8d1bfd5 100644
--- a/spec/features/valuation/budget_investments_spec.rb
+++ b/spec/features/valuation/budget_investments_spec.rb
@@ -234,7 +234,6 @@ feature 'Valuation budget investments' do
within('#duration') { expect(page).to have_content('Undefined') }
within('#feasibility') { expect(page).to have_content('Undecided') }
expect(page).not_to have_content('Valuation finished')
- expect(page).not_to have_content('Internal comments')
end
scenario 'Edit dossier' do
@@ -248,7 +247,6 @@ feature 'Valuation budget investments' do
fill_in 'budget_investment_price_explanation', with: 'Very cheap idea'
choose 'budget_investment_feasibility_feasible'
fill_in 'budget_investment_duration', with: '19 months'
- fill_in 'budget_investment_internal_comments', with: 'Should be double checked by the urbanism area'
click_button 'Save changes'
expect(page).to have_content "Dossier updated"
@@ -262,8 +260,6 @@ feature 'Valuation budget investments' do
within('#duration') { expect(page).to have_content('19 months') }
within('#feasibility') { expect(page).to have_content('Feasible') }
expect(page).not_to have_content('Valuation finished')
- expect(page).to have_content('Internal comments')
- expect(page).to have_content('Should be double checked by the urbanism area')
end
scenario 'Feasibility can be marked as pending' do
@@ -289,7 +285,7 @@ feature 'Valuation budget investments' do
scenario 'Feasibility selection makes proper fields visible', :js do
feasible_fields = ['Price (€)', 'Cost during the first year (€)', 'Price explanation', 'Time scope']
unfeasible_fields = ['Feasibility explanation']
- any_feasibility_fields = ['Valuation finished', 'Internal comments']
+ any_feasibility_fields = ['Valuation finished']
undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields
visit edit_valuation_budget_budget_investment_path(@budget, @investment)