diff --git a/app/helpers/log_actions_helper.rb b/app/helpers/log_actions_helper.rb index 760a5523b..8f02ccbf5 100644 --- a/app/helpers/log_actions_helper.rb +++ b/app/helpers/log_actions_helper.rb @@ -38,7 +38,7 @@ private if policy_class_for(log).new(current_user, log).destroy? govuk_button_link_to( "Delete log", - lettings_log_delete_confirmation_path(log), + log.lettings? ? lettings_log_delete_confirmation_path(log) : sales_log_delete_confirmation_path(log), warning: true, ) end diff --git a/spec/views/logs/edit.html.erb_spec.rb b/spec/views/logs/edit.html.erb_spec.rb index dd038448c..6ac12230d 100644 --- a/spec/views/logs/edit.html.erb_spec.rb +++ b/spec/views/logs/edit.html.erb_spec.rb @@ -3,6 +3,7 @@ require "rails_helper" RSpec.describe "logs/edit.html.erb" do before do assign(:log, log) + sign_in create(:user, :support) end context "when log is in progress" do @@ -15,6 +16,14 @@ RSpec.describe "logs/edit.html.erb" do expect(fragment).not_to have_link(text: "Back to lettings logs", href: "/lettings-logs") end + + it "has link 'Delete log'" do + render + + fragment = Capybara::Node::Simple.new(rendered) + + expect(fragment).to have_link(text: "Delete log", href: "/lettings-logs/#{log.id}/delete-confirmation") + end end context "when log is completed" do @@ -28,6 +37,14 @@ RSpec.describe "logs/edit.html.erb" do expect(fragment).to have_link(text: "Back to lettings logs", href: "/lettings-logs") end + + it "has link 'Delete log'" do + render + + fragment = Capybara::Node::Simple.new(rendered) + + expect(fragment).to have_link(text: "Delete log", href: "/lettings-logs/#{log.id}/delete-confirmation") + end end context "when showing a sales log" do @@ -40,6 +57,14 @@ RSpec.describe "logs/edit.html.erb" do expect(fragment).to have_link(text: "Back to sales logs", href: "/sales-logs") end + + it "has link 'Delete log'" do + render + + fragment = Capybara::Node::Simple.new(rendered) + + expect(fragment).to have_link(text: "Delete log", href: "/sales-logs/#{log.id}/delete-confirmation") + end end context "when lettings log is bulk uploaded" do @@ -53,6 +78,14 @@ RSpec.describe "logs/edit.html.erb" do expect(fragment).to have_link(text: "Back to uploaded logs", href: "/lettings-logs/bulk-upload-results/#{bulk_upload.id}/resume") end + + it "has link 'Delete log'" do + render + + fragment = Capybara::Node::Simple.new(rendered) + + expect(fragment).to have_link(text: "Delete log", href: "/lettings-logs/#{log.id}/delete-confirmation") + end end context "when sales log is bulk uploaded" do @@ -66,6 +99,14 @@ RSpec.describe "logs/edit.html.erb" do expect(fragment).to have_link(text: "Back to uploaded logs", href: "/sales-logs/bulk-upload-results/#{bulk_upload.id}/resume") end + + it "has link 'Delete log'" do + render + + fragment = Capybara::Node::Simple.new(rendered) + + expect(fragment).to have_link(text: "Delete log", href: "/sales-logs/#{log.id}/delete-confirmation") + end end end end