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