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?
|
||||
|
||||
source.transform_values do |value|
|
||||
of_value(value)
|
||||
of_value(value.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ class Pseudonymisation
|
|||
end
|
||||
|
||||
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?(' ')
|
||||
|
||||
source.split.map do |sub_string|
|
||||
|
|
|
@ -7,7 +7,7 @@ RSpec.describe Pseudonymisation do
|
|||
let(:source) do
|
||||
{
|
||||
firstname: 'John',
|
||||
lastname: 'Doe',
|
||||
lastname: nil,
|
||||
email: 'john.doe@example.com',
|
||||
organization: 'Example Inc.',
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ RSpec.describe Pseudonymisation do
|
|||
let(:result) do
|
||||
{
|
||||
firstname: 'J*n',
|
||||
lastname: 'D*e',
|
||||
lastname: '*',
|
||||
email: 'j*e@e*e.com',
|
||||
organization: 'E*e I*.',
|
||||
}
|
||||
|
@ -44,6 +44,14 @@ RSpec.describe Pseudonymisation do
|
|||
expect(described_class.of_value(source)).to eq('Z*d')
|
||||
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
|
||||
|
||||
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')
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue