Fixes #3488 - Invalid null value for user's last name.
This commit is contained in:
parent
ae4c601d1c
commit
d2a0997475
2 changed files with 20 additions and 4 deletions
|
@ -4,7 +4,7 @@ class Pseudonymisation
|
||||||
return if source.blank?
|
return if source.blank?
|
||||||
|
|
||||||
source.transform_values do |value|
|
source.transform_values do |value|
|
||||||
of_value(value)
|
of_value(value.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class Pseudonymisation
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.of_string(source)
|
def self.of_string(source)
|
||||||
return '*' if source.length == 1
|
return '*' if source.to_s.length <= 1
|
||||||
return "#{source.first}*#{source.last}" if source.exclude?(' ')
|
return "#{source.first}*#{source.last}" if source.exclude?(' ')
|
||||||
|
|
||||||
source.split.map do |sub_string|
|
source.split.map do |sub_string|
|
||||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe Pseudonymisation do
|
||||||
let(:source) do
|
let(:source) do
|
||||||
{
|
{
|
||||||
firstname: 'John',
|
firstname: 'John',
|
||||||
lastname: 'Doe',
|
lastname: nil,
|
||||||
email: 'john.doe@example.com',
|
email: 'john.doe@example.com',
|
||||||
organization: 'Example Inc.',
|
organization: 'Example Inc.',
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ RSpec.describe Pseudonymisation do
|
||||||
let(:result) do
|
let(:result) do
|
||||||
{
|
{
|
||||||
firstname: 'J*n',
|
firstname: 'J*n',
|
||||||
lastname: 'D*e',
|
lastname: '*',
|
||||||
email: 'j*e@e*e.com',
|
email: 'j*e@e*e.com',
|
||||||
organization: 'E*e I*.',
|
organization: 'E*e I*.',
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,14 @@ RSpec.describe Pseudonymisation do
|
||||||
expect(described_class.of_value(source)).to eq('Z*d')
|
expect(described_class.of_value(source)).to eq('Z*d')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when nil is given' do
|
||||||
|
let(:source) { nil }
|
||||||
|
|
||||||
|
it 'returns *' do
|
||||||
|
expect(described_class.of_value(source)).to eq('*')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.of_email_address' do
|
describe '.of_email_address' do
|
||||||
|
@ -107,5 +115,13 @@ RSpec.describe Pseudonymisation do
|
||||||
expect(described_class.of_string(source)).to eq('Z*d F*n')
|
expect(described_class.of_string(source)).to eq('Z*d F*n')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when nil are given' do
|
||||||
|
let(:source) { nil }
|
||||||
|
|
||||||
|
it 'returns *' do
|
||||||
|
expect(described_class.of_string(source)).to eq('*')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue