diff --git a/app/controllers/duplicate_logs_controller.rb b/app/controllers/duplicate_logs_controller.rb
index ddb2c9659..43b8524bf 100644
--- a/app/controllers/duplicate_logs_controller.rb
+++ b/app/controllers/duplicate_logs_controller.rb
@@ -4,7 +4,6 @@ class DuplicateLogsController < ApplicationController
def show
@duplicate_logs = @log.class.duplicate_logs_for_organisation(current_user.organisation_id, @log)
@all_duplicates = [@log, *@duplicate_logs]
- duplicate_check_question_ids = %w[startdate tenancycode postcode_full age1 sex1 ecstat1 tcharge]
@duplicate_check_questions = duplicate_check_question_ids.map { |question_id| @log.form.get_question(question_id, @log) }.compact
end
@@ -17,4 +16,12 @@ private
current_user.lettings_logs.visible.find_by(id: params[:lettings_log_id])
end
end
+
+ def duplicate_check_question_ids
+ if @log.lettings?
+ %w[owning_organisation_id startdate tenancycode postcode_full age1 sex1 ecstat1 tcharge]
+ else
+ %w[owning_organisation_id saledate purchid age1 sex1 ecstat1 postcode_full]
+ end
+ end
end
diff --git a/app/views/duplicate_logs/_duplicate_log.html.erb b/app/views/duplicate_logs/_duplicate_log.html.erb
index 5d44f2fd8..e08ef5980 100644
--- a/app/views/duplicate_logs/_duplicate_log.html.erb
+++ b/app/views/duplicate_logs/_duplicate_log.html.erb
@@ -4,7 +4,7 @@
diff --git a/spec/requests/duplicate_logs_controller_spec.rb b/spec/requests/duplicate_logs_controller_spec.rb
index 43b216a08..69e66ad03 100644
--- a/spec/requests/duplicate_logs_controller_spec.rb
+++ b/spec/requests/duplicate_logs_controller_spec.rb
@@ -12,6 +12,13 @@ RSpec.describe DuplicateLogsController, type: :request do
created_by: user,
)
end
+ let(:sales_log) do
+ create(
+ :sales_log,
+ :completed,
+ created_by: user,
+ )
+ end
before do
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
@@ -34,6 +41,7 @@ RSpec.describe DuplicateLogsController, type: :request do
end
it "displays check your answers for each log with correct questions" do
+ expect(page).to have_content("Q1 - Stock owner", count: 3)
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("Q12 - Postcode", count: 3)
@@ -41,10 +49,40 @@ RSpec.describe DuplicateLogsController, type: :request do
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)
+ end
+
+ it "displays buttons to delete" do
+ expect(page).to have_link("Keep this log and delete duplicates", count: 3)
+ end
+ end
+
+ context "with multiple duplicate sales logs" do
+ let(:duplicate_logs) { create_list(:sales_log, 2, :completed) }
+
+ before do
+ allow(SalesLog).to receive(:duplicate_logs_for_organisation).and_return(duplicate_logs)
+ get "/sales-logs/#{sales_log.id}/duplicate-logs"
+ 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("Owning organisation", count: 3)
+ 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 - Lead buyer’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)
end
- it "displays buttons to delete duplicates" do
+ it "displays buttons to delete" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3)
end
end