Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

862 lines
48 KiB

require "rails_helper"
RSpec.describe DuplicateLogsController, type: :request do
let(:page) { Capybara::Node::Simple.new(response.body) }
let(:user) { create(:user, :data_coordinator) }
let(:lettings_log) { create(:lettings_log, :duplicate, assigned_to: user) }
let(:sales_log) { create(:sales_log, :duplicate, assigned_to: user) }
describe "GET show" do
before do
Timecop.freeze(Time.zone.local(2024, 3, 1))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
Singleton.__init__(FormHandler)
end
context "when user is not signed in" do
it "redirects to sign in page" do
get "/lettings-logs/#{lettings_log.id}/duplicate-logs"
expect(response).to redirect_to("/account/sign-in")
end
end
context "when the user is from different organisation" do
let(:other_user) { create(:user) }
before do
allow(other_user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in other_user
end
it "renders page not found" do
get "/lettings-logs/#{lettings_log.id}/duplicate-logs"
expect(response).to have_http_status(:not_found)
end
end
context "when user is signed in" do
context "when user is support" do
let(:support_user_org) { create(:organisation) }
let(:user) { create(:user, :support, organisation: support_user_org) }
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
end
context "when viewing lettings logs duplicates" do
context "when there are multiple duplicate logs" do
let(:duplicate_logs) { create_list(:lettings_log, 2, :completed) }
before do
allow(LettingsLog).to receive(:duplicate_logs).and_return(duplicate_logs)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}&organisation_id=#{lettings_log.owning_organisation_id}"
end
it "displays links to all the duplicate logs" do
expect(page).to have_link("Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}")
expect(page).to have_link("Log #{duplicate_logs.first.id}", href: "/lettings-logs/#{duplicate_logs.first.id}")
expect(page).to have_link("Log #{duplicate_logs.second.id}", href: "/lettings-logs/#{duplicate_logs.second.id}")
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q5 - Tenancy start date", count: 3)
expect(page).to have_content("Q7 - Tenant code", count: 3)
expect(page).to have_content("Q32 - Lead tenant’s age", count: 3)
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 3)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 3)
expect(page).to have_content("Household rent and charges", count: 3)
expect(page).to have_link("Change", count: 24)
expect(page).to have_link("Change", href: "/lettings-logs/#{lettings_log.id}/tenant-code?first_remaining_duplicate_id=#{duplicate_logs[0].id}&organisation_id=#{lettings_log.owning_organisation_id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/lettings-logs/#{duplicate_logs[0].id}/tenant-code?first_remaining_duplicate_id=#{lettings_log.id}&organisation_id=#{lettings_log.owning_organisation_id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/lettings-logs/#{duplicate_logs[1].id}/tenant-code?first_remaining_duplicate_id=#{lettings_log.id}&organisation_id=#{lettings_log.owning_organisation_id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs")
end
it "displays check your answers for each log with correct questions where UPRN is given" do
CLDC-3787: Autocomplete address uprn search (#2967) * Prototype * Remove git from dockerfile * UPRN search too * Revert address client and use uprn client * Add address search to lettings too * Updates with lettings logs * Update copy * Move guidance to partial * Fix uprn return * Delete new db file, restore old * Lint * Remove old db file * Lint * Add new db file, remove old * JS lint * Update schema * Add manual entry option * Update derived variables * Comment out old version of find address in 2024 * Remove db column * Add new db columns * Update guidance partial * Add unless to migration * Add migration files to remove and readd * authenticate user * Remove file * Delete migration files * Add search url * Add search url * Fix onConfirm * Add manual entry button instead of change skip link * Revert "Add manual entry button instead of change skip link" This reverts commit 22577c801aca940acfc16caf94d3159071ea8258. * Revert "Revert "Add manual entry button instead of change skip link"" This reverts commit 9f0a2111a58e933a28105e54aba6ca08c2d043b7. * Replace uprn question * Update question copy * Allow changing the address search value * Rename address autocomplete to address search * Add buttons to switch between address questions * Fix controller logic * Enable adding question numbers to page headers * Update skip links * Add js disabled message to select * Alternative way to handle js disabled users * Revert "Alternative way to handle js disabled users" This reverts commit 10da3d61e2f89ec29ef9f9071c63eb99aa2bb482. * Fix typo * Fix address options for address search question * Reuse AddressDataPresenter where appropriate * Lint * Remove uprn selection question tests * Reuse UprnDataPresenter where appropriate * CSV export, exclude address_search * Add address search to sales and lettings factory bots * Exclude old address questions from routing, keep as exported values * lint * Update uprn value * Add address search input boolean and switch between questions * Reword copy, remove "Find" and "Search by" * Align address questions, add question number and question text * Remove old wip depends on * Update some tests * Update migration, move default value from db to model * Update test * Remove binding pry * Lint * Update test * Lint * Update test * Update routes with underscores * Remove debugging * Limit visible logs to user * Add manual address entry selected variable * Change address search min length to 3chars * Remove binding.pry * Update factory bots, manual_address_entry_selected to true for preexisting tests * Update model tests * Update sales model tests excl E-code tests * Update address search request test * Reuse uprn id instead of address_search * Set manual address entry selected as false when creating test logs * Update model test * Update request tests and remove old questions * Add back test * Update services * Update more tests Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com> * Update request tests * update model tests * Also update sales log * Update service csv uprn_selection values to 1 * Add tests for pages and questions * Update test * Update uprn_known * Lint * Add feature test * Update test * Update tests * Remove test * pre-consolidate migration files * Indentation * Controller method improvements * Update question numbers for 2025/26 * Update question numbers tests * consolidate and delete old migration files * undo changes to schema.rb * Update 2025 property information translation files * Update answer options to show singular previously selected result if present * Move buttons to bottom guidance partials * Small improvements, make address search and existing search more similar * Validate entered addresses as within England * Update test * Revert "Validate entered addresses as within England" This reverts commit 2dbfbcc8a5188cde7fb0ac0dcdbc5919eefd6a12. * Add missing button to sales address page * Change error code * Clear invalid options * Edit no results message method * Keep no result logic just change text * Display uprn value with address value * Still show no results message when characters entered is less than 3 rather than nothing * Fix uprn result when query is ambiguous * Reduce min match for address search * Hide no result found message just before results are populated * Prevent changing logs to 2025 with invalid addresses * Correct attribute name * Handle nil * Remove custom error message * Remove unused variables from factory * Update tests, remove address and postcode from old find address * Fix bug clearing uprn from see all answers * Revert "Fix bug clearing uprn from see all answers" This reverts commit a66c47a1abf7a429f25e0a016fedb0b92e92f15c. * Undo changes to validation method * Fix unchanged uprn_selection when clearing or changing uprn * Undo a change * Update bulk upload 2025 * Fix typo * Remove redundant line --------- Co-authored-by: Kat <54268893+kosiakkatrina@users.noreply.github.com> Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com>
1 week ago
lettings_log.update!(uprn: "123", uprn_known: 1, uprn_confirmed: 1, manual_address_entry_selected: false)
duplicate_logs[0].update!(uprn: "123", uprn_known: 1, uprn_confirmed: 1, manual_address_entry_selected: false)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}"
expect(page).to have_content("Q5 - Tenancy start date", count: 3)
expect(page).to have_content("Q7 - Tenant code", count: 3)
expect(page).to have_content("Postcode (from UPRN)", count: 2)
expect(page).to have_content("Q32 - Lead tenant’s age", count: 3)
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 3)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 3)
expect(page).to have_content("Household rent and charges", count: 3)
expect(page).to have_link("Change", count: 24)
expect(page).to have_link("Change", href: "/lettings-logs/#{lettings_log.id}/tenant-code?first_remaining_duplicate_id=#{duplicate_logs[0].id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/lettings-logs/#{duplicate_logs[0].id}/tenant-code?first_remaining_duplicate_id=#{lettings_log.id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/lettings-logs/#{duplicate_logs[1].id}/tenant-code?first_remaining_duplicate_id=#{lettings_log.id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs")
end
it "displays buttons to delete" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3)
expect(page).to have_link("Keep this log and delete duplicates", href: "/lettings-logs/#{lettings_log.id}/delete-duplicates?organisation_id=#{lettings_log.owning_organisation_id}&original_log_id=#{lettings_log.id}")
expect(page).to have_link("Keep this log and delete duplicates", href: "/lettings-logs/#{duplicate_logs.first.id}/delete-duplicates?organisation_id=#{lettings_log.owning_organisation_id}&original_log_id=#{lettings_log.id}")
expect(page).to have_link("Keep this log and delete duplicates", href: "/lettings-logs/#{duplicate_logs.second.id}/delete-duplicates?organisation_id=#{lettings_log.owning_organisation_id}&original_log_id=#{lettings_log.id}")
end
end
context "when there are no more duplicate logs" do
context "when accessed from the duplicate logs banner flow" do
before do
allow(LettingsLog).to receive(:duplicate_logs).and_return(LettingsLog.none)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}&organisation_id=#{lettings_log.owning_organisation_id}&referrer=duplicate_logs_banner"
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q5 - Tenancy start date", count: 1)
expect(page).to have_content("Q7 - Tenant code", count: 1)
expect(page).to have_content("Q32 - Lead tenant’s age", count: 1)
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 1)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 1)
expect(page).to have_content("Household rent and charges", count: 1)
expect(page).to have_link("Change", count: 8)
expect(page).to have_link("Change", href: "/lettings-logs/#{lettings_log.id}/tenant-code?original_log_id=#{lettings_log.id}&referrer=interruption_screen")
end
it "displays button to review other duplicates" do
expect(page).to have_link("Review other duplicates", href: "/organisations/#{lettings_log.owning_organisation_id}/duplicates?referrer=duplicate_logs_banner")
end
it "displays no duplicates banner" do
expect(page).to have_content("This log had the same answers but it is no longer a duplicate. Make sure the answers are correct.")
end
end
context "when accessed from the single log submission flow" do
before do
allow(LettingsLog).to receive(:duplicate_logs).and_return(LettingsLog.none)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}&organisation_id=#{lettings_log.owning_organisation_id}"
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q5 - Tenancy start date", count: 1)
expect(page).to have_content("Q7 - Tenant code", count: 1)
expect(page).to have_content("Q32 - Lead tenant’s age", count: 1)
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 1)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 1)
expect(page).to have_content("Household rent and charges", count: 1)
expect(page).to have_link("Change", count: 8)
expect(page).to have_link("Change", href: "/lettings-logs/#{lettings_log.id}/tenant-code?original_log_id=#{lettings_log.id}&referrer=interruption_screen")
end
it "displays button to return to log" do
expect(page).to have_link("Back to Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}")
end
it "displays no duplicates banner" do
expect(page).to have_content("This log had the same answers but it is no longer a duplicate. Make sure the answers are correct.")
end
end
end
end
context "when viewing sales logs duplicates" do
context "when there are multiple duplicate logs" do
let(:duplicate_logs) { create_list(:sales_log, 2, :completed) }
before do
allow(SalesLog).to receive(:duplicate_logs).and_return(duplicate_logs)
get "/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}&organisation_id=#{sales_log.owning_organisation_id}"
end
it "displays links to all the duplicate logs" do
expect(page).to have_link("Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
expect(page).to have_link("Log #{duplicate_logs.first.id}", href: "/sales-logs/#{duplicate_logs.first.id}")
expect(page).to have_link("Log #{duplicate_logs.second.id}", href: "/sales-logs/#{duplicate_logs.second.id}")
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q1 - Sale completion date", count: 3)
expect(page).to have_content("Q2 - Purchaser code", count: 3)
expect(page).to have_content("Q20 - Buyer 1’s age", count: 3)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 3)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 3)
expect(page).to have_content("Q15 - Postcode", count: 3)
expect(page).to have_link("Change", count: 21)
expect(page).to have_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?first_remaining_duplicate_id=#{duplicate_logs[0].id}&organisation_id=#{sales_log.owning_organisation_id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/sales-logs/#{duplicate_logs[0].id}/purchaser-code?first_remaining_duplicate_id=#{sales_log.id}&organisation_id=#{sales_log.owning_organisation_id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/sales-logs/#{duplicate_logs[1].id}/purchaser-code?first_remaining_duplicate_id=#{sales_log.id}&organisation_id=#{sales_log.owning_organisation_id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
end
it "displays check your answers for each log with correct questions when UPRN is given" do
CLDC-3787: Autocomplete address uprn search (#2967) * Prototype * Remove git from dockerfile * UPRN search too * Revert address client and use uprn client * Add address search to lettings too * Updates with lettings logs * Update copy * Move guidance to partial * Fix uprn return * Delete new db file, restore old * Lint * Remove old db file * Lint * Add new db file, remove old * JS lint * Update schema * Add manual entry option * Update derived variables * Comment out old version of find address in 2024 * Remove db column * Add new db columns * Update guidance partial * Add unless to migration * Add migration files to remove and readd * authenticate user * Remove file * Delete migration files * Add search url * Add search url * Fix onConfirm * Add manual entry button instead of change skip link * Revert "Add manual entry button instead of change skip link" This reverts commit 22577c801aca940acfc16caf94d3159071ea8258. * Revert "Revert "Add manual entry button instead of change skip link"" This reverts commit 9f0a2111a58e933a28105e54aba6ca08c2d043b7. * Replace uprn question * Update question copy * Allow changing the address search value * Rename address autocomplete to address search * Add buttons to switch between address questions * Fix controller logic * Enable adding question numbers to page headers * Update skip links * Add js disabled message to select * Alternative way to handle js disabled users * Revert "Alternative way to handle js disabled users" This reverts commit 10da3d61e2f89ec29ef9f9071c63eb99aa2bb482. * Fix typo * Fix address options for address search question * Reuse AddressDataPresenter where appropriate * Lint * Remove uprn selection question tests * Reuse UprnDataPresenter where appropriate * CSV export, exclude address_search * Add address search to sales and lettings factory bots * Exclude old address questions from routing, keep as exported values * lint * Update uprn value * Add address search input boolean and switch between questions * Reword copy, remove "Find" and "Search by" * Align address questions, add question number and question text * Remove old wip depends on * Update some tests * Update migration, move default value from db to model * Update test * Remove binding pry * Lint * Update test * Lint * Update test * Update routes with underscores * Remove debugging * Limit visible logs to user * Add manual address entry selected variable * Change address search min length to 3chars * Remove binding.pry * Update factory bots, manual_address_entry_selected to true for preexisting tests * Update model tests * Update sales model tests excl E-code tests * Update address search request test * Reuse uprn id instead of address_search * Set manual address entry selected as false when creating test logs * Update model test * Update request tests and remove old questions * Add back test * Update services * Update more tests Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com> * Update request tests * update model tests * Also update sales log * Update service csv uprn_selection values to 1 * Add tests for pages and questions * Update test * Update uprn_known * Lint * Add feature test * Update test * Update tests * Remove test * pre-consolidate migration files * Indentation * Controller method improvements * Update question numbers for 2025/26 * Update question numbers tests * consolidate and delete old migration files * undo changes to schema.rb * Update 2025 property information translation files * Update answer options to show singular previously selected result if present * Move buttons to bottom guidance partials * Small improvements, make address search and existing search more similar * Validate entered addresses as within England * Update test * Revert "Validate entered addresses as within England" This reverts commit 2dbfbcc8a5188cde7fb0ac0dcdbc5919eefd6a12. * Add missing button to sales address page * Change error code * Clear invalid options * Edit no results message method * Keep no result logic just change text * Display uprn value with address value * Still show no results message when characters entered is less than 3 rather than nothing * Fix uprn result when query is ambiguous * Reduce min match for address search * Hide no result found message just before results are populated * Prevent changing logs to 2025 with invalid addresses * Correct attribute name * Handle nil * Remove custom error message * Remove unused variables from factory * Update tests, remove address and postcode from old find address * Fix bug clearing uprn from see all answers * Revert "Fix bug clearing uprn from see all answers" This reverts commit a66c47a1abf7a429f25e0a016fedb0b92e92f15c. * Undo changes to validation method * Fix unchanged uprn_selection when clearing or changing uprn * Undo a change * Update bulk upload 2025 * Fix typo * Remove redundant line --------- Co-authored-by: Kat <54268893+kosiakkatrina@users.noreply.github.com> Co-authored-by: kosiakkatrina <kosiakkatrina@users.noreply.github.com>
1 week ago
sales_log.update!(uprn: "123", uprn_known: 1, manual_address_entry_selected: false)
duplicate_logs[0].update!(uprn: "123", uprn_known: 1, manual_address_entry_selected: false)
duplicate_logs[1].update!(uprn: "123", uprn_known: 1, manual_address_entry_selected: false)
get "/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}"
expect(page).to have_content("Q1 - Sale completion date", count: 3)
expect(page).to have_content("Q2 - Purchaser code", count: 3)
expect(page).to have_content("Q20 - Buyer 1’s age", count: 3)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 3)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 3)
expect(page).to have_content("Postcode (from UPRN)", count: 3)
expect(page).to have_link("Change", count: 21)
expect(page).to have_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?first_remaining_duplicate_id=#{duplicate_logs[0].id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/sales-logs/#{duplicate_logs[0].id}/purchaser-code?first_remaining_duplicate_id=#{sales_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/sales-logs/#{duplicate_logs[1].id}/purchaser-code?first_remaining_duplicate_id=#{sales_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
end
it "displays buttons to delete" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3)
expect(page).to have_link("Keep this log and delete duplicates", href: "/sales-logs/#{sales_log.id}/delete-duplicates?organisation_id=#{sales_log.owning_organisation_id}&original_log_id=#{sales_log.id}")
expect(page).to have_link("Keep this log and delete duplicates", href: "/sales-logs/#{duplicate_logs.first.id}/delete-duplicates?organisation_id=#{sales_log.owning_organisation_id}&original_log_id=#{sales_log.id}")
expect(page).to have_link("Keep this log and delete duplicates", href: "/sales-logs/#{duplicate_logs.second.id}/delete-duplicates?organisation_id=#{sales_log.owning_organisation_id}&original_log_id=#{sales_log.id}")
end
end
context "when there are no more duplicate logs" do
context "when accessed from the duplicate logs banner flow" do
before do
allow(SalesLog).to receive(:duplicate_logs).and_return(SalesLog.none)
get "/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}&referrer=duplicate_logs_banner&organisation_id=#{sales_log.owning_organisation_id}"
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q1 - Sale completion date", count: 1)
expect(page).to have_content("Q2 - Purchaser code", count: 1)
expect(page).to have_content("Q20 - Buyer 1’s age", count: 1)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 1)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 1)
expect(page).to have_content("Q15 - Postcode", count: 1)
expect(page).to have_link("Change", count: 7)
expect(page).to have_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?original_log_id=#{sales_log.id}&referrer=interruption_screen")
end
it "displays button to review other duplicates" do
expect(page).to have_link("Review other duplicates", href: "/organisations/#{sales_log.owning_organisation_id}/duplicates?referrer=duplicate_logs_banner")
end
it "displays no duplicates banner" do
expect(page).to have_content("This log had the same answers but it is no longer a duplicate. Make sure the answers are correct.")
end
end
context "when accessed from the single log submission flow" do
before do
allow(SalesLog).to receive(:duplicate_logs).and_return(SalesLog.none)
get "/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}&organisation_id=#{sales_log.owning_organisation_id}"
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q1 - Sale completion date", count: 1)
expect(page).to have_content("Q2 - Purchaser code", count: 1)
expect(page).to have_content("Q20 - Buyer 1’s age", count: 1)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 1)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 1)
expect(page).to have_content("Q15 - Postcode", count: 1)
expect(page).to have_link("Change", count: 7)
expect(page).to have_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?original_log_id=#{sales_log.id}&referrer=interruption_screen")
end
it "displays button to return to log" do
expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
end
it "displays no duplicates banner" do
expect(page).to have_content("This log had the same answers but it is no longer a duplicate. Make sure the answers are correct.")
end
end
end
end
end
context "when user is a data provider" do
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
end
context "when viewing lettings logs duplicates" do
context "when there are multiple duplicate logs" do
let(:duplicate_logs) { create_list(:lettings_log, 2, :completed) }
before do
allow(LettingsLog).to receive(:duplicate_logs).and_return(duplicate_logs)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}"
end
it "displays links to all the duplicate logs" do
expect(page).to have_link("Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}")
expect(page).to have_link("Log #{duplicate_logs.first.id}", href: "/lettings-logs/#{duplicate_logs.first.id}")
expect(page).to have_link("Log #{duplicate_logs.second.id}", href: "/lettings-logs/#{duplicate_logs.second.id}")
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q5 - Tenancy start date", count: 3)
expect(page).to have_content("Q7 - Tenant code", count: 3)
expect(page).to have_content("Q32 - Lead tenant’s age", count: 3)
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 3)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 3)
expect(page).to have_content("Household rent and charges", count: 3)
expect(page).to have_link("Change", count: 21)
expect(page).to have_link("Change", href: "/lettings-logs/#{lettings_log.id}/tenant-code?first_remaining_duplicate_id=#{duplicate_logs[0].id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/lettings-logs/#{duplicate_logs[0].id}/tenant-code?first_remaining_duplicate_id=#{lettings_log.id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/lettings-logs/#{duplicate_logs[1].id}/tenant-code?first_remaining_duplicate_id=#{lettings_log.id}&original_log_id=#{lettings_log.id}&referrer=duplicate_logs")
end
it "displays buttons to delete" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3)
expect(page).to have_link("Keep this log and delete duplicates", href: "/lettings-logs/#{lettings_log.id}/delete-duplicates?original_log_id=#{lettings_log.id}")
expect(page).to have_link("Keep this log and delete duplicates", href: "/lettings-logs/#{duplicate_logs.first.id}/delete-duplicates?original_log_id=#{lettings_log.id}")
expect(page).to have_link("Keep this log and delete duplicates", href: "/lettings-logs/#{duplicate_logs.second.id}/delete-duplicates?original_log_id=#{lettings_log.id}")
end
end
context "when there are no more duplicate logs" do
context "when accessed from the duplicate logs banner flow" do
before do
allow(LettingsLog).to receive(:duplicate_logs).and_return(LettingsLog.none)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}&referrer=duplicate_logs_banner"
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q5 - Tenancy start date", count: 1)
expect(page).to have_content("Q7 - Tenant code", count: 1)
expect(page).to have_content("Q32 - Lead tenant’s age", count: 1)
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 1)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 1)
expect(page).to have_content("Household rent and charges", count: 1)
expect(page).to have_link("Change", count: 7)
expect(page).to have_link("Change", href: "/lettings-logs/#{lettings_log.id}/tenant-code?original_log_id=#{lettings_log.id}&referrer=interruption_screen")
end
it "displays button to review other duplicates" do
expect(page).to have_link("Review other duplicates", href: "/duplicate-logs?referrer=duplicate_logs_banner")
end
it "displays no duplicates banner" do
expect(page).to have_content("This log had the same answers but it is no longer a duplicate. Make sure the answers are correct.")
end
end
context "when accessed from the single log submission flow" do
before do
allow(LettingsLog).to receive(:duplicate_logs).and_return(LettingsLog.none)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs?original_log_id=#{lettings_log.id}"
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q5 - Tenancy start date", count: 1)
expect(page).to have_content("Q7 - Tenant code", count: 1)
expect(page).to have_content("Q32 - Lead tenant’s age", count: 1)
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 1)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 1)
expect(page).to have_content("Household rent and charges", count: 1)
expect(page).to have_link("Change", count: 7)
expect(page).to have_link("Change", href: "/lettings-logs/#{lettings_log.id}/tenant-code?original_log_id=#{lettings_log.id}&referrer=interruption_screen")
end
it "displays button to return to log" do
expect(page).to have_link("Back to Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}")
end
it "displays no duplicates banner" do
expect(page).to have_content("This log had the same answers but it is no longer a duplicate. Make sure the answers are correct.")
end
end
end
end
context "when viewing sales logs duplicates" do
context "when there are multiple duplicate logs" do
let(:duplicate_logs) { create_list(:sales_log, 2, :completed) }
before do
allow(SalesLog).to receive(:duplicate_logs).and_return(duplicate_logs)
get "/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}"
end
it "displays links to all the duplicate logs" do
expect(page).to have_link("Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
expect(page).to have_link("Log #{duplicate_logs.first.id}", href: "/sales-logs/#{duplicate_logs.first.id}")
expect(page).to have_link("Log #{duplicate_logs.second.id}", href: "/sales-logs/#{duplicate_logs.second.id}")
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q1 - Sale completion date", count: 3)
expect(page).to have_content("Q2 - Purchaser code", count: 3)
expect(page).to have_content("Q20 - Buyer 1’s age", count: 3)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 3)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 3)
expect(page).to have_content("Q15 - Postcode", count: 3)
expect(page).to have_link("Change", count: 18)
expect(page).to have_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?first_remaining_duplicate_id=#{duplicate_logs[0].id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/sales-logs/#{duplicate_logs[0].id}/purchaser-code?first_remaining_duplicate_id=#{sales_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
expect(page).to have_link("Change", href: "/sales-logs/#{duplicate_logs[1].id}/purchaser-code?first_remaining_duplicate_id=#{sales_log.id}&original_log_id=#{sales_log.id}&referrer=duplicate_logs")
end
it "displays buttons to delete" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3)
expect(page).to have_link("Keep this log and delete duplicates", href: "/sales-logs/#{sales_log.id}/delete-duplicates?original_log_id=#{sales_log.id}")
expect(page).to have_link("Keep this log and delete duplicates", href: "/sales-logs/#{duplicate_logs.first.id}/delete-duplicates?original_log_id=#{sales_log.id}")
expect(page).to have_link("Keep this log and delete duplicates", href: "/sales-logs/#{duplicate_logs.second.id}/delete-duplicates?original_log_id=#{sales_log.id}")
end
end
context "when there are no more duplicate logs" do
context "when accessed from the duplicate logs banner flow" do
before do
allow(SalesLog).to receive(:duplicate_logs).and_return(SalesLog.none)
get "/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}&referrer=duplicate_logs_banner"
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q1 - Sale completion date", count: 1)
expect(page).to have_content("Q2 - Purchaser code", count: 1)
expect(page).to have_content("Q20 - Buyer 1’s age", count: 1)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 1)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 1)
expect(page).to have_content("Q15 - Postcode", count: 1)
expect(page).to have_link("Change", count: 6)
expect(page).to have_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?original_log_id=#{sales_log.id}&referrer=interruption_screen")
end
it "displays button to review other duplicates" do
expect(page).to have_link("Review other duplicates", href: "/duplicate-logs?referrer=duplicate_logs_banner")
end
it "displays no duplicates banner" do
expect(page).to have_content("This log had the same answers but it is no longer a duplicate. Make sure the answers are correct.")
end
end
context "when accessed from the single log submission flow" do
before do
allow(SalesLog).to receive(:duplicate_logs).and_return(SalesLog.none)
get "/sales-logs/#{sales_log.id}/duplicate-logs?original_log_id=#{sales_log.id}"
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q1 - Sale completion date", count: 1)
expect(page).to have_content("Q2 - Purchaser code", count: 1)
expect(page).to have_content("Q20 - Buyer 1’s age", count: 1)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 1)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 1)
expect(page).to have_content("Q15 - Postcode", count: 1)
expect(page).to have_link("Change", count: 6)
expect(page).to have_link("Change", href: "/sales-logs/#{sales_log.id}/purchaser-code?original_log_id=#{sales_log.id}&referrer=interruption_screen")
end
it "displays button to return to log" do
expect(page).to have_link("Back to Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
end
it "displays no duplicates banner" do
expect(page).to have_content("This log had the same answers but it is no longer a duplicate. Make sure the answers are correct.")
end
end
end
end
end
end
end
describe "GET lettings delete-duplicates" do
let(:id) { lettings_log.id }
let(:request) { get "/lettings-logs/#{id}/delete-duplicates?original_log_id=#{id}" }
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
end
context "when there are no duplicate logs" do
it "renders page not found" do
request
expect(response).to have_http_status(:not_found)
end
end
context "when accessed from the duplicate logs banner flow" do
let(:request) { get "/lettings-logs/#{id}/delete-duplicates?original_log_id=#{id}&referrer=duplicate_logs_banner" }
context "when there is 1 duplicate log being deleted" do
let!(:duplicate_log) { create(:lettings_log, :duplicate, assigned_to: user) }
it "renders page with correct link params" do
request
expect(response).to have_http_status(:ok)
expect(page).to have_content("Are you sure you want to delete this duplicate log?")
expect(page).to have_content("This log will be deleted:")
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, original_log_id: id, referrer: "duplicate_logs_banner"))
expect(page).to have_link(text: "Back", href: lettings_log_duplicate_logs_path(id, original_log_id: id, referrer: "duplicate_logs_banner"))
end
end
context "when there are multiple duplicate logs being deleted" do
let!(:duplicate_log) { create(:lettings_log, :duplicate, assigned_to: user) }
let!(:duplicate_log_2) { create(:lettings_log, :duplicate, assigned_to: user) }
it "renders page with correct link params" do
request
expect(response).to have_http_status(:ok)
expect(page).to have_content("Are you sure you want to delete these duplicate logs?")
expect(page).to have_content("These logs will be deleted:")
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, original_log_id: id, referrer: "duplicate_logs_banner"))
expect(page).to have_link(text: "Back", href: lettings_log_duplicate_logs_path(id, original_log_id: id, referrer: "duplicate_logs_banner"))
end
end
end
context "when accessed from the single log submission flow" do
context "when there is 1 duplicate log being deleted" do
let!(:duplicate_log) { create(:lettings_log, :duplicate, assigned_to: user) }
it "renders page" do
request
expect(response).to have_http_status(:ok)
expect(page).to have_content("Are you sure you want to delete this duplicate log?")
expect(page).to have_content("This log will be deleted:")
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, original_log_id: id))
expect(page).to have_link(text: "Back", href: lettings_log_duplicate_logs_path(id, original_log_id: id))
end
end
context "when there are multiple duplicate logs being deleted" do
let!(:duplicate_log) { create(:lettings_log, :duplicate, assigned_to: user) }
let!(:duplicate_log_2) { create(:lettings_log, :duplicate, assigned_to: user) }
it "renders page" do
request
expect(response).to have_http_status(:ok)
expect(page).to have_content("Are you sure you want to delete these duplicate logs?")
expect(page).to have_content("These logs will be deleted:")
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, original_log_id: id))
expect(page).to have_link(text: "Back", href: lettings_log_duplicate_logs_path(id, original_log_id: id))
end
end
end
context "when log does not exist" do
let(:id) { -1 }
it "returns 404" do
request
expect(response).to have_http_status(:not_found)
end
end
context "when user is not authorised" do
let(:other_user) { create(:user) }
before do
allow(other_user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in other_user
end
it "returns 404" do
request
expect(response).to have_http_status(:not_found)
end
end
end
describe "GET sales delete-duplicates" do
let(:headers) { { "Accept" => "text/html" } }
let(:id) { sales_log.id }
let(:request) { get "/sales-logs/#{id}/delete-duplicates?original_log_id=#{id}" }
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
end
context "when there are no duplicate logs" do
it "renders not found" do
request
expect(response).to have_http_status(:not_found)
end
end
context "when accessed from the duplicate logs banner flow" do
let(:request) { get "/sales-logs/#{id}/delete-duplicates?original_log_id=#{id}&referrer=duplicate_logs_banner" }
before do
Timecop.freeze(Time.zone.local(2024, 3, 1))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
Singleton.__init__(FormHandler)
end
context "when there is 1 duplicate log being deleted" do
let!(:duplicate_log) { create(:sales_log, :duplicate, assigned_to: user) }
it "renders page with correct link params" do
request
expect(response).to have_http_status(:ok)
expect(page).to have_content("Are you sure you want to delete this duplicate log?")
expect(page).to have_content("This log will be deleted:")
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, original_log_id: id, referrer: "duplicate_logs_banner"))
expect(page).to have_link(text: "Back", href: sales_log_duplicate_logs_path(id, original_log_id: id, referrer: "duplicate_logs_banner"))
end
end
context "when there are multiple duplicate logs being deleted" do
let!(:duplicate_log) { create(:sales_log, :duplicate, assigned_to: user) }
let!(:duplicate_log_2) { create(:sales_log, :duplicate, assigned_to: user) }
it "renders page with correct link params" do
request
expect(response).to have_http_status(:ok)
expect(page).to have_content("Are you sure you want to delete these duplicate logs?")
expect(page).to have_content("These logs will be deleted:")
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, original_log_id: id, referrer: "duplicate_logs_banner"))
expect(page).to have_link(text: "Back", href: sales_log_duplicate_logs_path(id, original_log_id: id, referrer: "duplicate_logs_banner"))
end
end
end
context "when accessed from the single log submission flow" do
before do
Timecop.freeze(Time.zone.local(2024, 3, 1))
Singleton.__init__(FormHandler)
end
after do
Timecop.return
Singleton.__init__(FormHandler)
end
context "when there is 1 duplicate log being deleted" do
let!(:duplicate_log) { create(:sales_log, :duplicate, assigned_to: user) }
it "renders page" do
request
expect(response).to have_http_status(:ok)
expect(page).to have_content("Are you sure you want to delete this duplicate log?")
expect(page).to have_content("This log will be deleted:")
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, original_log_id: id))
expect(page).to have_link(text: "Back", href: sales_log_duplicate_logs_path(id, original_log_id: id))
end
end
context "when there are multiple duplicate logs being deleted" do
let!(:duplicate_log) { create(:sales_log, :duplicate, assigned_to: user) }
let!(:duplicate_log_2) { create(:sales_log, :duplicate, assigned_to: user) }
it "renders page" do
request
expect(response).to have_http_status(:ok)
expect(page).to have_content("Are you sure you want to delete these duplicate logs?")
expect(page).to have_content("These logs will be deleted:")
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, original_log_id: id))
expect(page).to have_link(text: "Back", href: sales_log_duplicate_logs_path(id, original_log_id: id))
end
end
end
context "when log does not exist" do
let(:id) { -1 }
it "returns 404" do
request
expect(response).to have_http_status(:not_found)
end
end
context "when user is not authorised" do
let(:other_user) { create(:user) }
before do
allow(other_user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in other_user
end
it "returns 404" do
request
expect(response).to have_http_status(:not_found)
end
end
end
describe "GET #index" do
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user
end
context "when the user is support" do
let(:user) { create(:user, :support) }
before do
allow(Organisation).to receive(:find).with(user.organisation_id.to_s).and_return(user.organisation)
allow(user.organisation).to receive(:editable_duplicate_lettings_logs_sets).and_return([[1, 2], [3, 4, 5]])
allow(user.organisation).to receive(:editable_duplicate_sales_logs_sets).and_return([[11, 12]])
end
it "gets organisation duplicates" do
expect(user.organisation).to receive(:editable_duplicate_lettings_logs_sets)
expect(user.organisation).to receive(:editable_duplicate_sales_logs_sets)
get organisation_duplicates_path(organisation_id: user.organisation_id)
end
describe "viewing the page" do
context "when there are duplicate logs" do
before do
get organisation_duplicates_path(organisation_id: user.organisation_id)
end
it "has the correct headers" do
expect(page).to have_content("Type of logs")
expect(page).to have_content("Log IDs")
end
it "has the correct number of rows for each log type" do
expect(page).to have_selector("tbody tr td", text: "Lettings", count: 2)
expect(page).to have_selector("tbody tr td", text: "Sales", count: 1)
end
it "shows the log ids for each set of duplicates" do
expect(page).to have_content("Log 1, Log 2")
expect(page).to have_content("Log 3, Log 4, Log 5")
expect(page).to have_content("Log 11, Log 12")
end
it "shows links for each set of duplicates" do
expect(page).to have_link("Review logs", href: lettings_log_duplicate_logs_path(1, original_log_id: 1, organisation_id: user.organisation_id))
expect(page).to have_link("Review logs", href: lettings_log_duplicate_logs_path(3, original_log_id: 3, organisation_id: user.organisation_id))
expect(page).to have_link("Review logs", href: sales_log_duplicate_logs_path(11, original_log_id: 11, organisation_id: user.organisation_id))
end
end
context "when there are no duplicate logs" do
before do
allow(Organisation).to receive(:find).with(user.organisation_id.to_s).and_return(user.organisation)
allow(user.organisation).to receive(:editable_duplicate_lettings_logs_sets).and_return([])
allow(user.organisation).to receive(:editable_duplicate_sales_logs_sets).and_return([])
get organisation_duplicates_path(organisation_id: user.organisation_id)
end
it "has the correct headers" do
expect(page).to have_content("There are no more duplicate logs")
expect(page).to have_content("You have either changed or deleted all the duplicate logs.")
end
it "shows back to all logs button" do
expect(page).to have_link("Back to all logs", href: lettings_logs_path)
end
end
end
end
context "when the user is a data coordinator" do
let(:user) { create(:user, :data_coordinator) }
before do
allow(user.organisation).to receive(:editable_duplicate_lettings_logs_sets).and_return([[1, 2], [3, 4, 5]])
allow(user.organisation).to receive(:editable_duplicate_sales_logs_sets).and_return([[11, 12]])
end
it "gets organisation duplicates" do
expect(user.organisation).to receive(:editable_duplicate_lettings_logs_sets)
expect(user.organisation).to receive(:editable_duplicate_sales_logs_sets)
get duplicate_logs_path(organisation_id: user.organisation.id)
end
end
context "when the user is a provider" do
let(:user) { create(:user) }
before do
allow(user).to receive(:editable_duplicate_lettings_logs_sets).and_return([[1, 2], [3, 4, 5]])
allow(user).to receive(:editable_duplicate_sales_logs_sets).and_return([[11, 12]])
end
it "calls the helper method to retrieve duplicates for the current user" do
expect(user).to receive(:editable_duplicate_lettings_logs_sets)
expect(user).to receive(:editable_duplicate_sales_logs_sets)
get duplicate_logs_path
end
describe "viewing the page" do
context "when there are duplicate logs" do
before do
get duplicate_logs_path
end
it "has the correct headers" do
expect(page).to have_content("Type of logs")
expect(page).to have_content("Log IDs")
end
it "has the correct number of rows for each log type" do
expect(page).to have_selector("tbody tr td", text: "Lettings", count: 2)
expect(page).to have_selector("tbody tr td", text: "Sales", count: 1)
end
it "shows the log ids for each set of duplicates" do
expect(page).to have_content("Log 1, Log 2")
expect(page).to have_content("Log 3, Log 4, Log 5")
expect(page).to have_content("Log 11, Log 12")
end
it "shows links for each set of duplicates" do
expect(page).to have_link("Review logs", href: lettings_log_duplicate_logs_path(1, original_log_id: 1))
expect(page).to have_link("Review logs", href: lettings_log_duplicate_logs_path(3, original_log_id: 3))
expect(page).to have_link("Review logs", href: sales_log_duplicate_logs_path(11, original_log_id: 11))
end
end
context "when there are no duplicate logs" do
before do
allow(user).to receive(:editable_duplicate_lettings_logs_sets).and_return([])
allow(user).to receive(:editable_duplicate_sales_logs_sets).and_return([])
get duplicate_logs_path
end
it "has the correct headers" do
expect(page).to have_content("There are no more duplicate logs")
expect(page).to have_content("You have either changed or deleted all the duplicate logs.")
end
it "shows back to all logs button" do
expect(page).to have_link("Back to all logs", href: lettings_logs_path)
end
end
end
end
end
end