diff --git a/Rakefile b/Rakefile index 13a99536b..c4d34f626 100644 --- a/Rakefile +++ b/Rakefile @@ -3,5 +3,5 @@ require File.expand_path('../config/application', __FILE__) -Rails.application.load_tasks +Rails.application.load_tasks if Rake::Task.tasks.empty? KnapsackPro.load_tasks if defined?(KnapsackPro) diff --git a/app/controllers/admin/budget_investment_milestones_controller.rb b/app/controllers/admin/budget_investment_milestones_controller.rb index f63fee025..23ef679cc 100644 --- a/app/controllers/admin/budget_investment_milestones_controller.rb +++ b/app/controllers/admin/budget_investment_milestones_controller.rb @@ -2,19 +2,19 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController include Translatable before_action :load_budget_investment, only: [:index, :new, :create, :edit, :update, :destroy] - before_action :load_budget_investment_milestone, only: [:edit, :update, :destroy] + before_action :load_milestone, only: [:edit, :update, :destroy] before_action :load_statuses, only: [:index, :new, :create, :edit, :update] def index end def new - @milestone = Budget::Investment::Milestone.new + @milestone = Milestone.new end def create - @milestone = Budget::Investment::Milestone.new(milestone_params) - @milestone.investment = @investment + @milestone = Milestone.new(milestone_params) + @milestone.milestoneable = @investment if @milestone.save redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.create.notice') @@ -47,22 +47,22 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy] attributes = [:publication_date, :budget_investment_id, :status_id, - translation_params(Budget::Investment::Milestone), + translation_params(Milestone), image_attributes: image_attributes, documents_attributes: documents_attributes] - params.require(:budget_investment_milestone).permit(*attributes) + params.require(:milestone).permit(*attributes) end def load_budget_investment @investment = Budget::Investment.find(params[:budget_investment_id]) end - def load_budget_investment_milestone + def load_milestone @milestone = get_milestone end def get_milestone - Budget::Investment::Milestone.find(params[:id]) + Milestone.find(params[:id]) end def resource @@ -70,7 +70,7 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController end def load_statuses - @statuses = Budget::Investment::Status.all + @statuses = Milestone::Status.all end end diff --git a/app/controllers/admin/budget_investment_statuses_controller.rb b/app/controllers/admin/milestone_statuses_controller.rb similarity index 52% rename from app/controllers/admin/budget_investment_statuses_controller.rb rename to app/controllers/admin/milestone_statuses_controller.rb index c3d7a4e16..18c573ab3 100644 --- a/app/controllers/admin/budget_investment_statuses_controller.rb +++ b/app/controllers/admin/milestone_statuses_controller.rb @@ -1,20 +1,20 @@ -class Admin::BudgetInvestmentStatusesController < Admin::BaseController +class Admin::MilestoneStatusesController < Admin::BaseController before_action :load_status, only: [:edit, :update, :destroy] def index - @statuses = Budget::Investment::Status.all + @statuses = Milestone::Status.all end def new - @status = Budget::Investment::Status.new + @status = Milestone::Status.new end def create - @status = Budget::Investment::Status.new(status_params) + @status = Milestone::Status.new(status_params) if @status.save - redirect_to admin_budget_investment_statuses_path, + redirect_to admin_milestone_statuses_path, notice: t('admin.statuses.create.notice') else render :new @@ -26,7 +26,7 @@ class Admin::BudgetInvestmentStatusesController < Admin::BaseController def update if @status.update(status_params) - redirect_to admin_budget_investment_statuses_path, + redirect_to admin_milestone_statuses_path, notice: t('admin.statuses.update.notice') else render :edit @@ -35,17 +35,17 @@ class Admin::BudgetInvestmentStatusesController < Admin::BaseController def destroy @status.destroy - redirect_to admin_budget_investment_statuses_path, + redirect_to admin_milestone_statuses_path, notice: t('admin.statuses.delete.notice') end private def load_status - @status = Budget::Investment::Status.find(params[:id]) + @status = Milestone::Status.find(params[:id]) end def status_params - params.require(:budget_investment_status).permit([:name, :description]) + params.require(:milestone_status).permit([:name, :description]) end end diff --git a/app/controllers/budgets/executions_controller.rb b/app/controllers/budgets/executions_controller.rb index b321c4377..e17763090 100644 --- a/app/controllers/budgets/executions_controller.rb +++ b/app/controllers/budgets/executions_controller.rb @@ -6,7 +6,7 @@ module Budgets def show authorize! :read_executions, @budget - @statuses = ::Budget::Investment::Status.all + @statuses = Milestone::Status.all if params[:status].present? @investments_by_heading = @budget.investments.winners diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 486e65052..4143300eb 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -24,6 +24,7 @@ class Budget include Notifiable include Filterable include Flaggable + include Milestoneable belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :heading @@ -40,8 +41,6 @@ class Budget has_many :comments, -> {where(valuation: false)}, as: :commentable, class_name: 'Comment' has_many :valuations, -> {where(valuation: true)}, as: :commentable, class_name: 'Comment' - has_many :milestones - validates :title, presence: true validates :author, presence: true validates :description, presence: true diff --git a/app/models/budget/investment/milestone.rb b/app/models/budget/investment/milestone.rb deleted file mode 100644 index f59705ede..000000000 --- a/app/models/budget/investment/milestone.rb +++ /dev/null @@ -1,35 +0,0 @@ -class Budget - class Investment - class Milestone < ActiveRecord::Base - include Imageable - include Documentable - documentable max_documents_allowed: 3, - max_file_size: 3.megabytes, - accepted_content_types: [ "application/pdf" ] - - translates :title, :description, touch: true - include Globalizable - - belongs_to :investment - belongs_to :status, class_name: 'Budget::Investment::Status' - - validates :investment, presence: true - validates :publication_date, presence: true - validate :description_or_status_present? - - scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) } - scope :published, -> { where("publication_date <= ?", Date.current) } - scope :with_status, -> { where("status_id IS NOT NULL") } - - def self.title_max_length - 80 - end - - def description_or_status_present? - unless description.present? || status_id.present? - errors.add(:description) - end - end - end - end -end diff --git a/app/models/concerns/milestoneable.rb b/app/models/concerns/milestoneable.rb new file mode 100644 index 000000000..7bae4a61a --- /dev/null +++ b/app/models/concerns/milestoneable.rb @@ -0,0 +1,7 @@ +module Milestoneable + extend ActiveSupport::Concern + + included do + has_many :milestones, as: :milestoneable, dependent: :destroy + end +end diff --git a/app/models/milestone.rb b/app/models/milestone.rb new file mode 100644 index 000000000..1b4790040 --- /dev/null +++ b/app/models/milestone.rb @@ -0,0 +1,31 @@ +class Milestone < ActiveRecord::Base + include Imageable + include Documentable + documentable max_documents_allowed: 3, + max_file_size: 3.megabytes, + accepted_content_types: [ "application/pdf" ] + + translates :title, :description, touch: true + include Globalizable + + belongs_to :milestoneable, polymorphic: true + belongs_to :status + + validates :milestoneable, presence: true + validates :publication_date, presence: true + validate :description_or_status_present? + + scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) } + scope :published, -> { where("publication_date <= ?", Date.current) } + scope :with_status, -> { where("status_id IS NOT NULL") } + + def self.title_max_length + 80 + end + + def description_or_status_present? + unless description.present? || status_id.present? + errors.add(:description) + end + end +end diff --git a/app/models/budget/investment/status.rb b/app/models/milestone/status.rb similarity index 65% rename from app/models/budget/investment/status.rb rename to app/models/milestone/status.rb index df2b991ba..51b03427d 100644 --- a/app/models/budget/investment/status.rb +++ b/app/models/milestone/status.rb @@ -1,4 +1,4 @@ -class Budget::Investment::Status < ActiveRecord::Base +class Milestone::Status < ActiveRecord::Base acts_as_paranoid column: :hidden_at has_many :milestones diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 911bc0713..902c8261e 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -57,7 +57,7 @@ <% if feature?(:budgets) %>
  • "> + controller_name == "milestone_statuses" %>"> <%= link_to admin_budgets_path do %> <%= t("admin.menu.budgets") %> diff --git a/app/views/admin/budget_investment_milestones/_form.html.erb b/app/views/admin/budget_investment_milestones/_form.html.erb index 8b335e29a..c62ba3521 100644 --- a/app/views/admin/budget_investment_milestones/_form.html.erb +++ b/app/views/admin/budget_investment_milestones/_form.html.erb @@ -8,12 +8,12 @@ { include_blank: @statuses.any? ? '' : t('admin.milestones.form.no_statuses_defined') }, { disabled: @statuses.blank? } %> <%= link_to t('admin.milestones.form.admin_statuses'), - admin_budget_investment_statuses_path %> + admin_milestone_statuses_path %> <%= f.translatable_fields do |translations_form| %> <%= translations_form.hidden_field :title, value: l(Time.current, format: :datetime), - maxlength: Budget::Investment::Milestone.title_max_length %> + maxlength: Milestone.title_max_length %> <%= translations_form.text_area :description, rows: 5, diff --git a/app/views/admin/budget_investment_statuses/edit.html.erb b/app/views/admin/budget_investment_statuses/edit.html.erb deleted file mode 100644 index e54bfcb08..000000000 --- a/app/views/admin/budget_investment_statuses/edit.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%= back_link_to admin_budget_investment_statuses_path %> - -

    <%= t("admin.statuses.edit.title") %>

    - -<%= render '/admin/budget_investment_statuses/form' %> diff --git a/app/views/admin/budget_investment_statuses/new.html.erb b/app/views/admin/budget_investment_statuses/new.html.erb deleted file mode 100644 index 336b41238..000000000 --- a/app/views/admin/budget_investment_statuses/new.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%= back_link_to admin_budget_investment_statuses_path %> - -

    <%= t("admin.statuses.new.title") %>

    - -<%= render '/admin/budget_investment_statuses/form' %> diff --git a/app/views/admin/budget_investments/_milestones.html.erb b/app/views/admin/budget_investments/_milestones.html.erb index 757fb97e4..20a870d71 100644 --- a/app/views/admin/budget_investments/_milestones.html.erb +++ b/app/views/admin/budget_investments/_milestones.html.erb @@ -18,7 +18,7 @@ <%= milestone.id %> <%= link_to milestone.title, - edit_admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, + edit_admin_budget_budget_investment_milestone_path(@investment.budget, @investment, milestone) %> @@ -46,7 +46,7 @@ <%= link_to t("admin.milestones.index.delete"), - admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, + admin_budget_budget_investment_milestone_path(@investment.budget, @investment, milestone), method: :delete, diff --git a/app/views/admin/budget_investments/show.html.erb b/app/views/admin/budget_investments/show.html.erb index f9e7dc88e..cb44745a1 100644 --- a/app/views/admin/budget_investments/show.html.erb +++ b/app/views/admin/budget_investments/show.html.erb @@ -63,6 +63,6 @@

    <%= link_to t("admin.budget_investments.show.new_milestone"), - new_admin_budget_budget_investment_budget_investment_milestone_path(@budget, @investment), + new_admin_budget_budget_investment_milestone_path(@budget, @investment), class: "button hollow" %>

    diff --git a/app/views/admin/budget_investment_statuses/_form.html.erb b/app/views/admin/milestone_statuses/_form.html.erb similarity index 100% rename from app/views/admin/budget_investment_statuses/_form.html.erb rename to app/views/admin/milestone_statuses/_form.html.erb diff --git a/app/views/admin/milestone_statuses/edit.html.erb b/app/views/admin/milestone_statuses/edit.html.erb new file mode 100644 index 000000000..78df3f184 --- /dev/null +++ b/app/views/admin/milestone_statuses/edit.html.erb @@ -0,0 +1,5 @@ +<%= back_link_to admin_milestone_statuses_path %> + +

    <%= t("admin.statuses.edit.title") %>

    + +<%= render '/admin/milestone_statuses/form' %> diff --git a/app/views/admin/budget_investment_statuses/index.html.erb b/app/views/admin/milestone_statuses/index.html.erb similarity index 80% rename from app/views/admin/budget_investment_statuses/index.html.erb rename to app/views/admin/milestone_statuses/index.html.erb index f41a730cc..45c1e96a9 100644 --- a/app/views/admin/budget_investment_statuses/index.html.erb +++ b/app/views/admin/milestone_statuses/index.html.erb @@ -1,7 +1,7 @@

    <%= t("admin.statuses.index.title") %>

    <%= link_to t("admin.statuses.index.new_status"), - new_admin_budget_investment_status_path, + new_admin_milestone_status_path, class: "button float-right margin-right" %> <% if @statuses.any? %> @@ -15,7 +15,7 @@ <% @statuses.each do |status| %> - + <%= status.name %> @@ -24,10 +24,10 @@ <%= link_to t("admin.statuses.index.edit"), - edit_admin_budget_investment_status_path(status), + edit_admin_milestone_status_path(status), method: :get, class: "button hollow" %> <%= link_to t("admin.statuses.index.delete"), - admin_budget_investment_status_path(status), + admin_milestone_status_path(status), method: :delete, class: "button hollow alert" %> diff --git a/app/views/admin/milestone_statuses/new.html.erb b/app/views/admin/milestone_statuses/new.html.erb new file mode 100644 index 000000000..6ab1f841c --- /dev/null +++ b/app/views/admin/milestone_statuses/new.html.erb @@ -0,0 +1,5 @@ +<%= back_link_to admin_milestone_statuses_path %> + +

    <%= t("admin.statuses.new.title") %>

    + +<%= render '/admin/milestone_statuses/form' %> diff --git a/config/initializers/routes_hierarchy.rb b/config/initializers/routes_hierarchy.rb index f06acf5c9..e9892ef38 100644 --- a/config/initializers/routes_hierarchy.rb +++ b/config/initializers/routes_hierarchy.rb @@ -7,8 +7,8 @@ module ActionDispatch::Routing::UrlFor case resource.class.name when "Budget::Investment" [resource.budget, resource] - when "Budget::Investment::Milestone" - [resource.investment.budget, resource.investment, resource] + when "Milestone" + [resource.milestoneable.budget, resource.milestoneable, resource] when "Legislation::Annotation" [resource.draft_version.process, resource.draft_version, resource] when "Legislation::Proposal", "Legislation::Question", "Legislation::DraftVersion" diff --git a/config/locales/ar/activerecord.yml b/config/locales/ar/activerecord.yml index 1c4d69c01..5f1ba2c00 100644 --- a/config/locales/ar/activerecord.yml +++ b/config/locales/ar/activerecord.yml @@ -86,12 +86,12 @@ ar: organization_name: "إذا كنت تقترح بإسم جماعي/منظمة, أو نيابة عن أشخاص آخرين, اكتب إسمها" image: "اقتراح صورة وصفية" image_title: "عنوان الصورة" - budget/investment/milestone: + milestone: status_id: "حالة الإستثمار الحالية (إختياري)" title: "العنوان" description: "الوصف (إختياري ان كان هناك حالة معينة)" publication_date: "تاريخ النشر" - budget/investment/status: + milestone/status: name: "الاسم" description: "الوصف (إختياري)" budget/heading: diff --git a/config/locales/ast/activerecord.yml b/config/locales/ast/activerecord.yml index 46ea2c973..07e57bfd2 100644 --- a/config/locales/ast/activerecord.yml +++ b/config/locales/ast/activerecord.yml @@ -7,7 +7,7 @@ ast: budget/investment: one: "Proyectu de inversión" other: "Proyectos d'inversión" - budget/investment/milestone: + milestone: one: "finxu" other: "finxos" comment: diff --git a/config/locales/ca/activerecord.yml b/config/locales/ca/activerecord.yml index 99c24dddd..121f343fa 100644 --- a/config/locales/ca/activerecord.yml +++ b/config/locales/ca/activerecord.yml @@ -10,7 +10,7 @@ ca: budget/investment: one: "Proposta d'inversió" other: "Propostes d'inversió" - budget/investment/milestone: + milestone: one: "fita" other: "fites" comment: diff --git a/config/locales/de-DE/activerecord.yml b/config/locales/de-DE/activerecord.yml index 0b61727e9..8032a3aff 100644 --- a/config/locales/de-DE/activerecord.yml +++ b/config/locales/de-DE/activerecord.yml @@ -10,10 +10,10 @@ de: budget/investment: one: "Ausgabenvorschlag" other: "Ausgabenvorschläge" - budget/investment/milestone: + milestone: one: "Meilenstein" other: "Meilensteine" - budget/investment/status: + milestone/status: one: "Status des Ausgabenvorschlags" other: "Status der Ausgabenvorschläge" comment: @@ -131,12 +131,12 @@ de: organization_name: "Wenn Sie einen Vorschlag im Namen einer Gruppe, Organisation oder mehreren Personen einreichen, nennen Sie bitte dessen/deren Name/n" image: "Beschreibendes Bild zum Ausgabenvorschlag" image_title: "Bildtitel" - budget/investment/milestone: + milestone: status_id: "Derzeitiger Status des Ausgabenvorschlags (optional)" title: "Titel" description: "Beschreibung (optional, wenn kein Status zugewiesen ist)" publication_date: "Datum der Veröffentlichung" - budget/investment/status: + milestone/status: name: "Name" description: "Beschreibung (optional)" budget/heading: diff --git a/config/locales/en-US/activerecord.yml b/config/locales/en-US/activerecord.yml index 28deaa039..0bf16fa71 100644 --- a/config/locales/en-US/activerecord.yml +++ b/config/locales/en-US/activerecord.yml @@ -1,10 +1,10 @@ en-US: activerecord: models: - budget/investment/milestone: + milestone: one: "Meilenstein" other: "Meilensteine" - budget/investment/status: + milestone/status: one: "Investitionsstatus, Anlagenstatus" other: "Investitionsstatus, Anlagenstatus" comment: diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml index 0ed4a9872..5fdff28dd 100644 --- a/config/locales/en/activerecord.yml +++ b/config/locales/en/activerecord.yml @@ -10,12 +10,12 @@ en: budget/investment: one: "Investment" other: "Investments" - budget/investment/milestone: + milestone: one: "milestone" other: "milestones" - budget/investment/status: - one: "Investment status" - other: "Investment statuses" + milestone/status: + one: "Milestone Status" + other: "Milestone Statuses" comment: one: "Comment" other: "Comments" @@ -131,12 +131,12 @@ en: organization_name: "If you are proposing in the name of a collective/organization, or on behalf of more people, write its name" image: "Proposal descriptive image" image_title: "Image title" - budget/investment/milestone: + milestone: status_id: "Current investment status (optional)" title: "Title" description: "Description (optional if there's an status assigned)" publication_date: "Publication date" - budget/investment/status: + milestone/status: name: "Name" description: "Description (optional)" budget/heading: diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 6ee435c55..666cfec65 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -286,24 +286,24 @@ en: notice: Milestone successfully deleted statuses: index: - title: Investment statuses - empty_statuses: There are no investment statuses created - new_status: Create new investment status + title: Milestone statuses + empty_statuses: There are no milestone statuses created + new_status: Create new milestone status table_name: Name table_description: Description table_actions: Actions delete: Delete edit: Edit edit: - title: Edit investment status + title: Edit milestone status update: - notice: Investment status updated successfully + notice: Milestone status updated successfully new: - title: Create investment status + title: Create milestone status create: - notice: Investment status created successfully + notice: Milestone status created successfully delete: - notice: Investment status deleted successfully + notice: Milestone status deleted successfully comments: index: filter: Filter diff --git a/config/locales/es-AR/activerecord.yml b/config/locales/es-AR/activerecord.yml index 23b50fca7..9e838c744 100644 --- a/config/locales/es-AR/activerecord.yml +++ b/config/locales/es-AR/activerecord.yml @@ -7,10 +7,10 @@ es-AR: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" - budget/investment/status: + milestone/status: one: "Estado de Inversiones" other: "Estado de Inversiones" comment: @@ -113,12 +113,12 @@ es-AR: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: status_id: "Estado de inversión actual ( opcional)" title: "Título" description: "Descripción (opcional si hay estado asignado)" publication_date: "Fecha de publicación" - budget/investment/status: + milestone/status: name: "Nombre" description: "Descripción (opcional)" budget/heading: diff --git a/config/locales/es-BO/activerecord.yml b/config/locales/es-BO/activerecord.yml index 9eff5337e..878fd2c7d 100644 --- a/config/locales/es-BO/activerecord.yml +++ b/config/locales/es-BO/activerecord.yml @@ -7,7 +7,7 @@ es-BO: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-BO: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-CL/activerecord.yml b/config/locales/es-CL/activerecord.yml index 826b5101f..0bd35df38 100644 --- a/config/locales/es-CL/activerecord.yml +++ b/config/locales/es-CL/activerecord.yml @@ -10,10 +10,10 @@ es-CL: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" - budget/investment/status: + milestone/status: one: "Estado de la inversión" other: "Estados de las inversiones" comment: @@ -128,12 +128,12 @@ es-CL: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: status_id: "Estado actual de la inversión (opcional)" title: "Título" description: "Descripción (opcional si hay una condición asignada)" publication_date: "Fecha de publicación" - budget/investment/status: + milestone/status: name: "Nombre" description: "Descripción (opcional)" budget/heading: diff --git a/config/locales/es-CO/activerecord.yml b/config/locales/es-CO/activerecord.yml index 41ebf026a..69cadde05 100644 --- a/config/locales/es-CO/activerecord.yml +++ b/config/locales/es-CO/activerecord.yml @@ -7,7 +7,7 @@ es-CO: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-CO: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-CR/activerecord.yml b/config/locales/es-CR/activerecord.yml index bc2bcff15..d24c27af4 100644 --- a/config/locales/es-CR/activerecord.yml +++ b/config/locales/es-CR/activerecord.yml @@ -7,7 +7,7 @@ es-CR: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-CR: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-DO/activerecord.yml b/config/locales/es-DO/activerecord.yml index e0cfcc982..21b0d65fa 100644 --- a/config/locales/es-DO/activerecord.yml +++ b/config/locales/es-DO/activerecord.yml @@ -7,7 +7,7 @@ es-DO: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-DO: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-EC/activerecord.yml b/config/locales/es-EC/activerecord.yml index d097a6eec..4540f0839 100644 --- a/config/locales/es-EC/activerecord.yml +++ b/config/locales/es-EC/activerecord.yml @@ -7,7 +7,7 @@ es-EC: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-EC: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-GT/activerecord.yml b/config/locales/es-GT/activerecord.yml index 5147d66da..1e9b19bf0 100644 --- a/config/locales/es-GT/activerecord.yml +++ b/config/locales/es-GT/activerecord.yml @@ -7,7 +7,7 @@ es-GT: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-GT: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-HN/activerecord.yml b/config/locales/es-HN/activerecord.yml index 483778186..7d597d531 100644 --- a/config/locales/es-HN/activerecord.yml +++ b/config/locales/es-HN/activerecord.yml @@ -7,7 +7,7 @@ es-HN: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-HN: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-MX/activerecord.yml b/config/locales/es-MX/activerecord.yml index 7d0d80da0..2e64e6124 100644 --- a/config/locales/es-MX/activerecord.yml +++ b/config/locales/es-MX/activerecord.yml @@ -10,10 +10,10 @@ es-MX: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" - budget/investment/status: + milestone/status: one: "Estado de inversión" other: "Estados de inversión" comment: @@ -128,11 +128,11 @@ es-MX: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" description: "Descripción (opcional si cuenta con un estado asignado)" publication_date: "Fecha de publicación" - budget/investment/status: + milestone/status: name: "Nombre" description: "Descripción (opcional)" budget/heading: diff --git a/config/locales/es-NI/activerecord.yml b/config/locales/es-NI/activerecord.yml index d3b6d8242..c9aad963a 100644 --- a/config/locales/es-NI/activerecord.yml +++ b/config/locales/es-NI/activerecord.yml @@ -7,7 +7,7 @@ es-NI: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-NI: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-PA/activerecord.yml b/config/locales/es-PA/activerecord.yml index 95f617cbd..eac061779 100644 --- a/config/locales/es-PA/activerecord.yml +++ b/config/locales/es-PA/activerecord.yml @@ -7,7 +7,7 @@ es-PA: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-PA: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-PE/activerecord.yml b/config/locales/es-PE/activerecord.yml index 4604a2868..8569e3bfc 100644 --- a/config/locales/es-PE/activerecord.yml +++ b/config/locales/es-PE/activerecord.yml @@ -7,7 +7,7 @@ es-PE: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-PE: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-PR/activerecord.yml b/config/locales/es-PR/activerecord.yml index cf38eaba8..08d1a8662 100644 --- a/config/locales/es-PR/activerecord.yml +++ b/config/locales/es-PR/activerecord.yml @@ -7,7 +7,7 @@ es-PR: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-PR: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-PY/activerecord.yml b/config/locales/es-PY/activerecord.yml index fc3dd64b4..27150dfca 100644 --- a/config/locales/es-PY/activerecord.yml +++ b/config/locales/es-PY/activerecord.yml @@ -7,7 +7,7 @@ es-PY: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-PY: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-SV/activerecord.yml b/config/locales/es-SV/activerecord.yml index a4c3430c6..594d2003b 100644 --- a/config/locales/es-SV/activerecord.yml +++ b/config/locales/es-SV/activerecord.yml @@ -7,7 +7,7 @@ es-SV: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-SV: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-UY/activerecord.yml b/config/locales/es-UY/activerecord.yml index e8348ed68..ffa5059fd 100644 --- a/config/locales/es-UY/activerecord.yml +++ b/config/locales/es-UY/activerecord.yml @@ -7,7 +7,7 @@ es-UY: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-UY: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es-VE/activerecord.yml b/config/locales/es-VE/activerecord.yml index 13e76a7be..7878f5019 100644 --- a/config/locales/es-VE/activerecord.yml +++ b/config/locales/es-VE/activerecord.yml @@ -7,7 +7,7 @@ es-VE: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" comment: @@ -104,7 +104,7 @@ es-VE: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva de la propuesta de inversión" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: title: "Título" publication_date: "Fecha de publicación" budget/heading: diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml index 15bbb35bf..722fd6724 100644 --- a/config/locales/es/activerecord.yml +++ b/config/locales/es/activerecord.yml @@ -10,12 +10,12 @@ es: budget/investment: one: "Proyecto de gasto" other: "Proyectos de gasto" - budget/investment/milestone: + milestone: one: "hito" other: "hitos" - budget/investment/status: - one: "Estado del proyecto" - other: "Estados del proyecto" + milestone/status: + one: "Estado de seguimiento" + other: "Estados de seguimiento" comment: one: "Comentario" other: "Comentarios" @@ -131,12 +131,12 @@ es: organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre" image: "Imagen descriptiva del proyecto de gasto" image_title: "Título de la imagen" - budget/investment/milestone: + milestone: status_id: "Estado actual del proyecto (opcional)" title: "Título" description: "Descripción (opcional si hay un estado asignado)" publication_date: "Fecha de publicación" - budget/investment/status: + milestone/status: name: "Nombre" description: "Descripción (opcional)" budget/heading: diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index b16f85bd8..f5a82ff58 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -286,24 +286,24 @@ es: notice: Hito borrado correctamente statuses: index: - title: Estados de proyectos - empty_statuses: Aún no se ha creado ningún estado de proyecto - new_status: Crear nuevo estado de proyecto + title: Estados de seguimiento + empty_statuses: Aún no se ha creado ningún estado de seguimiento + new_status: Crear nuevo estado de seguimiento table_name: Nombre table_description: Descripción table_actions: Acciones delete: Borrar edit: Editar edit: - title: Editar estado de proyecto + title: Editar estado de seguimiento update: - notice: Estado de proyecto editado correctamente + notice: Estado de seguimiento editado correctamente new: - title: Crear estado de proyecto + title: Crear estado de seguimiento create: - notice: Estado de proyecto creado correctamente + notice: Estado de seguimiento creado correctamente delete: - notice: Estado de proyecto eliminado correctamente + notice: Estado de seguimiento eliminado correctamente comments: index: filter: Filtro diff --git a/config/locales/fa-IR/activerecord.yml b/config/locales/fa-IR/activerecord.yml index e7baab9b0..4a417cc80 100644 --- a/config/locales/fa-IR/activerecord.yml +++ b/config/locales/fa-IR/activerecord.yml @@ -10,7 +10,7 @@ fa: budget/investment: one: "سرمایه گذاری" other: "سرمایه گذاری ها" - budget/investment/milestone: + milestone: one: "نقطه عطف" other: "نقاط عطف" comment: @@ -119,7 +119,7 @@ fa: organization_name: "اگر شما به نام یک گروه / سازمان، یا از طرف افراد بیشتری پیشنهاد می کنید، نام آنها را بنویسید." image: "تصویر طرح توصیفی" image_title: "عنوان تصویر" - budget/investment/milestone: + milestone: title: "عنوان" publication_date: "تاریخ انتشار" budget/heading: diff --git a/config/locales/fr/activerecord.yml b/config/locales/fr/activerecord.yml index 0b9540d10..247cdffb5 100644 --- a/config/locales/fr/activerecord.yml +++ b/config/locales/fr/activerecord.yml @@ -10,10 +10,10 @@ fr: budget/investment: one: "Projet d'investissement" other: "Projets d'investissement" - budget/investment/milestone: + milestone: one: "jalon" other: "jalons" - budget/investment/status: + milestone/status: one: "Statut d’investissement" other: "Statuts d’investissement" comment: @@ -128,12 +128,12 @@ fr: organization_name: "Si votre proposition se fait au nom d'un collectif ou d'une organisation, renseignez leur nom" image: "Image descriptive de la proposition" image_title: "Titre de l'image" - budget/investment/milestone: + milestone: status_id: "Statut actuel de l'investissement (facultatif)" title: "Titre" description: "Description (facultative si un statut est affecté)" publication_date: "Date de publication" - budget/investment/status: + milestone/status: name: "Nom" description: "Description (facultative)" budget/heading: diff --git a/config/locales/gl/activerecord.yml b/config/locales/gl/activerecord.yml index bef16f4db..725778290 100644 --- a/config/locales/gl/activerecord.yml +++ b/config/locales/gl/activerecord.yml @@ -10,10 +10,10 @@ gl: budget/investment: one: "Investimento" other: "Investimentos" - budget/investment/milestone: + milestone: one: "fito" other: "fitos" - budget/investment/status: + milestone/status: one: "Estado do investimento" other: "Estado dos investimentos" comment: @@ -131,12 +131,12 @@ gl: organization_name: "Se estás a propor no nome dunha organización, dun colectivo ou de mais xente, escribe o seu nome" image: "Imaxe descritiva da proposta" image_title: "Título da imaxe" - budget/investment/milestone: + milestone: status_id: "Estado do investimento actual (opcional)" title: "Título" description: "Descrición (opcional se hai unha condición asignada)" publication_date: "Data de publicación" - budget/investment/status: + milestone/status: name: "Nome" description: "Descrición (opcional)" budget/heading: diff --git a/config/locales/id-ID/activerecord.yml b/config/locales/id-ID/activerecord.yml index 66b109b6b..eae0f72cf 100644 --- a/config/locales/id-ID/activerecord.yml +++ b/config/locales/id-ID/activerecord.yml @@ -7,7 +7,7 @@ id: other: "Anggaran" budget/investment: other: "Investasi" - budget/investment/milestone: + milestone: other: "batu peringatan" comment: other: "Komentar" @@ -81,7 +81,7 @@ id: organization_name: "Jika Anda usulkan dalam nama kolektif/organisasi, atau atas nama orang lain, menulis namanya" image: "Gambar deskriptif proposal" image_title: "Judul gambar" - budget/investment/milestone: + milestone: title: "Judul" publication_date: "Tanggal publikasi" budget/heading: diff --git a/config/locales/it/activerecord.yml b/config/locales/it/activerecord.yml index 7de92dc08..84c494e0b 100644 --- a/config/locales/it/activerecord.yml +++ b/config/locales/it/activerecord.yml @@ -10,10 +10,10 @@ it: budget/investment: one: "Investimento" other: "Investimenti" - budget/investment/milestone: + milestone: one: "traguardo" other: "traguardi" - budget/investment/status: + milestone/status: one: "Status dell’investimento" other: "Status dell’investimento" comment: @@ -128,12 +128,12 @@ it: organization_name: "Se presenti una proposta a nome di un collettivo o di un’organizzazione, ovvero per conto di più persone, indicane il nome" image: "Immagine descrittiva della proposta" image_title: "Titolo dell’immagine" - budget/investment/milestone: + milestone: status_id: "Stato attuale dell’investimento (facoltativo)" title: "Titolo" description: "Descrizione (facoltativa se c’è gia uno stato assegnato)" publication_date: "Data di pubblicazione" - budget/investment/status: + milestone/status: name: "Nome" description: "Descrizione (facoltativa)" budget/heading: diff --git a/config/locales/nl/activerecord.yml b/config/locales/nl/activerecord.yml index 7cc9b19c3..559462b88 100644 --- a/config/locales/nl/activerecord.yml +++ b/config/locales/nl/activerecord.yml @@ -10,7 +10,7 @@ nl: budget/investment: one: "Investerning" other: "Investeringen" - budget/investment/milestone: + milestone: one: "mijlpaal" other: "mijlpalen" comment: @@ -122,12 +122,12 @@ nl: organization_name: "Als je een voorstel doet uit naam van een collectief/organisatie, voer dan hier de naam in" image: "Afbeelding ter omschrijving van het voorstel" image_title: "Naam van de afbeelding" - budget/investment/milestone: + milestone: status_id: "Huidige investeringsstatus (optioneel)" title: "Titel" description: "Omschrijving" publication_date: "Publicatiedatum" - budget/investment/status: + milestone/status: name: "Naam" description: "Beschrijving (optioneel)" budget/heading: diff --git a/config/locales/pl-PL/activerecord.yml b/config/locales/pl-PL/activerecord.yml index c16b494d1..e8a63da98 100644 --- a/config/locales/pl-PL/activerecord.yml +++ b/config/locales/pl-PL/activerecord.yml @@ -6,12 +6,12 @@ pl: few: "Inwestycje" many: "Inwestycji" other: "Inwestycji" - budget/investment/milestone: + milestone: one: "kamień milowy" few: "kamienie milowe" many: "kamieni milowych" other: "kamieni milowych" - budget/investment/status: + milestone/status: one: "Etap inwestycji" few: "Etapy inwestycji" many: "Etapów inwestycji" @@ -158,12 +158,12 @@ pl: organization_name: "Jeśli wnioskujesz w imieniu zespołu/organizacji, lub w imieniu większej liczby osób, wpisz ich nazwę" image: "Opisowy obraz wniosku" image_title: "Tytuł obrazu" - budget/investment/milestone: + milestone: status_id: "Bieżący stan inwestycji (opcjonalnie)" title: "Tytuł" description: "Opis (opcjonalnie, jeśli istnieje przydzielony stan)" publication_date: "Data publikacji" - budget/investment/status: + milestone/status: name: "Nazwa" description: "Opis (opcjonalnie)" budget/heading: diff --git a/config/locales/pt-BR/activerecord.yml b/config/locales/pt-BR/activerecord.yml index 93756f2fc..91fcd3dbc 100644 --- a/config/locales/pt-BR/activerecord.yml +++ b/config/locales/pt-BR/activerecord.yml @@ -10,10 +10,10 @@ pt-BR: budget/investment: one: "Investimento" other: "Investimentos" - budget/investment/milestone: + milestone: one: "Marco" other: "Marcos" - budget/investment/status: + milestone/status: one: "Status de investimento" other: "Status dos investimentos" comment: @@ -128,12 +128,12 @@ pt-BR: organization_name: "Se você está propondo em nome de um coletivo / organização, ou em nome de mais pessoas, escreva seu nome" image: "Imagem descritiva da proposta" image_title: "Título da imagem" - budget/investment/milestone: + milestone: status_id: "Status atual do investimento (opcional)" title: "Título" description: "Descrição (opcional, se houver uma condição atribuída)" publication_date: "Data de publicação" - budget/investment/status: + milestone/status: name: "Nome" description: "Descrição (opcional)" budget/heading: diff --git a/config/locales/ru/activerecord.yml b/config/locales/ru/activerecord.yml index efecc08c2..a97e2e69d 100644 --- a/config/locales/ru/activerecord.yml +++ b/config/locales/ru/activerecord.yml @@ -22,12 +22,12 @@ ru: organization_name: "Если вы делаете предложение от имени коллектива/организации или от имени большего числа людей, напишите его название" image: "Иллюстративное изображение предложения" image_title: "Название изображения" - budget/investment/milestone: + milestone: status_id: "Текущий инвестиционный статус (опционально)" title: "Название" description: "Описание (опционально, если присвоен статус)" publication_date: "Дата публикации" - budget/investment/status: + milestone/status: name: "Имя" description: "Описание (опционально)" budget/heading: diff --git a/config/locales/sq-AL/activerecord.yml b/config/locales/sq-AL/activerecord.yml index 8eaf2af24..e8882ffcc 100644 --- a/config/locales/sq-AL/activerecord.yml +++ b/config/locales/sq-AL/activerecord.yml @@ -10,10 +10,10 @@ sq: budget/investment: one: "Investim" other: "Investim" - budget/investment/milestone: + milestone: one: "moment historik" other: "milestone" - budget/investment/status: + milestone/status: one: "Statusi investimeve" other: "Statusi investimeve" comment: @@ -128,12 +128,12 @@ sq: organization_name: "Nëse propozoni në emër të një kolektivi / organizate, ose në emër të më shumë njerëzve, shkruani emrin e tij" image: "Imazhi përshkrues i propozimit" image_title: "Titulli i imazhit" - budget/investment/milestone: + milestone: status_id: "Statusi aktual i investimit (opsional)" title: "Titull" description: "Përshkrimi (opsional nëse ka status të caktuar)" publication_date: "Data e publikimit" - budget/investment/status: + milestone/status: name: "Emri" description: "Përshkrimi (opsional)" budget/heading: diff --git a/config/locales/sv-SE/activerecord.yml b/config/locales/sv-SE/activerecord.yml index 47f0e9a49..4dd7cf5c6 100644 --- a/config/locales/sv-SE/activerecord.yml +++ b/config/locales/sv-SE/activerecord.yml @@ -10,10 +10,10 @@ sv: budget/investment: one: "Budgetförslag" other: "Budgetförslag" - budget/investment/milestone: + milestone: one: "milstolpe" other: "milstolpar" - budget/investment/status: + milestone/status: one: "Budgetförslagets status" other: "Budgetförslagens status" comment: @@ -128,12 +128,12 @@ sv: organization_name: "Organisation eller grupp i vars namn du lämnar förslaget" image: "Förklarande bild till förslaget" image_title: "Bildtext" - budget/investment/milestone: + milestone: status_id: "Nuvarande status för budgetförslag (frivilligt fält)" title: "Titel" description: "Beskrivning (frivilligt fält om projektets status har ställts in)" publication_date: "Publiceringsdatum" - budget/investment/status: + milestone/status: name: "Namn" description: "Beskrivning (frivilligt fält)" budget/heading: diff --git a/config/locales/tr-TR/activerecord.yml b/config/locales/tr-TR/activerecord.yml index 160579200..46e4fd8cd 100644 --- a/config/locales/tr-TR/activerecord.yml +++ b/config/locales/tr-TR/activerecord.yml @@ -10,7 +10,7 @@ tr: budget/investment: one: "yatırım" other: "Yatırımlar" - budget/investment/milestone: + milestone: one: "kilometre taşı" other: "kilometre taşları" comment: diff --git a/config/locales/val/activerecord.yml b/config/locales/val/activerecord.yml index 7231bd73f..eac2133b8 100644 --- a/config/locales/val/activerecord.yml +++ b/config/locales/val/activerecord.yml @@ -10,10 +10,10 @@ val: budget/investment: one: "Proposta d'inversió" other: "Propostes d'inversió" - budget/investment/milestone: + milestone: one: "fita" other: "fites" - budget/investment/status: + milestone/status: one: "Estat de la proposta" other: "Estat de les propostes" comment: @@ -131,12 +131,12 @@ val: organization_name: "Si estàs proposant en nom d'una associació o col·lectiu, escriu el seu nom" image: "Imatge descriptiva de la proposta d'inversió" image_title: "Títol de la imatge" - budget/investment/milestone: + milestone: status_id: "Estat actual de la proposta (opcional)" title: "Títol" description: "Descripció (opcional si hi ha un estat asignat)" publication_date: "Data de publicació" - budget/investment/status: + milestone/status: name: "Nom" description: "Descripció (opcional)" budget/heading: diff --git a/config/locales/zh-CN/activerecord.yml b/config/locales/zh-CN/activerecord.yml index 90f1f94ec..ca8972641 100644 --- a/config/locales/zh-CN/activerecord.yml +++ b/config/locales/zh-CN/activerecord.yml @@ -7,9 +7,9 @@ zh-CN: other: "预算" budget/investment: other: "投资" - budget/investment/milestone: + milestone: other: "里程碑" - budget/investment/status: + milestone/status: other: "投资状态" comment: other: "意见" @@ -93,12 +93,12 @@ zh-CN: organization_name: "如果你是以集体/组织的名义或者代表更多的人提出建议,写下它的名字。" image: "建议说明性图像" image_title: "图像标题" - budget/investment/milestone: + milestone: status_id: "当前投资状况(可选)" title: "标题" description: "说明(如果指定了状态,则可选)" publication_date: "出版日期" - budget/investment/status: + milestone/status: name: "名字" description: "说明(可选)" budget/heading: diff --git a/config/locales/zh-TW/activerecord.yml b/config/locales/zh-TW/activerecord.yml index cebb171a9..1840ee3f7 100644 --- a/config/locales/zh-TW/activerecord.yml +++ b/config/locales/zh-TW/activerecord.yml @@ -7,9 +7,9 @@ zh-TW: other: "預算" budget/investment: other: "投資" - budget/investment/milestone: + milestone: other: "里程碑" - budget/investment/status: + milestone/status: other: "投資狀態" comment: other: "評論" @@ -93,12 +93,12 @@ zh-TW: organization_name: "如果您以集體/組織的名義,或代表多人提出建議,請寫下其名稱" image: "建議說明性圖像" image_title: "圖像標題" - budget/investment/milestone: + milestone: status_id: "當前投資狀況 (可選擇填寫)" title: "標題" description: "說明 (如果已經指定了狀態, 則可選擇填寫)" publication_date: "出版日期" - budget/investment/status: + milestone/status: name: "名字" description: "說明 (可選擇填寫)" budget/heading: diff --git a/config/routes/admin.rb b/config/routes/admin.rb index e65ec688a..4bd607803 100644 --- a/config/routes/admin.rb +++ b/config/routes/admin.rb @@ -62,14 +62,14 @@ namespace :admin do end resources :budget_investments, only: [:index, :show, :edit, :update] do - resources :budget_investment_milestones + resources :milestones, controller: 'budget_investment_milestones' member { patch :toggle_selection } end resources :budget_phases, only: [:edit, :update] end - resources :budget_investment_statuses, only: [:index, :new, :create, :update, :edit, :destroy] + resources :milestone_statuses, only: [:index, :new, :create, :update, :edit, :destroy] resources :signature_sheets, only: [:index, :new, :create, :show] diff --git a/db/dev_seeds/budgets.rb b/db/dev_seeds/budgets.rb index 6a44b977c..07f30758f 100644 --- a/db/dev_seeds/budgets.rb +++ b/db/dev_seeds/budgets.rb @@ -139,16 +139,16 @@ section "Creating Valuation Assignments" do end end -section "Creating default Investment Milestone Statuses" do - Budget::Investment::Status.create(name: I18n.t('seeds.budgets.statuses.studying_project')) - Budget::Investment::Status.create(name: I18n.t('seeds.budgets.statuses.bidding')) - Budget::Investment::Status.create(name: I18n.t('seeds.budgets.statuses.executing_project')) - Budget::Investment::Status.create(name: I18n.t('seeds.budgets.statuses.executed')) +section "Creating default Milestone Statuses" do + Milestone::Status.create(name: I18n.t('seeds.budgets.statuses.studying_project')) + Milestone::Status.create(name: I18n.t('seeds.budgets.statuses.bidding')) + Milestone::Status.create(name: I18n.t('seeds.budgets.statuses.executing_project')) + Milestone::Status.create(name: I18n.t('seeds.budgets.statuses.executed')) end section "Creating investment milestones" do Budget::Investment.find_each do |investment| - milestone = Budget::Investment::Milestone.new(investment_id: investment.id, publication_date: Date.tomorrow) + milestone = investment.milestones.build(publication_date: Date.tomorrow, status_id: Milestone::Status.all.sample) I18n.available_locales.map do |locale| Globalize.with_locale(locale) do milestone.description = "Description for locale #{locale}" diff --git a/db/migrate/20180323190027_add_translate_milestones.rb b/db/migrate/20180323190027_add_translate_milestones.rb index 6767d8e84..afc8db9af 100644 --- a/db/migrate/20180323190027_add_translate_milestones.rb +++ b/db/migrate/20180323190027_add_translate_milestones.rb @@ -1,15 +1,12 @@ class AddTranslateMilestones < ActiveRecord::Migration - def self.up - Budget::Investment::Milestone.create_translation_table!( - { - title: :string, - description: :text - }, - { migrate_data: true } - ) - end + def change + create_table :budget_investment_milestone_translations do |t| + t.integer :budget_investment_milestone_id, null: false + t.string :locale, null: false + t.string :title + t.text :description - def self.down - Budget::Investment::Milestone.drop_translation_table! + t.timestamps null: false + end end end diff --git a/db/migrate/20180713103402_change_budget_investment_statuses_to_milestone_statuses.rb b/db/migrate/20180713103402_change_budget_investment_statuses_to_milestone_statuses.rb new file mode 100644 index 000000000..05deae5a7 --- /dev/null +++ b/db/migrate/20180713103402_change_budget_investment_statuses_to_milestone_statuses.rb @@ -0,0 +1,12 @@ +class ChangeBudgetInvestmentStatusesToMilestoneStatuses < ActiveRecord::Migration + def change + create_table :milestone_statuses do |t| + t.string :name + t.text :description + t.datetime :hidden_at, index: true + + t.timestamps null: false + end + end +end + diff --git a/db/migrate/20180713124501_make_investment_milestones_polymorphic.rb b/db/migrate/20180713124501_make_investment_milestones_polymorphic.rb new file mode 100644 index 000000000..9d8ce901e --- /dev/null +++ b/db/migrate/20180713124501_make_investment_milestones_polymorphic.rb @@ -0,0 +1,27 @@ +class MakeInvestmentMilestonesPolymorphic < ActiveRecord::Migration + def change + create_table :milestones do |t| + t.references :milestoneable, polymorphic: true + t.string "title", limit: 80 + t.text "description" + t.datetime "publication_date" + + t.references :status, index: true + + t.timestamps null: false + end + + reversible do |change| + change.up do + Milestone.create_translation_table!({ + title: :string, + description: :text + }) + end + + change.down do + Milestone.drop_translation_table! + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index d30f35716..368049987 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -163,15 +163,12 @@ ActiveRecord::Schema.define(version: 20181016204729) do create_table "budget_investment_milestone_translations", force: :cascade do |t| t.integer "budget_investment_milestone_id", null: false t.string "locale", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false t.string "title" t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end - add_index "budget_investment_milestone_translations", ["budget_investment_milestone_id"], name: "index_6770e7675fe296cf87aa0fd90492c141b5269e0b", using: :btree - add_index "budget_investment_milestone_translations", ["locale"], name: "index_budget_investment_milestone_translations_on_locale", using: :btree - create_table "budget_investment_milestones", force: :cascade do |t| t.integer "investment_id" t.string "title", limit: 80 @@ -781,6 +778,41 @@ ActiveRecord::Schema.define(version: 20181016204729) do add_index "map_locations", ["investment_id"], name: "index_map_locations_on_investment_id", using: :btree add_index "map_locations", ["proposal_id"], name: "index_map_locations_on_proposal_id", using: :btree + create_table "milestone_statuses", force: :cascade do |t| + t.string "name" + t.text "description" + t.datetime "hidden_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "milestone_statuses", ["hidden_at"], name: "index_milestone_statuses_on_hidden_at", using: :btree + + create_table "milestone_translations", force: :cascade do |t| + t.integer "milestone_id", null: false + t.string "locale", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "title" + t.text "description" + end + + add_index "milestone_translations", ["locale"], name: "index_milestone_translations_on_locale", using: :btree + add_index "milestone_translations", ["milestone_id"], name: "index_milestone_translations_on_milestone_id", using: :btree + + create_table "milestones", force: :cascade do |t| + t.integer "milestoneable_id" + t.string "milestoneable_type" + t.string "title", limit: 80 + t.text "description" + t.datetime "publication_date" + t.integer "status_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "milestones", ["status_id"], name: "index_milestones_on_status_id", using: :btree + create_table "moderators", force: :cascade do |t| t.integer "user_id" end diff --git a/lib/tasks/globalize.rake b/lib/tasks/globalize.rake index 51a23042e..5197b0b1d 100644 --- a/lib/tasks/globalize.rake +++ b/lib/tasks/globalize.rake @@ -3,7 +3,7 @@ namespace :globalize do [ AdminNotification, Banner, - Budget::Investment::Milestone, + Milestone, I18nContent, Legislation::DraftVersion, Legislation::Process, diff --git a/lib/tasks/migrate_milestones_and_statuses.rake b/lib/tasks/migrate_milestones_and_statuses.rake new file mode 100644 index 000000000..d01418e6b --- /dev/null +++ b/lib/tasks/migrate_milestones_and_statuses.rake @@ -0,0 +1,106 @@ +namespace :milestones do + + def generate_table_migration_sql(new_table:, old_table:, columns:) + from_cols = ['id', *columns.keys] + to_cols = ['id', *columns.values] + <<~SQL + INSERT INTO #{new_table} (#{to_cols.join(', ')}) + SELECT #{from_cols.join(', ')} FROM #{old_table}; + SQL + end + + def migrate_table!(new_table:, old_table:, columns:) + puts "Migrating data from '#{old_table}' to '#{new_table}'..." + result = ActiveRecord::Base.connection.execute( + generate_table_migration_sql(old_table: old_table, + new_table: new_table, + columns: columns) + + ) + puts "#{result.cmd_tuples} rows affected" + end + + def populate_column!(table:, column:, value:) + puts "Populating column '#{column}' from table '#{table}' with '#{value}'..." + result = ActiveRecord::Base.connection.execute( + "UPDATE #{table} SET #{column} = '#{value}';" + ) + puts "#{result.cmd_tuples} rows affected" + end + + def count_rows(table) + ActiveRecord::Base.connection.query("SELECT COUNT(*) FROM #{table};")[0][0].to_i + end + + desc "Migrate milestones and milestone status data after making the model polymorphic" + task migrate: :environment do + # This script copies all milestone-related data from the old tables to + # the new ones (preserving all primary keys). All 3 of the new tables + # must be empty. + # + # To clear the new tables to test this script: + # + # DELETE FROM milestone_statuses; + # DELETE FROM milestones; + # DELETE FROM milestone_translations; + # + + start = Time.now + + ActiveRecord::Base.transaction do + migrate_table! old_table: 'budget_investment_statuses', + new_table: 'milestone_statuses', + columns: {'name' => 'name', + 'description' => 'description', + 'hidden_at' => 'hidden_at', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at'} + + migrate_table! old_table: 'budget_investment_milestones', + new_table: 'milestones', + columns: {'investment_id' => 'milestoneable_id', + 'title' => 'title', + 'description' => 'description', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at', + 'publication_date' => 'publication_date', + 'status_id' => 'status_id'} + + populate_column! table: 'milestones', + column: 'milestoneable_type', + value: 'Budget::Investment' + + migrate_table! old_table: 'budget_investment_milestone_translations', + new_table: 'milestone_translations', + columns: {'budget_investment_milestone_id' => 'milestone_id', + 'locale' => 'locale', + 'created_at' => 'created_at', + 'updated_at' => 'updated_at', + 'title' => 'title', + 'description' => 'description'} + + Image.where(imageable_type: "Budget::Investment::Milestone"). + update_all(imageable_type: "Milestone") + Document.where(documentable_type: "Budget::Investment::Milestone"). + update_all(documentable_type: "Milestone") + + puts "Verifying that all rows were copied..." + + { + "budget_investment_milestones" => "milestones", + "budget_investment_statuses" => "milestone_statuses", + "budget_investment_milestone_translations" => "milestone_translations" + }.each do |original_table, migrated_table| + ActiveRecord::Base.connection.execute( + "select setval('#{migrated_table}_id_seq', (select max(id) from #{migrated_table}));" + ) + + unless count_rows(original_table) == count_rows(migrated_table) + raise "Number of rows of old and new tables do not match! Rolling back transaction..." + end + end + end + + puts "Finished in %.3f seconds" % (Time.now - start) + end +end diff --git a/spec/factories/budgets.rb b/spec/factories/budgets.rb index d713302fd..0a8ea699b 100644 --- a/spec/factories/budgets.rb +++ b/spec/factories/budgets.rb @@ -193,14 +193,14 @@ FactoryBot.define do reason "unfeasible" end - factory :budget_investment_status, class: 'Budget::Investment::Status' do - sequence(:name) { |n| "Budget investment status #{n} name" } - sequence(:description) { |n| "Budget investment status #{n} description" } + factory :milestone_status, class: 'Milestone::Status' do + sequence(:name) { |n| "Milestone status #{n} name" } + sequence(:description) { |n| "Milestone status #{n} description" } end - factory :budget_investment_milestone, class: 'Budget::Investment::Milestone' do - association :investment, factory: :budget_investment - association :status, factory: :budget_investment_status + factory :milestone, class: 'Milestone' do + association :milestoneable, factory: :budget_investment + association :status, factory: :milestone_status sequence(:title) { |n| "Budget investment milestone #{n} title" } description 'Milestone description' publication_date { Date.current } diff --git a/spec/features/admin/budget_investment_milestones_spec.rb b/spec/features/admin/budget_investment_milestones_spec.rb index 35ed69089..28b05ff03 100644 --- a/spec/features/admin/budget_investment_milestones_spec.rb +++ b/spec/features/admin/budget_investment_milestones_spec.rb @@ -5,22 +5,22 @@ feature 'Admin budget investment milestones' do background do admin = create(:administrator) login_as(admin.user) - - @investment = create(:budget_investment) end + let!(:investment) { create(:budget_investment) } + it_behaves_like "translatable", - "budget_investment_milestone", - "edit_admin_budget_budget_investment_budget_investment_milestone_path", + "milestone", + "edit_admin_budget_budget_investment_milestone_path", %w[description] context "Index" do scenario 'Displaying milestones' do - milestone = create(:budget_investment_milestone, investment: @investment) + milestone = create(:milestone, milestoneable: investment) create(:image, imageable: milestone) document = create(:document, documentable: milestone) - visit admin_budget_budget_investment_path(@investment.budget, @investment) + visit admin_budget_budget_investment_path(investment.budget, investment) expect(page).to have_content("Milestone") expect(page).to have_content(milestone.title) @@ -32,7 +32,7 @@ feature 'Admin budget investment milestones' do end scenario 'Displaying no_milestones text' do - visit admin_budget_budget_investment_path(@investment.budget, @investment) + visit admin_budget_budget_investment_path(investment.budget, investment) expect(page).to have_content("Milestone") expect(page).to have_content("Don't have defined milestones") @@ -41,14 +41,14 @@ feature 'Admin budget investment milestones' do context "New" do scenario "Add milestone" do - status = create(:budget_investment_status) - visit admin_budget_budget_investment_path(@investment.budget, @investment) + status = create(:milestone_status) + visit admin_budget_budget_investment_path(investment.budget, investment) click_link 'Create new milestone' - select status.name, from: 'budget_investment_milestone_status_id' + select status.name, from: 'milestone_status_id' fill_in 'Description', with: 'New description milestone' - fill_in 'budget_investment_milestone_publication_date', with: Date.current + fill_in 'milestone_publication_date', with: Date.current click_button 'Create milestone' @@ -58,14 +58,14 @@ feature 'Admin budget investment milestones' do end scenario "Status select is disabled if there are no statuses available" do - visit admin_budget_budget_investment_path(@investment.budget, @investment) + visit admin_budget_budget_investment_path(investment.budget, investment) click_link 'Create new milestone' - expect(find("#budget_investment_milestone_status_id").disabled?).to be true + expect(find("#milestone_status_id").disabled?).to be true end scenario "Show validation errors on milestone form" do - visit admin_budget_budget_investment_path(@investment.budget, @investment) + visit admin_budget_budget_investment_path(investment.budget, investment) click_link 'Create new milestone' @@ -73,7 +73,7 @@ feature 'Admin budget investment milestones' do click_button 'Create milestone' - within "#new_budget_investment_milestone" do + within "#new_milestone" do expect(page).to have_content "can't be blank", count: 1 expect(page).to have_content 'New description milestone' end @@ -82,11 +82,11 @@ feature 'Admin budget investment milestones' do context "Edit" do scenario "Change title, description and document names" do - milestone = create(:budget_investment_milestone, investment: @investment) + milestone = create(:milestone, milestoneable: investment) create(:image, imageable: milestone) document = create(:document, documentable: milestone) - visit admin_budget_budget_investment_path(@investment.budget, @investment) + visit admin_budget_budget_investment_path(investment.budget, investment) expect(page).to have_link document.title click_link milestone.title @@ -94,8 +94,8 @@ feature 'Admin budget investment milestones' do expect(page).to have_css("img[alt='#{milestone.image.title}']") 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' + fill_in 'milestone_publication_date', with: Date.current + fill_in 'milestone_documents_attributes_0_title', with: 'New document title' click_button 'Update milestone' @@ -108,9 +108,9 @@ feature 'Admin budget investment milestones' do context "Delete" do scenario "Remove milestone" do - milestone = create(:budget_investment_milestone, investment: @investment, title: "Title will it remove") + milestone = create(:milestone, milestoneable: investment, title: "Title will it remove") - visit admin_budget_budget_investment_path(@investment.budget, @investment) + visit admin_budget_budget_investment_path(investment.budget, investment) click_link "Delete milestone" diff --git a/spec/features/admin/budget_investment_statuses_spec.rb b/spec/features/admin/budget_investment_statuses_spec.rb deleted file mode 100644 index 196dc2eee..000000000 --- a/spec/features/admin/budget_investment_statuses_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'rails_helper' - -feature 'Admin budget investment statuses' do - - background do - admin = create(:administrator) - login_as(admin.user) - end - - context "Index" do - scenario 'Displaying only not hidden statuses' do - status1 = create(:budget_investment_status) - status2 = create(:budget_investment_status) - - status1.destroy - - visit admin_budget_investment_statuses_path - - expect(page).not_to have_content status1.name - expect(page).not_to have_content status1.description - - expect(page).to have_content status2.name - expect(page).to have_content status2.description - end - - scenario 'Displaying no statuses text' do - visit admin_budget_investment_statuses_path - - expect(page).to have_content("There are no investment statuses created") - end - end - - context "New" do - scenario "Create status" do - visit admin_budget_investment_statuses_path - - click_link 'Create new investment status' - - fill_in 'budget_investment_status_name', with: 'New status name' - fill_in 'budget_investment_status_description', with: 'This status description' - click_button 'Create Investment status' - - expect(page).to have_content 'New status name' - expect(page).to have_content 'This status description' - end - - scenario "Show validation errors in status form" do - visit admin_budget_investment_statuses_path - - click_link 'Create new investment status' - - fill_in 'budget_investment_status_description', with: 'This status description' - click_button 'Create Investment status' - - within "#new_budget_investment_status" do - expect(page).to have_content "can't be blank", count: 1 - end - end - end - - context "Edit" do - scenario "Change name and description" do - status = create(:budget_investment_status) - - visit admin_budget_investment_statuses_path - - within("#budget_investment_status_#{status.id}") do - click_link "Edit" - end - - fill_in 'budget_investment_status_name', with: 'Other status name' - fill_in 'budget_investment_status_description', with: 'Other status description' - click_button 'Update Investment status' - - expect(page).to have_content 'Other status name' - expect(page).to have_content 'Other status description' - end - end - - context "Delete" do - scenario "Hides status" do - status = create(:budget_investment_status) - - visit admin_budget_investment_statuses_path - - within("#budget_investment_status_#{status.id}") do - click_link "Delete" - end - - expect(page).not_to have_content status.name - expect(page).not_to have_content status.description - end - end - -end diff --git a/spec/features/admin/milestone_statuses_spec.rb b/spec/features/admin/milestone_statuses_spec.rb new file mode 100644 index 000000000..e928ce453 --- /dev/null +++ b/spec/features/admin/milestone_statuses_spec.rb @@ -0,0 +1,95 @@ +require 'rails_helper' + +feature 'Admin milestone statuses' do + + background do + admin = create(:administrator) + login_as(admin.user) + end + + context "Index" do + scenario 'Displaying only not hidden statuses' do + status1 = create(:milestone_status) + status2 = create(:milestone_status) + + status1.destroy + + visit admin_milestone_statuses_path + + expect(page).not_to have_content status1.name + expect(page).not_to have_content status1.description + + expect(page).to have_content status2.name + expect(page).to have_content status2.description + end + + scenario 'Displaying no statuses text' do + visit admin_milestone_statuses_path + + expect(page).to have_content("There are no milestone statuses created") + end + end + + context "New" do + scenario "Create status" do + visit admin_milestone_statuses_path + + click_link 'Create new milestone status' + + fill_in 'milestone_status_name', with: 'New status name' + fill_in 'milestone_status_description', with: 'This status description' + click_button 'Create Milestone Status' + + expect(page).to have_content 'New status name' + expect(page).to have_content 'This status description' + end + + scenario "Show validation errors in status form" do + visit admin_milestone_statuses_path + + click_link 'Create new milestone status' + + fill_in 'milestone_status_description', with: 'This status description' + click_button 'Create Milestone Status' + + within "#new_milestone_status" do + expect(page).to have_content "can't be blank", count: 1 + end + end + end + + context "Edit" do + scenario "Change name and description" do + status = create(:milestone_status) + + visit admin_milestone_statuses_path + + within("#milestone_status_#{status.id}") do + click_link "Edit" + end + + fill_in 'milestone_status_name', with: 'Other status name' + fill_in 'milestone_status_description', with: 'Other status description' + click_button 'Update Milestone Status' + + expect(page).to have_content 'Other status name' + expect(page).to have_content 'Other status description' + end + end + + context "Delete" do + scenario "Hides status" do + status = create(:milestone_status) + + visit admin_milestone_statuses_path + + within("#milestone_status_#{status.id}") do + click_link "Delete" + end + + expect(page).not_to have_content status.name + expect(page).not_to have_content status.description + end + end + +end diff --git a/spec/features/budgets/executions_spec.rb b/spec/features/budgets/executions_spec.rb index 9627cb793..226d01cfe 100644 --- a/spec/features/budgets/executions_spec.rb +++ b/spec/features/budgets/executions_spec.rb @@ -12,7 +12,7 @@ feature 'Executions' do let!(:investment3) { create(:budget_investment, :incompatible, heading: heading) } scenario 'only displays investments with milestones' do - create(:budget_investment_milestone, investment: investment1) + create(:milestone, milestoneable: investment1) visit budget_path(budget) click_link 'See results' @@ -28,7 +28,7 @@ feature 'Executions' do end scenario "Do not display headings with no winning investments for selected status" do - create(:budget_investment_milestone, investment: investment1) + create(:milestone, milestoneable: investment1) empty_group = create(:budget_group, budget: budget) empty_heading = create(:budget_heading, group: empty_group, price: 1000) @@ -46,7 +46,7 @@ feature 'Executions' do end scenario "Show message when there are no winning investments with the selected status", :js do - create(:budget_investment_status, name: I18n.t('seeds.budgets.statuses.executed')) + create(:milestone_status, name: I18n.t('seeds.budgets.statuses.executed')) visit budget_path(budget) @@ -63,7 +63,7 @@ feature 'Executions' do context 'Images' do scenario 'renders milestone image if available' do - milestone1 = create(:budget_investment_milestone, investment: investment1) + milestone1 = create(:milestone, milestoneable: investment1) create(:image, imageable: milestone1) visit budget_path(budget) @@ -76,7 +76,7 @@ feature 'Executions' do end scenario 'renders investment image if no milestone image is available' do - create(:budget_investment_milestone, investment: investment2) + create(:milestone, milestoneable: investment2) create(:image, imageable: investment2) visit budget_path(budget) @@ -89,7 +89,7 @@ feature 'Executions' do end scenario 'renders default image if no milestone nor investment images are available' do - create(:budget_investment_milestone, investment: investment4) + create(:milestone, milestoneable: investment4) visit budget_path(budget) @@ -101,17 +101,17 @@ feature 'Executions' do end scenario "renders last milestone's image if investment has multiple milestones with images associated" do - milestone1 = create(:budget_investment_milestone, investment: investment1, - publication_date: Date.yesterday) + milestone1 = create(:milestone, milestoneable: investment1, + publication_date: Date.yesterday) - milestone2 = create(:budget_investment_milestone, investment: investment1, - publication_date: Date.yesterday) + milestone2 = create(:milestone, milestoneable: investment1, + publication_date: Date.yesterday) - milestone3 = create(:budget_investment_milestone, investment: investment1, - publication_date: Date.yesterday) + milestone3 = create(:milestone, milestoneable: investment1, + publication_date: Date.yesterday) - milestone4 = create(:budget_investment_milestone, investment: investment1, - publication_date: Date.yesterday) + milestone4 = create(:milestone, milestoneable: investment1, + publication_date: Date.yesterday) create(:image, imageable: milestone2, title: 'Image for first milestone with image') create(:image, imageable: milestone3, title: 'Image for second milestone with image') @@ -129,17 +129,17 @@ feature 'Executions' do context 'Filters' do - let!(:status1) { create(:budget_investment_status, name: I18n.t('seeds.budgets.statuses.studying_project')) } - let!(:status2) { create(:budget_investment_status, name: I18n.t('seeds.budgets.statuses.bidding')) } + let!(:status1) { create(:milestone_status, name: "Studying the project") } + let!(:status2) { create(:milestone_status, name: "Bidding") } scenario 'Filters select with counter are shown' do - create(:budget_investment_milestone, investment: investment1, - publication_date: Date.yesterday, - status: status1) + create(:milestone, milestoneable: investment1, + publication_date: Date.yesterday, + status: status1) - create(:budget_investment_milestone, investment: investment2, - publication_date: Date.yesterday, - status: status2) + create(:milestone, milestoneable: investment2, + publication_date: Date.yesterday, + status: status2) visit budget_path(budget) @@ -152,9 +152,9 @@ feature 'Executions' do end scenario 'by milestone status', :js do - create(:budget_investment_milestone, investment: investment1, status: status1) - create(:budget_investment_milestone, investment: investment2, status: status2) - create(:budget_investment_status, name: I18n.t('seeds.budgets.statuses.executing_project')) + create(:milestone, milestoneable: investment1, status: status1) + create(:milestone, milestoneable: investment2, status: status2) + create(:milestone_status, name: I18n.t('seeds.budgets.statuses.executing_project')) visit budget_path(budget) @@ -181,13 +181,13 @@ feature 'Executions' do end scenario 'are based on latest milestone status', :js do - create(:budget_investment_milestone, investment: investment1, - publication_date: 1.month.ago, - status: status1) + create(:milestone, milestoneable: investment1, + publication_date: 1.month.ago, + status: status1) - create(:budget_investment_milestone, investment: investment1, - publication_date: Date.yesterday, - status: status2) + create(:milestone, milestoneable: investment1, + publication_date: Date.yesterday, + status: status2) visit budget_path(budget) click_link 'See results' @@ -201,13 +201,13 @@ feature 'Executions' do end scenario 'milestones with future dates are not shown', :js do - create(:budget_investment_milestone, investment: investment1, - publication_date: Date.yesterday, - status: status1) + create(:milestone, milestoneable: investment1, + publication_date: Date.yesterday, + status: status1) - create(:budget_investment_milestone, investment: investment1, - publication_date: Date.tomorrow, - status: status2) + create(:milestone, milestoneable: investment1, + publication_date: Date.tomorrow, + status: status2) visit budget_path(budget) click_link 'See results' @@ -226,7 +226,7 @@ feature 'Executions' do def create_heading_with_investment_with_milestone(group:, name:) heading = create(:budget_heading, group: group, name: name) investment = create(:budget_investment, :winner, heading: heading) - milestone = create(:budget_investment_milestone, investment: investment) + milestone = create(:milestone, milestoneable: investment) heading end @@ -260,8 +260,8 @@ feature 'Executions' do context 'No milestones' do scenario 'Milestone not yet published' do - status = create(:budget_investment_status) - unpublished_milestone = create(:budget_investment_milestone, investment: investment1, + status = create(:milestone_status) + unpublished_milestone = create(:milestone, milestoneable: investment1, status: status, publication_date: Date.tomorrow) visit budget_executions_path(budget, status: status.id) diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index e918e9f52..fd01acfb2 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -1121,13 +1121,13 @@ feature 'Budget Investments' do scenario "Show milestones", :js do user = create(:user) investment = create(:budget_investment) - create(:budget_investment_milestone, investment: investment, - description_en: "Last milestone with a link to https://consul.dev", - description_es: "Último hito con el link https://consul.dev", - publication_date: Date.tomorrow) - first_milestone = create(:budget_investment_milestone, investment: investment, - description: "First milestone", - publication_date: Date.yesterday) + create(:milestone, milestoneable: investment, + description_en: "Last milestone with a link to https://consul.dev", + description_es: "Último hito con el link https://consul.dev", + publication_date: Date.tomorrow) + first_milestone = create(:milestone, milestoneable: investment, + description: "First milestone", + publication_date: Date.yesterday) image = create(:image, imageable: first_milestone) document = create(:document, documentable: first_milestone) diff --git a/spec/lib/tasks/communities_spec.rb b/spec/lib/tasks/communities_spec.rb index 3a8819147..3c3d17682 100644 --- a/spec/lib/tasks/communities_spec.rb +++ b/spec/lib/tasks/communities_spec.rb @@ -1,15 +1,9 @@ require 'rails_helper' -require 'rake' describe 'Communities Rake' do describe '#associate_community' do - before do - Rake.application.rake_require "tasks/communities" - Rake::Task.define_task(:environment) - end - let :run_rake_task do Rake::Task['communities:associate_community'].reenable Rake.application.invoke_task 'communities:associate_community' diff --git a/spec/lib/tasks/dev_seed_spec.rb b/spec/lib/tasks/dev_seed_spec.rb index d3e69f4b9..0bd63035e 100644 --- a/spec/lib/tasks/dev_seed_spec.rb +++ b/spec/lib/tasks/dev_seed_spec.rb @@ -1,7 +1,4 @@ -require 'rake' require 'rails_helper' -Rake::Task.define_task(:environment) -Rake.application.rake_require('tasks/db') describe 'rake db:dev_seed' do let :run_rake_task do diff --git a/spec/lib/tasks/globalize_spec.rb b/spec/lib/tasks/globalize_spec.rb index b685bb95e..26a24dd8a 100644 --- a/spec/lib/tasks/globalize_spec.rb +++ b/spec/lib/tasks/globalize_spec.rb @@ -1,15 +1,9 @@ require "rails_helper" -require "rake" describe "Globalize tasks" do describe "#migrate_data" do - before do - Rake.application.rake_require "tasks/globalize" - Rake::Task.define_task(:environment) - end - let :run_rake_task do Rake::Task["globalize:migrate_data"].reenable Rake.application.invoke_task "globalize:migrate_data" @@ -151,7 +145,7 @@ describe "Globalize tasks" do before { I18n.locale = :"pt-BR" } let!(:milestone) do - create(:budget_investment_milestone).tap do |milestone| + create(:milestone).tap do |milestone| milestone.translations.delete_all milestone.update_column(:title, "Português") milestone.reload diff --git a/spec/lib/tasks/map_location_spec.rb b/spec/lib/tasks/map_location_spec.rb index 8ef004bda..42cae9241 100644 --- a/spec/lib/tasks/map_location_spec.rb +++ b/spec/lib/tasks/map_location_spec.rb @@ -1,6 +1,4 @@ -require 'rake' require 'rails_helper' -Rails.application.load_tasks describe 'rake map_locations:destroy' do before do diff --git a/spec/lib/tasks/milestones_spec.rb b/spec/lib/tasks/milestones_spec.rb new file mode 100644 index 000000000..f4c9dd052 --- /dev/null +++ b/spec/lib/tasks/milestones_spec.rb @@ -0,0 +1,147 @@ +require "rails_helper" + +describe "Milestones tasks" do + describe "#migrate" do + let :run_rake_task do + Rake::Task["milestones:migrate"].reenable + Rake.application.invoke_task "milestones:migrate" + end + + let!(:investment) { create(:budget_investment) } + + before do + ActiveRecord::Base.connection.execute( + "INSERT INTO budget_investment_statuses " + + "(name, description, hidden_at, created_at, updated_at) " + + "VALUES ('open', 'Good', NULL, '#{Time.current - 1.day}', '#{Time.current}');" + ) + + status_id = ActiveRecord::Base.connection.execute( + "SELECT MAX(id) FROM budget_investment_statuses;" + ).to_a.first["max"] + + milestone_attributes = { + investment_id: investment.id, + title: "First", + description: "Interesting", + publication_date: Date.yesterday, + status_id: status_id, + created_at: Time.current - 1.day, + updated_at: Time.current + } + + ActiveRecord::Base.connection.execute( + "INSERT INTO budget_investment_milestones " + + "(#{milestone_attributes.keys.join(", ")}) " + + "VALUES (#{milestone_attributes.values.map { |value| "'#{value}'"}.join(", ")})" + ) + end + + it "migrates statuses" do + run_rake_task + + expect(Milestone::Status.count).to be 1 + + status = Milestone::Status.first + expect(status.name).to eq "open" + expect(status.description).to eq "Good" + expect(status.hidden_at).to be nil + expect(status.created_at.to_date).to eq Date.yesterday + expect(status.updated_at.to_date).to eq Date.current + end + + it "migrates milestones" do + run_rake_task + + expect(Milestone.count).to be 1 + + milestone = Milestone.first + expect(milestone.milestoneable_id).to eq investment.id + expect(milestone.milestoneable_type).to eq "Budget::Investment" + expect(milestone.title).to eq "First" + expect(milestone.description).to eq "Interesting" + expect(milestone.publication_date).to eq Date.yesterday + expect(milestone.status_id).to eq Milestone::Status.first.id + expect(milestone.created_at.to_date).to eq Date.yesterday + expect(milestone.updated_at.to_date).to eq Date.current + end + + it "Updates the primary key sequence correctly" do + run_rake_task + expect { create(:milestone) }.not_to raise_exception + end + + context "Milestone has images and documents" do + let(:milestone_id) do + ActiveRecord::Base.connection.execute( + "SELECT MAX(id) FROM budget_investment_milestones;" + ).to_a.first["max"] + end + + let!(:image) do + create(:image, imageable_id: milestone_id).tap do |image| + image.update_column(:imageable_type, "Budget::Investment::Milestone") + end + end + + let!(:document) do + create(:document, documentable_id: milestone_id).tap do |document| + document.update_column(:documentable_type, "Budget::Investment::Milestone") + end + end + + it "migrates images and documents" do + run_rake_task + + expect(Milestone.last.image).to eq image + expect(Milestone.last.documents).to eq [document] + end + end + + context "Statuses had been deleted" do + before do + ActiveRecord::Base.connection.execute( + "INSERT INTO budget_investment_statuses " + + "(name, description, hidden_at, created_at, updated_at) " + + "VALUES ('deleted', 'Del', NULL, '#{Time.current - 1.day}', '#{Time.current}');" + ) + + ActiveRecord::Base.connection.execute( + "DELETE FROM budget_investment_statuses WHERE name='deleted'" + ) + + ActiveRecord::Base.connection.execute( + "INSERT INTO budget_investment_statuses " + + "(name, description, hidden_at, created_at, updated_at) " + + "VALUES ('new', 'New', NULL, '#{Time.current - 1.day}', '#{Time.current}');" + ) + + status_id = ActiveRecord::Base.connection.execute( + "SELECT MAX(id) FROM budget_investment_statuses;" + ).to_a.first["max"] + + milestone_attributes = { + investment_id: investment.id, + title: "Last", + description: "Different", + publication_date: Date.yesterday, + status_id: status_id, + created_at: Time.current - 1.day, + updated_at: Time.current + } + + ActiveRecord::Base.connection.execute( + "INSERT INTO budget_investment_milestones " + + "(#{milestone_attributes.keys.join(", ")}) " + + "VALUES (#{milestone_attributes.values.map { |value| "'#{value}'"}.join(", ")})" + ) + end + + it "migrates the status id correctly" do + run_rake_task + + expect(Milestone.last.status_id).to eq Milestone::Status.last.id + end + end + end +end diff --git a/spec/lib/tasks/settings_spec.rb b/spec/lib/tasks/settings_spec.rb index 4008cf784..22cee28e1 100644 --- a/spec/lib/tasks/settings_spec.rb +++ b/spec/lib/tasks/settings_spec.rb @@ -1,15 +1,9 @@ require 'rails_helper' -require 'rake' describe 'Settings Rake' do describe '#per_page_code_migration' do - before do - Rake.application.rake_require "tasks/settings" - Rake::Task.define_task(:environment) - end - let :run_rake_task do Rake::Task['settings:per_page_code_migration'].reenable Rake.application.invoke_task 'settings:per_page_code_migration' diff --git a/spec/lib/tasks/sitemap_spec.rb b/spec/lib/tasks/sitemap_spec.rb index cfab39afc..72f0ed461 100644 --- a/spec/lib/tasks/sitemap_spec.rb +++ b/spec/lib/tasks/sitemap_spec.rb @@ -1,7 +1,4 @@ -require 'rake' require 'rails_helper' -Rails.application.load_tasks -Rake::Task.define_task(:environment) feature 'rake sitemap:create' do before do diff --git a/spec/models/budget/investment/status_spec.rb b/spec/models/milestone/status_spec.rb similarity index 71% rename from spec/models/budget/investment/status_spec.rb rename to spec/models/milestone/status_spec.rb index 36d472a76..7e530a995 100644 --- a/spec/models/budget/investment/status_spec.rb +++ b/spec/models/milestone/status_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -describe Budget::Investment::Status do +describe Milestone::Status do describe "Validations" do - let(:status) { build(:budget_investment_status) } + let(:status) { build(:milestone_status) } it "is valid" do expect(status).to be_valid diff --git a/spec/models/budget/investment/milestone_spec.rb b/spec/models/milestone_spec.rb similarity index 77% rename from spec/models/budget/investment/milestone_spec.rb rename to spec/models/milestone_spec.rb index 45d4e7c0b..35f175aea 100644 --- a/spec/models/budget/investment/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -1,9 +1,9 @@ require 'rails_helper' -describe Budget::Investment::Milestone do +describe Milestone do describe "Validations" do - let(:milestone) { build(:budget_investment_milestone) } + let(:milestone) { build(:milestone) } it "is valid" do expect(milestone).to be_valid @@ -25,8 +25,8 @@ describe Budget::Investment::Milestone do expect(milestone).to be_valid end - it "is not valid without an investment" do - milestone.investment_id = nil + it "is not valid without a milestoneable" do + milestone.milestoneable_id = nil expect(milestone).not_to be_valid end @@ -48,7 +48,7 @@ describe Budget::Investment::Milestone do end describe "#description_or_status_present?" do - let(:milestone) { build(:budget_investment_milestone) } + let(:milestone) { build(:milestone) } it "is not valid when status is removed and there's no description" do milestone.update(description: nil) @@ -71,14 +71,14 @@ describe Budget::Investment::Milestone do describe ".published" do it "uses the application's time zone date", :with_different_time_zone do - published_in_local_time_zone = create(:budget_investment_milestone, + published_in_local_time_zone = create(:milestone, publication_date: Date.today) - published_in_application_time_zone = create(:budget_investment_milestone, + published_in_application_time_zone = create(:milestone, publication_date: Date.current) - expect(Budget::Investment::Milestone.published).to include(published_in_application_time_zone) - expect(Budget::Investment::Milestone.published).not_to include(published_in_local_time_zone) + expect(Milestone.published).to include(published_in_application_time_zone) + expect(Milestone.published).not_to include(published_in_local_time_zone) end end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 1385490c8..c3772d5d8 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -12,6 +12,7 @@ require 'capybara/rails' require 'capybara/rspec' require 'selenium/webdriver' +Rails.application.load_tasks if Rake::Task.tasks.empty? I18n.default_locale = :en include Warden::Test::Helpers diff --git a/spec/shared/features/translatable.rb b/spec/shared/features/translatable.rb index bd485334a..4994ab1d5 100644 --- a/spec/shared/features/translatable.rb +++ b/spec/shared/features/translatable.rb @@ -317,7 +317,7 @@ end # even share the same colour. def update_button_text case translatable_class.name - when "Budget::Investment::Milestone" + when "Milestone" "Update milestone" when "AdminNotification" "Update notification"