From 8eaf0982b1d5fcaf33ff5fcf6e5eaa7f4017d632 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 20 Jan 2018 11:17:56 +0100 Subject: [PATCH] Fixed Admin Budget's destroy button to a link Why: The Admin Budget form has a submit button for saving the record, adding another submit input to destroy the record actually adds to the html: `` and it collides with the save button, forcing it to perform a destroy instead of save. Previously the destroy button was not in the same div as the save button How: Just changing the Destroy from a button_to to a link_to. --- app/views/admin/budgets/_form.html.erb | 2 +- spec/features/admin/budgets_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb index 9b96107ac..44e395f6f 100644 --- a/app/views/admin/budgets/_form.html.erb +++ b/app/views/admin/budgets/_form.html.erb @@ -62,7 +62,7 @@ <% end %> <% if @budget.persisted? %> - <%= button_to t("admin.budgets.edit.delete"), admin_budget_path(@budget), method: :delete, class: "button hollow alert float-right" %> + <%= link_to t("admin.budgets.edit.delete"), admin_budget_path(@budget), method: :delete, class: "button hollow alert float-right" %> <% end %> diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 7bf48903f..7da02b559 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -116,7 +116,7 @@ feature 'Admin budgets' do scenario 'Destroy a budget without investments' do visit admin_budgets_path click_link 'Edit budget' - click_button 'Delete budget' + click_link 'Delete budget' expect(page).to have_content('Budget deleted successfully') expect(page).to have_content('budgets cannot be found') @@ -127,7 +127,7 @@ feature 'Admin budgets' do visit admin_budgets_path click_link 'Edit budget' - click_button 'Delete budget' + click_link 'Delete budget' expect(page).to have_content('You cannot destroy a Budget that has associated investments') expect(page).to have_content('There is 1 budget')