From 071da81be64878ac873c9cad25f094c48e0cd0da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 13 Jun 2021 14:40:56 +0200 Subject: [PATCH] Add notice when supporting an investment It was hard to notice what was going on when supporting one investment which was at the bottom of the investment index page. I wonder whether we should add the title of the investment to this text; I'm not doing so because we don't do that anywhere else. --- app/controllers/budgets/investments_controller.rb | 7 ++++++- .../management/budgets/investments_controller.rb | 7 ++++++- config/locales/en/responders.yml | 1 + config/locales/es/responders.yml | 1 + spec/system/budgets/votes_spec.rb | 2 ++ spec/system/management/budget_investments_spec.rb | 1 + 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index c0eec21bb..b07d25b24 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -92,8 +92,13 @@ module Budgets def vote @investment.register_selection(current_user) + respond_to do |format| - format.html { redirect_to budget_investments_path(heading_id: @investment.heading.id) } + format.html do + redirect_to budget_investments_path(heading_id: @investment.heading.id), + notice: t("flash.actions.create.support") + end + format.js end end diff --git a/app/controllers/management/budgets/investments_controller.rb b/app/controllers/management/budgets/investments_controller.rb index ba32122fd..68abcbb84 100644 --- a/app/controllers/management/budgets/investments_controller.rb +++ b/app/controllers/management/budgets/investments_controller.rb @@ -40,8 +40,13 @@ class Management::Budgets::InvestmentsController < Management::BaseController def vote @investment.register_selection(managed_user) + respond_to do |format| - format.html { redirect_to management_budget_investments_path(heading_id: @investment.heading.id) } + format.html do + redirect_to management_budget_investments_path(heading_id: @investment.heading.id), + notice: t("flash.actions.create.support") + end + format.js end end diff --git a/config/locales/en/responders.yml b/config/locales/en/responders.yml index 82ee36271..7fb544b97 100644 --- a/config/locales/en/responders.yml +++ b/config/locales/en/responders.yml @@ -14,6 +14,7 @@ en: proposal_notification: "Your message has been sent correctly." budget_investment: "Budget Investment created successfully." signature_sheet: "Signature sheet created successfully" + support: "Investment supported successfully" topic: "Topic created successfully." valuator_group: "Valuator group created successfully" save_changes: diff --git a/config/locales/es/responders.yml b/config/locales/es/responders.yml index fc12f9961..6092cf9ff 100644 --- a/config/locales/es/responders.yml +++ b/config/locales/es/responders.yml @@ -14,6 +14,7 @@ es: proposal_notification: "Tu mensaje ha sido enviado correctamente." budget_investment: "Proyecto de gasto creado correctamente." signature_sheet: "Hoja de firmas creada correctamente" + support: "Proyecto de gasto apoyado correctamente" topic: "Tema creado correctamente." valuator_group: "Grupo de evaluadores creado correctamente" save_changes: diff --git a/spec/system/budgets/votes_spec.rb b/spec/system/budgets/votes_spec.rb index 5e1aff243..2a9de4659 100644 --- a/spec/system/budgets/votes_spec.rb +++ b/spec/system/budgets/votes_spec.rb @@ -127,6 +127,8 @@ describe "Votes" do "Share it!" end + expect(page).to have_content "Investment supported successfully" + visit budget_investments_path(budget, heading_id: san_francisco.id) within("#budget_investment_#{san_francisco_investment.id}") do diff --git a/spec/system/management/budget_investments_spec.rb b/spec/system/management/budget_investments_spec.rb index eafb51d94..382ff4a63 100644 --- a/spec/system/management/budget_investments_spec.rb +++ b/spec/system/management/budget_investments_spec.rb @@ -329,6 +329,7 @@ describe "Budget Investments" do expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this investment project. Share it!" + expect(page).to have_content "Investment supported successfully" expect(page).to have_content "CONSUL\nMANAGEMENT" end