From f220952883bd072811dd353a46d3f7a0e579ffde Mon Sep 17 00:00:00 2001
From: taitus <%= t("admin.milestones.edit.title") %>
+
+<%= render '/admin/budget_investment_milestones/form' %>
diff --git a/app/views/admin/budget_investment_milestones/new.html.erb b/app/views/admin/budget_investment_milestones/new.html.erb
new file mode 100644
index 000000000..7e065a605
--- /dev/null
+++ b/app/views/admin/budget_investment_milestones/new.html.erb
@@ -0,0 +1,10 @@
+<%= t("admin.milestones.new.creating") %>
+
+ <%= render "form" %>
+
+
+
+<% end %>
diff --git a/app/views/admin/budget_investments/show.html.erb b/app/views/admin/budget_investments/show.html.erb
index a58110c94..f220c0955 100644
--- a/app/views/admin/budget_investments/show.html.erb
+++ b/app/views/admin/budget_investments/show.html.erb
@@ -47,3 +47,12 @@
<%= link_to t("admin.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) %>
+
+
+
+ <% @investment.milestones.each do |milestone| %>
+ <%= t("admin.milestones.index.table_id") %>
+ <%= t("admin.milestones.index.table_title") %>
+ <%= t("admin.milestones.index.table_description") %>
+ <%= t("admin.milestones.index.table_actions") %>
+
+
+ <% end %>
+
+
+ <%= milestone.id %>
+
+
+ <%= link_to milestone.title, edit_admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone) %>
+
+
+ <%= milestone.description %>
+
+
+ <%= link_to t("admin.milestones.index.delete"), admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone),
+ method: :delete,
+ class: 'button hollow alert expanded' %>
+
+
+ <%= link_to t("admin.budget_investments.show.new_milestone"), new_admin_budget_budget_investment_budget_investment_milestone_path(@budget, @investment) %> +
diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index 0af387a50..d45c569d4 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -10,6 +10,9 @@ en: budget/investment: one: "Investment" other: "Investments" + budget/investment/milestone: + one: "milestone" + other: "milestones" comment: one: "Comment" other: "Comments" @@ -98,6 +101,9 @@ en: title: "Title" location: "Location" organization_name: "If you are proposing in the name of a collective/organization, write its name" + budget/investment/milestone: + title: "Title" + description: "Description" comment: body: "Comment" user: "User" diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml index b2b5fc20e..86bb76c87 100644 --- a/config/locales/activerecord.es.yml +++ b/config/locales/activerecord.es.yml @@ -10,6 +10,9 @@ es: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" + budget/investment/milestone: + one: "seguimiento" + other: "seguimientos" comment: one: "Comentario" other: "Comentarios" @@ -96,6 +99,9 @@ es: comment: body: "Comentario" user: "Usuario" + budget/investment/milestone: + title: "Título" + description: "Descripción" debate: author: "Autor" description: "Opinión" diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index bbd8dd1bd..96dc32a8b 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -151,6 +151,8 @@ en: edit_dossier: Edit dossier tags: Tags undefined: Undefined + milestone: Milestone + new_milestone: Create new milestone edit: classification: Clasification assigned_valuators: Valuators @@ -160,6 +162,23 @@ en: tags_placeholder: "Write the tags you want separated by commas (,)" undefined: Undefined search_unfeasible: Search unfeasible + milestones: + index: + table_id: "ID" + table_title: "Title" + table_description: "Description" + table_actions: "Actions" + delete: "Delete milestone" + new: + creating: Create milestone + edit: + title: Edit milestone + create: + notice: New milestone created successfully! + update: + notice: Milestone updated successfully + delete: + notice: Milestone successfully deleted comments: index: filter: Filter diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index a3c6a99b9..405f70152 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -151,6 +151,8 @@ es: edit_dossier: Editar informe tags: Etiquetas undefined: Sin definir + milestone: Seguimiento + new_milestone: Crear nuevo seguimiento edit: classification: Clasificación assigned_valuators: Evaluadores @@ -160,6 +162,23 @@ es: tags_placeholder: "Escribe las etiquetas que desees separadas por comas (,)" undefined: Sin definir search_unfeasible: Buscar inviables + milestones: + index: + table_id: "ID" + table_title: "Título" + table_description: "Descripción" + table_actions: "Acciones" + delete: "Eliminar seguimiento" + new: + creating: Crear seguimiento + edit: + title: Editar seguimiento + create: + notice: Nuevo seguimiento creado con éxito! + update: + notice: Seguimiento actualizado + delete: + notice: Seguimiento borrado correctamente comments: index: filter: Filtro diff --git a/config/routes.rb b/config/routes.rb index 5c5284a91..e436244a1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -199,10 +199,12 @@ Rails.application.routes.draw do end resources :budget_investments, only: [:index, :show, :edit, :update] do + resources :budget_investment_milestones member { patch :toggle_selection } end end + resources :signature_sheets, only: [:index, :new, :create, :show] resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do diff --git a/db/migrate/20170620132731_create_budget_investment_checkpoints.rb b/db/migrate/20170620132731_create_budget_investment_milestones.rb similarity index 57% rename from db/migrate/20170620132731_create_budget_investment_checkpoints.rb rename to db/migrate/20170620132731_create_budget_investment_milestones.rb index 22081f319..199d8e70e 100644 --- a/db/migrate/20170620132731_create_budget_investment_checkpoints.rb +++ b/db/migrate/20170620132731_create_budget_investment_milestones.rb @@ -1,6 +1,6 @@ -class CreateBudgetInvestmentCheckpoints < ActiveRecord::Migration +class CreateBudgetInvestmentMilestones < ActiveRecord::Migration def change - create_table :budget_investment_checkpoints do |t| + create_table :budget_investment_milestones do |t| t.integer :investment_id t.string "title", limit: 80 t.text "description" diff --git a/db/schema.rb b/db/schema.rb index a5d7ecbb5..4cfa7229f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -114,7 +114,7 @@ ActiveRecord::Schema.define(version: 20170620132731) do add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree - create_table "budget_investment_checkpoints", force: :cascade do |t| + create_table "budget_investment_milestones", force: :cascade do |t| t.integer "investment_id" t.string "title", limit: 80 t.text "description" @@ -932,7 +932,7 @@ ActiveRecord::Schema.define(version: 20170620132731) do t.boolean "email_digest", default: true t.boolean "email_on_direct_message", default: true t.boolean "official_position_badge", default: false - t.datetime "password_changed_at", default: '2017-06-20 13:30:34', null: false + t.datetime "password_changed_at", default: '2017-06-22 11:21:30', null: false t.boolean "created_from_signature", default: false t.integer "failed_email_digests_count", default: 0 t.text "former_users_data_log", default: "" diff --git a/spec/factories.rb b/spec/factories.rb index 6401616e7..1d842e299 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -322,10 +322,10 @@ FactoryGirl.define do reason "unfeasible" end - factory :budget_investment_checkpoint, class: 'Budget::Investment::Checkpoint' do + factory :budget_investment_milestone, class: 'Budget::Investment::Milestone' do association :investment, factory: :budget_investment - sequence(:title) { |n| "Budget Investment Checkpoint #{n} title" } - description 'Checkpoint description' + sequence(:title) { |n| "Budget Investment Milestone #{n} title" } + description 'Milestone description' end factory :vote do diff --git a/spec/features/admin/budget_investment_milestones_spec.rb b/spec/features/admin/budget_investment_milestones_spec.rb new file mode 100644 index 000000000..1550f05e6 --- /dev/null +++ b/spec/features/admin/budget_investment_milestones_spec.rb @@ -0,0 +1,70 @@ +require 'rails_helper' + +feature 'Admin budget investment milestones' do + + background do + admin = create(:administrator) + login_as(admin.user) + + @investment = create(:budget_investment) + end + + context "Index" do + scenario 'Displaying milestones' do + milestone = create(:budget_investment_milestone, investment: @investment) + + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + expect(page).to have_content("Milestone") + expect(page).to have_content(milestone.title) + expect(page).to have_content(milestone.id) + end + end + + context "New" do + scenario "Add milestone" do + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + click_link 'Create new milestone' + + fill_in 'budget_investment_milestone_title', with: 'New title milestone' + fill_in 'budget_investment_milestone_description', with: 'New description milestone' + + click_button 'Create milestone' + + expect(page).to have_content 'New title milestone' + expect(page).to have_content 'New description milestone' + end + end + + context "Edit" do + scenario "Change title and description" do + milestone = create(:budget_investment_milestone, investment: @investment) + + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + click_link milestone.title + + fill_in 'budget_investment_milestone_title', with: 'Changed title' + fill_in 'budget_investment_milestone_description', with: 'Changed description' + + click_button 'Update milestone' + + expect(page).to have_content 'Changed title' + expect(page).to have_content 'Changed description' + end + end + + context "Delete" do + scenario "Remove milestone" do + milestone = create(:budget_investment_milestone, investment: @investment, title: "Title will it remove") + + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + click_link "Delete milestone" + + expect(page).to_not have_content 'Title will it remove' + end + end + +end diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 52c008c18..c50a05f32 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -27,7 +27,7 @@ feature 'Admin budget investments' do context "Index" do - scenario 'Displaying investmentss' do + scenario 'Displaying investments' do budget_investment = create(:budget_investment, budget: @budget, cached_votes_up: 77) visit admin_budget_budget_investments_path(budget_id: @budget.id) expect(page).to have_content(budget_investment.title) diff --git a/spec/models/budget/investment/checkpoint_spec.rb b/spec/models/budget/investment/checkpoint_spec.rb deleted file mode 100644 index fe40a58bb..000000000 --- a/spec/models/budget/investment/checkpoint_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -describe "Budget::Investment::Checkpoint" do - - describe "Validations" do - let(:checkpoint) { build(:budget_investment_checkpoint) } - - it "should be valid" do - expect(checkpoint).to be_valid - end - - it "should not be valid without a title" do - checkpoint.title = nil - expect(checkpoint).to_not be_valid - end - - it "should not be valid without an investment" do - checkpoint.investment_id = nil - expect(checkpoint).to_not be_valid - end - end - -end diff --git a/spec/models/budget/investment/milestone_spec.rb b/spec/models/budget/investment/milestone_spec.rb new file mode 100644 index 000000000..5fc749d36 --- /dev/null +++ b/spec/models/budget/investment/milestone_spec.rb @@ -0,0 +1,23 @@ +require 'rails_helper' + +describe "Budget::Investment::Milestone" do + + describe "Validations" do + let(:milestone) { build(:budget_investment_milestone) } + + it "should be valid" do + expect(milestone).to be_valid + end + + it "should not be valid without a title" do + milestone.title = nil + expect(milestone).to_not be_valid + end + + it "should not be valid without an investment" do + milestone.investment_id = nil + expect(milestone).to_not be_valid + end + end + +end