From 8e81d030510acca75bc1723a6ee1f558faf1f17f Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire <94526761+natdeanlewissoftwire@users.noreply.github.com> Date: Fri, 16 Jun 2023 16:50:29 +0100 Subject: [PATCH] feat: sort dpo names in alphabetical order (#1708) --- app/components/data_protection_confirmation_banner_component.rb | 2 +- .../data_protection_confirmation_banner_component_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/data_protection_confirmation_banner_component.rb b/app/components/data_protection_confirmation_banner_component.rb index b1dc61152..b11c01f02 100644 --- a/app/components/data_protection_confirmation_banner_component.rb +++ b/app/components/data_protection_confirmation_banner_component.rb @@ -22,7 +22,7 @@ class DataProtectionConfirmationBannerComponent < ViewComponent::Base def data_protection_officers_text if org_or_user_org.data_protection_officers.any? - "You can ask: #{org_or_user_org.data_protection_officers.map(&:name).join(', ')}" + "You can ask: #{org_or_user_org.data_protection_officers.map(&:name).sort_by(&:downcase).join(', ')}" end end diff --git a/spec/components/data_protection_confirmation_banner_component_spec.rb b/spec/components/data_protection_confirmation_banner_component_spec.rb index a76db4435..792e3a5a3 100644 --- a/spec/components/data_protection_confirmation_banner_component_spec.rb +++ b/spec/components/data_protection_confirmation_banner_component_spec.rb @@ -31,7 +31,7 @@ RSpec.describe DataProtectionConfirmationBannerComponent, type: :component do create(:user, organisation:, is_dpo: true, name: "Test McTest") end - it "returns the correct text" do + it "returns the correct list of names, in alphabetical order)" do expect(component.data_protection_officers_text).to eq("You can ask: Danny Rojas, Test McTest") end end