Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/utils/email_spec.rb')
-rw-r--r--spec/lib/gitlab/utils/email_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/lib/gitlab/utils/email_spec.rb b/spec/lib/gitlab/utils/email_spec.rb
new file mode 100644
index 00000000000..d7a881d8655
--- /dev/null
+++ b/spec/lib/gitlab/utils/email_spec.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+require 'rspec-parameterized'
+
+RSpec.describe Gitlab::Utils::Email, feature_category: :service_desk do
+ using RSpec::Parameterized::TableSyntax
+
+ describe '.obfuscated_email' do
+ where(:input, :output) do
+ 'alex@gitlab.com' | 'al**@g*****.com'
+ 'alex@gl.co.uk' | 'al**@g****.uk'
+ 'a@b.c' | 'a@b.c'
+ 'q@example.com' | 'q@e******.com'
+ 'q@w.' | 'q@w.'
+ 'a@b' | 'a@b'
+ 'no mail' | 'no mail'
+ end
+
+ with_them do
+ it { expect(described_class.obfuscated_email(input)).to eq(output) }
+ end
+
+ context 'when deform is active' do
+ where(:input, :output) do
+ 'alex@gitlab.com' | 'al*****@g*****.c**'
+ 'alex@gl.co.uk' | 'al*****@g*****.u**'
+ 'a@b.c' | 'aa*****@b*****.c**'
+ 'qqwweerrttyy@example.com' | 'qq*****@e*****.c**'
+ 'getsuperfancysupport@paywhatyouwant.accounting' | 'ge*****@p*****.a**'
+ 'q@example.com' | 'qq*****@e*****.c**'
+ 'q@w.' | 'q@w.'
+ 'a@b' | 'a@b'
+ 'no mail' | 'no mail'
+ end
+
+ with_them do
+ it { expect(described_class.obfuscated_email(input, deform: true)).to eq(output) }
+ end
+ end
+ end
+end