Browse Source

CLDC-2674 Fix delete duplicates cancel and back buttons (#1936)

* feat: fix duplicate log back behaviour

* feat: fix duplicate log cancel behaviour

* feat: fix duplicate log back behaviour and add tests

* feat: update remaining tests
pull/1944/head
natdeanlewissoftwire 1 year ago committed by GitHub
parent
commit
f1e4f9f9ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/views/logs/delete_duplicates.html.erb
  2. 16
      spec/requests/duplicate_logs_controller_spec.rb

4
app/views/logs/delete_duplicates.html.erb

@ -1,6 +1,6 @@
<% content_for :before_content do %>
<% content_for :title, "Are you sure you want to delete #{@duplicate_logs.count == 1 ? 'this duplicate log' : 'these duplicate logs'}?" %>
<%= govuk_back_link href: @log.lettings? ? lettings_log_duplicate_logs_path(@log) : sales_log_duplicate_logs_path(@log) %>
<%= govuk_back_link href: @log.lettings? ? lettings_log_duplicate_logs_path(@original_log, original_log_id: @original_log.id) : sales_log_duplicate_logs_path(@original_log, original_log_id: @original_log.id) %>
<% end %>
<div class="govuk-grid-row">
@ -32,7 +32,7 @@
params: { ids: @duplicate_logs.map(&:id), original_log_id: @original_log.id, remaining_log_id: @log.id } %>
<%= govuk_button_link_to(
"Cancel",
send("#{@log.class.name.underscore}_duplicate_logs_path", @log),
send("#{@log.class.name.underscore}_duplicate_logs_path", @original_log, original_log_id: @original_log.id),
secondary: true,
) %>
</div>

16
spec/requests/duplicate_logs_controller_spec.rb

@ -192,8 +192,8 @@ RSpec.describe DuplicateLogsController, type: :request do
expect(page).to have_button(text: "Delete this log")
expect(page).to have_link(text: "Log #{duplicate_log.id}", href: sales_log_path(duplicate_log.id))
expect(page).not_to have_link(text: "Log #{id}", href: sales_log_path(id))
expect(page).to have_link(text: "Cancel", href: sales_log_duplicate_logs_path(id))
expect(page).to have_link(text: "Back", href: sales_log_duplicate_logs_path(id))
expect(page).to have_link(text: "Cancel", href: sales_log_duplicate_logs_path(id, original_log_id: id))
expect(page).to have_link(text: "Back", href: sales_log_duplicate_logs_path(id, original_log_id: id))
end
end
@ -210,8 +210,8 @@ RSpec.describe DuplicateLogsController, type: :request do
expect(page).to have_button(text: "Delete these logs")
expect(page).to have_link(text: "Log #{duplicate_log.id}", href: sales_log_path(duplicate_log.id))
expect(page).to have_link(text: "Log #{duplicate_log_2.id}", href: sales_log_path(duplicate_log_2.id))
expect(page).to have_link(text: "Cancel", href: sales_log_duplicate_logs_path(id))
expect(page).to have_link(text: "Back", href: sales_log_duplicate_logs_path(id))
expect(page).to have_link(text: "Cancel", href: sales_log_duplicate_logs_path(id, original_log_id: id))
expect(page).to have_link(text: "Back", href: sales_log_duplicate_logs_path(id, original_log_id: id))
end
end
@ -267,8 +267,8 @@ RSpec.describe DuplicateLogsController, type: :request do
expect(page).to have_button(text: "Delete this log")
expect(page).to have_link(text: "Log #{duplicate_log.id}", href: lettings_log_path(duplicate_log.id))
expect(page).not_to have_link(text: "Log #{id}", href: lettings_log_path(id))
expect(page).to have_link(text: "Cancel", href: lettings_log_duplicate_logs_path(id))
expect(page).to have_link(text: "Back", href: lettings_log_duplicate_logs_path(id))
expect(page).to have_link(text: "Cancel", href: lettings_log_duplicate_logs_path(id, original_log_id: id))
expect(page).to have_link(text: "Back", href: lettings_log_duplicate_logs_path(id, original_log_id: id))
end
end
@ -285,8 +285,8 @@ RSpec.describe DuplicateLogsController, type: :request do
expect(page).to have_button(text: "Delete these logs")
expect(page).to have_link(text: "Log #{duplicate_log.id}", href: lettings_log_path(duplicate_log.id))
expect(page).to have_link(text: "Log #{duplicate_log_2.id}", href: lettings_log_path(duplicate_log_2.id))
expect(page).to have_link(text: "Cancel", href: lettings_log_duplicate_logs_path(id))
expect(page).to have_link(text: "Back", href: lettings_log_duplicate_logs_path(id))
expect(page).to have_link(text: "Cancel", href: lettings_log_duplicate_logs_path(id, original_log_id: id))
expect(page).to have_link(text: "Back", href: lettings_log_duplicate_logs_path(id, original_log_id: id))
end
end

Loading…
Cancel
Save