Adds delete link to budget investment list in user activities

This commit is contained in:
kikito
2017-03-06 19:24:10 +01:00
parent 24920e73f6
commit 3dbdc8f455
6 changed files with 26 additions and 3 deletions

View File

@@ -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

View File

@@ -4,6 +4,11 @@
<td>
<%= link_to budget_investment.title, budget_investment_path(budget_investment.budget, budget_investment) %>
</td>
<td>
<% if can? :destroy, budget_investment %>
<%= link_to t('shared.delete'), budget_investment_path(budget_investment.budget, budget_investment), method: :delete %>
<% end %>
</td>
</tr>
<% end %>
</table>

View File

@@ -428,6 +428,7 @@ en:
search: 'Filter'
title: 'Advanced search'
to: 'To'
delete: Delete
author_info:
author_deleted: User deleted
back: Go back

View File

@@ -428,6 +428,7 @@ es:
search: 'Filtrar'
title: 'Búsqueda avanzada'
to: 'Hasta'
delete: 'Borrar'
author_info:
author_deleted: Usuario eliminado
back: Volver

View File

@@ -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

View File

@@ -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)