diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb
index 0a5e78eef..7f9c6e7ee 100644
--- a/app/controllers/budgets/investments_controller.rb
+++ b/app/controllers/budgets/investments_controller.rb
@@ -55,7 +55,7 @@ module Budgets
end
def destroy
- investment.destroy
+ @investment.destroy
redirect_to user_path(current_user, filter: 'budget_investments'), notice: t('flash.actions.destroy.budget_investment')
end
diff --git a/app/views/users/_budget_investments.html.erb b/app/views/users/_budget_investments.html.erb
index b5773cbdf..d16f022ce 100644
--- a/app/views/users/_budget_investments.html.erb
+++ b/app/views/users/_budget_investments.html.erb
@@ -4,6 +4,11 @@
<%= link_to budget_investment.title, budget_investment_path(budget_investment.budget, budget_investment) %>
|
+
+ <% if can? :destroy, budget_investment %>
+ <%= link_to t('shared.delete'), budget_investment_path(budget_investment.budget, budget_investment), method: :delete %>
+ <% end %>
+ |
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index dd9624188..0e8462cb8 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -428,6 +428,7 @@ en:
search: 'Filter'
title: 'Advanced search'
to: 'To'
+ delete: Delete
author_info:
author_deleted: User deleted
back: Go back
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 0b8fa4b1c..ba9b2c706 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -428,6 +428,7 @@ es:
search: 'Filtrar'
title: 'Búsqueda avanzada'
to: 'Hasta'
+ delete: 'Borrar'
author_info:
author_deleted: Usuario eliminado
back: Volver
diff --git a/config/routes.rb b/config/routes.rb
index cc76297f6..8d5e84ad3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -298,7 +298,7 @@ Rails.application.routes.draw do
get :support_investments
get :print_investments
end
- resources :investments, only: [:index, :new, :create, :show], controller: 'budgets/investments' do
+ resources :investments, only: [:index, :new, :create, :show, :destroy], controller: 'budgets/investments' do
post :vote, on: :member
get :print, on: :collection
end
diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb
index a6feb6f44..323948c16 100644
--- a/spec/features/budgets/investments_spec.rb
+++ b/spec/features/budgets/investments_spec.rb
@@ -315,6 +315,20 @@ feature 'Budget Investments' do
end
end
+ scenario "Author can destroy while on the selecting phase" do
+ user = create(:user, :level_two)
+ sp1 = create(:budget_investment, :selected, heading: heading, price: 10000, author: user)
+
+ login_as(user)
+ visit user_path(user, tab: :budget_investments)
+
+ within("#budget_investment_#{sp1.id}") do
+ expect(page).to have_content(sp1.title)
+ click_link('Delete')
+ end
+
+ visit user_path(user, tab: :budget_investments)
+ end
end
context "Selecting Phase" do
@@ -476,6 +490,8 @@ feature 'Budget Investments' do
expect(page).to have_content "€10,000"
end
+
+
scenario "Sidebar in show should display vote text" do
investment = create(:budget_investment, :selected, budget: budget)
visit budget_investment_path(budget, investment)
@@ -561,4 +577,4 @@ feature 'Budget Investments' do
end
end
-end
\ No newline at end of file
+end