FIX: remove primary emails from secondary_emails attr
This commit is contained in:
Родитель
46fa806fa1
Коммит
12368b4b06
|
@ -28,7 +28,15 @@ module MozillaIAM
|
|||
def process_emails
|
||||
emails = @raw[:emails]
|
||||
if emails
|
||||
emails.select { |x| x[:verified] && !x[:primary] }.map { |x| x[:value] }.uniq
|
||||
primary = emails.select do |x|
|
||||
x[:verified] &&
|
||||
x[:primary]
|
||||
end.map { |x| x[:value] }
|
||||
emails.select do |x|
|
||||
x[:verified] &&
|
||||
!x[:primary] &&
|
||||
primary.exclude?(x[:value])
|
||||
end.map { |x| x[:value] }.uniq
|
||||
else
|
||||
[]
|
||||
end
|
||||
|
|
|
@ -90,6 +90,19 @@ describe MozillaIAM::API::Person do
|
|||
expect(profile.secondary_emails).to contain_exactly("second@example.com", "third@example.com")
|
||||
end
|
||||
end
|
||||
|
||||
context "with a primary email in profile as secondary" do
|
||||
let(:profile) { described_class.new({ emails: [
|
||||
{ verified: true, value: "first@example.com", primary: true },
|
||||
{ verified: true, value: "first@example.com", primary: false },
|
||||
{ verified: true, value: "second@example.com", primary: false },
|
||||
{ verified: true, value: "third@example.com", primary: false },
|
||||
] }) }
|
||||
|
||||
it "doesn't return primary email in secondary emails" do
|
||||
expect(profile.secondary_emails).to contain_exactly("second@example.com", "third@example.com")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче