Browse Source

bugfix: route to correct log type (#1640)

pull/1647/head v0.3.21
Jack 2 years ago committed by GitHub
parent
commit
6b71968344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/helpers/log_actions_helper.rb
  2. 41
      spec/views/logs/edit.html.erb_spec.rb

2
app/helpers/log_actions_helper.rb

@ -38,7 +38,7 @@ private
if policy_class_for(log).new(current_user, log).destroy? if policy_class_for(log).new(current_user, log).destroy?
govuk_button_link_to( govuk_button_link_to(
"Delete log", "Delete log",
lettings_log_delete_confirmation_path(log), log.lettings? ? lettings_log_delete_confirmation_path(log) : sales_log_delete_confirmation_path(log),
warning: true, warning: true,
) )
end end

41
spec/views/logs/edit.html.erb_spec.rb

@ -3,6 +3,7 @@ require "rails_helper"
RSpec.describe "logs/edit.html.erb" do RSpec.describe "logs/edit.html.erb" do
before do before do
assign(:log, log) assign(:log, log)
sign_in create(:user, :support)
end end
context "when log is in progress" do 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") expect(fragment).not_to have_link(text: "Back to lettings logs", href: "/lettings-logs")
end 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 end
context "when log is completed" do 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") expect(fragment).to have_link(text: "Back to lettings logs", href: "/lettings-logs")
end 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 end
context "when showing a sales log" do 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") expect(fragment).to have_link(text: "Back to sales logs", href: "/sales-logs")
end 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
context "when lettings log is bulk uploaded" do 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") expect(fragment).to have_link(text: "Back to uploaded logs", href: "/lettings-logs/bulk-upload-results/#{bulk_upload.id}/resume")
end 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 end
context "when sales log is bulk uploaded" do 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") expect(fragment).to have_link(text: "Back to uploaded logs", href: "/sales-logs/bulk-upload-results/#{bulk_upload.id}/resume")
end 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 end
end end

Loading…
Cancel
Save