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
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-25 21:08:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-25 21:08:56 +0300
commitff549ec680715e4ea1daf0cee457f29dfe3b6062 (patch)
tree823fc28718a1278025ee2d88c1368958befec4da /spec/lib
parentec558ad8ed732ff6f8a89aa3651eb92c27c50deb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/github_import/importer/pull_requests/review_requests_importer_spec.rb4
-rw-r--r--spec/lib/gitlab/slug/path_spec.rb33
-rw-r--r--spec/lib/gitlab/utils/email_spec.rb42
-rw-r--r--spec/lib/gitlab_spec.rb82
-rw-r--r--spec/lib/service_ping/build_payload_spec.rb2
5 files changed, 100 insertions, 63 deletions
diff --git a/spec/lib/gitlab/github_import/importer/pull_requests/review_requests_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_requests/review_requests_importer_spec.rb
index 06005a447a8..53a0e718eb6 100644
--- a/spec/lib/gitlab/github_import/importer/pull_requests/review_requests_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/pull_requests/review_requests_importer_spec.rb
@@ -108,10 +108,10 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequests::ReviewRequestsImpor
it 'schedule import for each merge request reviewers' do
expect(Gitlab::GithubImport::PullRequests::ImportReviewRequestWorker)
- .to receive(:perform_in).with(1.minute, *expected_worker_payload.first).ordered
+ .to receive(:perform_in).with(1.minute, *expected_worker_payload.first)
expect(Gitlab::GithubImport::PullRequests::ImportReviewRequestWorker)
- .to receive(:perform_in).with(1.minute, *expected_worker_payload.second).ordered
+ .to receive(:perform_in).with(1.minute, *expected_worker_payload.second)
importer.parallel_import
end
diff --git a/spec/lib/gitlab/slug/path_spec.rb b/spec/lib/gitlab/slug/path_spec.rb
new file mode 100644
index 00000000000..9a7067e40a2
--- /dev/null
+++ b/spec/lib/gitlab/slug/path_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+
+RSpec.describe Gitlab::Slug::Path, feature_category: :not_owned do
+ describe '#generate' do
+ {
+ 'name': 'name',
+ 'james.atom@bond.com': 'james',
+ '--foobar--': 'foobar--',
+ '--foo_bar--': 'foo_bar--',
+ '--foo$^&_bar--': 'foo_bar--',
+ 'john@doe.com': 'john',
+ '-john+gitlab-ETC%.git@gmail.com': 'johngitlab-ETC',
+ 'this.is.git.atom.': 'this.is',
+ '#$%^.': 'blank',
+ '---.git#$.atom%@atom^.': 'blank', # use default when all characters are filtered out
+ '--gitlab--hey.git#$.atom%@atom^.': 'gitlab--hey'
+ }.each do |input, output|
+ it "yields a slug #{output} when given #{input}" do
+ slug = described_class.new(input).generate
+
+ expect(slug).to match(/\A#{output}\z/)
+ end
+ end
+ end
+
+ describe '#to_s' do
+ it 'presents with a cleaned slug' do
+ expect(described_class.new('---show-me-what-you.got.git').to_s).to match(/\Ashow-me-what-you.got\z/)
+ end
+ end
+end
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
diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb
index c44bb64a5c0..a554e0b26a8 100644
--- a/spec/lib/gitlab_spec.rb
+++ b/spec/lib/gitlab_spec.rb
@@ -81,10 +81,6 @@ RSpec.describe Gitlab do
describe '.com?' do
context 'when not simulating SaaS' do
- before do
- stub_env('GITLAB_SIMULATE_SAAS', '0')
- end
-
it "is true when on #{Gitlab::Saas.com_url}" do
stub_config_setting(url: Gitlab::Saas.com_url)
@@ -118,17 +114,31 @@ RSpec.describe Gitlab do
end
end
- it 'is true when GITLAB_SIMULATE_SAAS is true and in development' do
- stub_rails_env('development')
- stub_env('GITLAB_SIMULATE_SAAS', '1')
+ context 'when simulating SaaS' do
+ before do
+ stub_const('Gitlab::GITLAB_SIMULATE_SAAS', '1')
+ end
- expect(described_class.com?).to eq true
- end
+ it 'is false in tests' do
+ expect(described_class.com?).to eq false
+ end
+
+ it 'is true in development' do
+ stub_rails_env('development')
- it 'is false when GITLAB_SIMULATE_SAAS is true and in test' do
- stub_env('GITLAB_SIMULATE_SAAS', '1')
+ expect(described_class.com?).to eq true
+ end
- expect(described_class.com?).to eq false
+ # See ee/spec/lib/gitlab_spec.rb for EE-specific changes to this behavior.
+ context 'in a production environment' do
+ before do
+ stub_rails_env('production')
+ end
+
+ it 'is false' do
+ expect(described_class.com?).to eq false
+ end
+ end
end
end
@@ -236,54 +246,6 @@ RSpec.describe Gitlab do
end
end
- describe '.simulate_com?' do
- subject { described_class.simulate_com? }
-
- context 'when GITLAB_SIMULATE_SAAS is true' do
- before do
- stub_env('GITLAB_SIMULATE_SAAS', '1')
- end
-
- it 'is false when test env' do
- expect(subject).to eq false
- end
-
- it 'is true when dev env' do
- stub_rails_env('development')
-
- expect(subject).to eq true
- end
-
- it 'is false when env is not dev' do
- stub_rails_env('production')
-
- expect(subject).to eq false
- end
- end
-
- context 'when GITLAB_SIMULATE_SAAS is false' do
- before do
- stub_env('GITLAB_SIMULATE_SAAS', '0')
- end
-
- it 'is false when test env' do
- expect(subject).to eq false
- end
-
- it 'is false when dev env' do
- stub_rails_env('development')
-
- expect(subject).to eq false
- end
-
- it 'is false when env is not dev or test' do
- stub_rails_env('production')
-
- expect(subject).to eq false
- end
- end
- end
-
describe '.dev_or_test_env?' do
subject { described_class.dev_or_test_env? }
diff --git a/spec/lib/service_ping/build_payload_spec.rb b/spec/lib/service_ping/build_payload_spec.rb
index b10c9fd5bc0..6c37168f5a0 100644
--- a/spec/lib/service_ping/build_payload_spec.rb
+++ b/spec/lib/service_ping/build_payload_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe ServicePing::BuildPayload do
+RSpec.describe ServicePing::BuildPayload, feature_category: :service_ping do
describe '#execute', :without_license do
subject(:service_ping_payload) { described_class.new.execute }