From 0e919b0f78c06bb4850b483cf70f2480bc3035cb Mon Sep 17 00:00:00 2001 From: carolynbarker <8038496+carolynbarker@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:00:37 +0000 Subject: [PATCH] Escape html in tests to handle names with punctuation (#3002) Co-authored-by: Carolyn --- spec/helpers/tab_nav_helper_spec.rb | 4 ++-- spec/requests/bulk_upload_lettings_results_controller_spec.rb | 2 +- spec/requests/bulk_upload_sales_results_controller_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/helpers/tab_nav_helper_spec.rb b/spec/helpers/tab_nav_helper_spec.rb index bd29f4c46..71fd4f9a8 100644 --- a/spec/helpers/tab_nav_helper_spec.rb +++ b/spec/helpers/tab_nav_helper_spec.rb @@ -16,7 +16,7 @@ RSpec.describe TabNavHelper do describe "#org_cell" do it "returns the users org name and role separated by a newline character" do expected_html = "#{organisation.name}\nData provider" - expect(org_cell(current_user)).to match(expected_html) + expect(CGI.unescapeHTML(org_cell(current_user))).to match(expected_html) end end @@ -30,7 +30,7 @@ RSpec.describe TabNavHelper do describe "#scheme_cell" do it "returns the scheme link service name and primary user group separated by a newline character" do expected_html = "#{scheme.service_name}\nScheme" - expect(scheme_cell(scheme)).to match(expected_html) + expect(CGI.unescapeHTML(scheme_cell(scheme))).to match(expected_html) end end end diff --git a/spec/requests/bulk_upload_lettings_results_controller_spec.rb b/spec/requests/bulk_upload_lettings_results_controller_spec.rb index 3c84487ac..3416b6da9 100644 --- a/spec/requests/bulk_upload_lettings_results_controller_spec.rb +++ b/spec/requests/bulk_upload_lettings_results_controller_spec.rb @@ -138,7 +138,7 @@ RSpec.describe BulkUploadLettingsResultsController, type: :request do get "/lettings-logs/bulk-upload-results/#{bulk_upload.id}/summary" expect(response.body).to include("This error report is out of date.") - expect(response.body).to include("Some logs in this upload are assigned to #{other_user.name}, who has moved to a different organisation since this file was uploaded. Upload the file again to get an accurate error report.") + expect(CGI.unescapeHTML(response.body)).to include("Some logs in this upload are assigned to #{other_user.name}, who has moved to a different organisation since this file was uploaded. Upload the file again to get an accurate error report.") end end diff --git a/spec/requests/bulk_upload_sales_results_controller_spec.rb b/spec/requests/bulk_upload_sales_results_controller_spec.rb index e58303d68..2236475fa 100644 --- a/spec/requests/bulk_upload_sales_results_controller_spec.rb +++ b/spec/requests/bulk_upload_sales_results_controller_spec.rb @@ -30,7 +30,7 @@ RSpec.describe BulkUploadSalesResultsController, type: :request do get "/sales-logs/bulk-upload-results/#{bulk_upload.id}/summary" expect(response.body).to include("This error report is out of date.") - expect(response.body).to include("Some logs in this upload are assigned to #{user.name}, who has moved to a different organisation since this file was uploaded. Upload the file again to get an accurate error report.") + expect(CGI.unescapeHTML(response.body)).to include("Some logs in this upload are assigned to #{user.name}, who has moved to a different organisation since this file was uploaded. Upload the file again to get an accurate error report.") end end @@ -113,7 +113,7 @@ RSpec.describe BulkUploadSalesResultsController, type: :request do get "/sales-logs/bulk-upload-results/#{bulk_upload.id}/summary" expect(response.body).to include("This error report is out of date.") - expect(response.body).to include("Some logs in this upload are assigned to #{other_user.name}, who has moved to a different organisation since this file was uploaded. Upload the file again to get an accurate error report.") + expect(CGI.unescapeHTML(response.body)).to include("Some logs in this upload are assigned to #{other_user.name}, who has moved to a different organisation since this file was uploaded. Upload the file again to get an accurate error report.") end end