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
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-03-29 03:09:12 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-03-29 03:09:12 +0300
commit2c99b3e0f38bd94ace525f35469dae1eda051c16 (patch)
treeb82adf05bcea217c2103aa96f6abf6c02f2458d1 /spec
parentfc8a3b9422a7fb2e61d8e70a908cfaf979b64b2e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/lib/utils/unit_format/formatter_factory_spec.js50
-rw-r--r--spec/frontend/lib/utils/unit_format/index_spec.js15
-rw-r--r--spec/lib/gitlab/seeder_spec.rb27
-rw-r--r--spec/models/integrations/emails_on_push_spec.rb3
-rw-r--r--spec/models/project_spec.rb27
-rw-r--r--spec/tasks/dev_rake_spec.rb2
6 files changed, 120 insertions, 4 deletions
diff --git a/spec/frontend/lib/utils/unit_format/formatter_factory_spec.js b/spec/frontend/lib/utils/unit_format/formatter_factory_spec.js
index 0ca70e0a77e..9632d0f98f4 100644
--- a/spec/frontend/lib/utils/unit_format/formatter_factory_spec.js
+++ b/spec/frontend/lib/utils/unit_format/formatter_factory_spec.js
@@ -31,12 +31,17 @@ describe('unit_format/formatter_factory', () => {
expect(formatNumber(12.345, 4)).toBe('12.3450');
});
- it('formats a large integer with a length limit', () => {
+ it('formats a large integer with a max length - using legacy positional argument', () => {
expect(formatNumber(10 ** 7, undefined)).toBe('10,000,000');
expect(formatNumber(10 ** 7, undefined, 9)).toBe('1.00e+7');
expect(formatNumber(10 ** 7, undefined, 10)).toBe('10,000,000');
});
+ it('formats a large integer with a max length', () => {
+ expect(formatNumber(10 ** 7, undefined, { maxLength: 9 })).toBe('1.00e+7');
+ expect(formatNumber(10 ** 7, undefined, { maxLength: 10 })).toBe('10,000,000');
+ });
+
describe('formats with a different locale', () => {
let originalLang;
@@ -92,7 +97,7 @@ describe('unit_format/formatter_factory', () => {
expect(formatSuffix(-1000000)).toBe('-1,000,000pop.');
});
- it('formats a floating point nugative number', () => {
+ it('formats a floating point negative number', () => {
expect(formatSuffix(-0.1)).toBe('-0.1pop.');
expect(formatSuffix(-0.1, 0)).toBe('-0pop.');
expect(formatSuffix(-0.1, 2)).toBe('-0.10pop.');
@@ -108,10 +113,20 @@ describe('unit_format/formatter_factory', () => {
expect(formatSuffix(10 ** 10)).toBe('10,000,000,000pop.');
});
- it('formats a large integer with a length limit', () => {
+ it('formats using a unit separator', () => {
+ expect(formatSuffix(10, 0, { unitSeparator: ' ' })).toBe('10 pop.');
+ expect(formatSuffix(10, 0, { unitSeparator: ' x ' })).toBe('10 x pop.');
+ });
+
+ it('formats a large integer with a max length - using legacy positional argument', () => {
expect(formatSuffix(10 ** 7, undefined, 10)).toBe('1.00e+7pop.');
expect(formatSuffix(10 ** 10, undefined, 10)).toBe('1.00e+10pop.');
});
+
+ it('formats a large integer with a max length', () => {
+ expect(formatSuffix(10 ** 7, undefined, { maxLength: 10 })).toBe('1.00e+7pop.');
+ expect(formatSuffix(10 ** 10, undefined, { maxLength: 10 })).toBe('1.00e+10pop.');
+ });
});
describe('scaledSIFormatter', () => {
@@ -143,6 +158,10 @@ describe('unit_format/formatter_factory', () => {
expect(formatGibibytes(10 ** 10)).toBe('10GB');
expect(formatGibibytes(10 ** 11)).toBe('100GB');
});
+
+ it('formats bytes using a unit separator', () => {
+ expect(formatGibibytes(1, 0, { unitSeparator: ' ' })).toBe('1 B');
+ });
});
describe('scaled format with offset', () => {
@@ -174,6 +193,19 @@ describe('unit_format/formatter_factory', () => {
expect(formatGigaBytes(10 ** 9)).toBe('1EB');
});
+ it('formats bytes using a unit separator', () => {
+ expect(formatGigaBytes(1, undefined, { unitSeparator: ' ' })).toBe('1 GB');
+ });
+
+ it('formats long byte numbers with max length - using legacy positional argument', () => {
+ expect(formatGigaBytes(1, 8, 7)).toBe('1.00e+0GB');
+ });
+
+ it('formats long byte numbers with max length', () => {
+ expect(formatGigaBytes(1, 8)).toBe('1.00000000GB');
+ expect(formatGigaBytes(1, 8, { maxLength: 7 })).toBe('1.00e+0GB');
+ });
+
it('formatting of too large numbers is not suported', () => {
// formatting YB is out of range
expect(() => scaledSIFormatter('B', 9)).toThrow();
@@ -216,6 +248,10 @@ describe('unit_format/formatter_factory', () => {
expect(formatMilligrams(-100)).toBe('-100mg');
expect(formatMilligrams(-(10 ** 4))).toBe('-10g');
});
+
+ it('formats using a unit separator', () => {
+ expect(formatMilligrams(1, undefined, { unitSeparator: ' ' })).toBe('1 mg');
+ });
});
});
@@ -253,6 +289,10 @@ describe('unit_format/formatter_factory', () => {
expect(formatScaledBin(10 * 1024 ** 3)).toBe('10GiB');
expect(formatScaledBin(100 * 1024 ** 3)).toBe('100GiB');
});
+
+ it('formats using a unit separator', () => {
+ expect(formatScaledBin(1, undefined, { unitSeparator: ' ' })).toBe('1 B');
+ });
});
describe('scaled format with offset', () => {
@@ -288,6 +328,10 @@ describe('unit_format/formatter_factory', () => {
expect(formatGibibytes(100 * 1024 ** 3)).toBe('100EiB');
});
+ it('formats using a unit separator', () => {
+ expect(formatGibibytes(1, undefined, { unitSeparator: ' ' })).toBe('1 GiB');
+ });
+
it('formatting of too large numbers is not suported', () => {
// formatting YB is out of range
expect(() => scaledBinaryFormatter('B', 9)).toThrow();
diff --git a/spec/frontend/lib/utils/unit_format/index_spec.js b/spec/frontend/lib/utils/unit_format/index_spec.js
index 7fd273f1b58..dc9d6ece48e 100644
--- a/spec/frontend/lib/utils/unit_format/index_spec.js
+++ b/spec/frontend/lib/utils/unit_format/index_spec.js
@@ -74,10 +74,13 @@ describe('unit_format', () => {
it('seconds', () => {
expect(seconds(1)).toBe('1s');
+ expect(seconds(1, undefined, { unitSeparator: ' ' })).toBe('1 s');
});
it('milliseconds', () => {
expect(milliseconds(1)).toBe('1ms');
+ expect(milliseconds(1, undefined, { unitSeparator: ' ' })).toBe('1 ms');
+
expect(milliseconds(100)).toBe('100ms');
expect(milliseconds(1000)).toBe('1,000ms');
expect(milliseconds(10_000)).toBe('10,000ms');
@@ -87,6 +90,7 @@ describe('unit_format', () => {
it('decimalBytes', () => {
expect(decimalBytes(1)).toBe('1B');
expect(decimalBytes(1, 1)).toBe('1.0B');
+ expect(decimalBytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 B');
expect(decimalBytes(10)).toBe('10B');
expect(decimalBytes(10 ** 2)).toBe('100B');
@@ -104,31 +108,37 @@ describe('unit_format', () => {
it('kilobytes', () => {
expect(kilobytes(1)).toBe('1kB');
expect(kilobytes(1, 1)).toBe('1.0kB');
+ expect(kilobytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 kB');
});
it('megabytes', () => {
expect(megabytes(1)).toBe('1MB');
expect(megabytes(1, 1)).toBe('1.0MB');
+ expect(megabytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 MB');
});
it('gigabytes', () => {
expect(gigabytes(1)).toBe('1GB');
expect(gigabytes(1, 1)).toBe('1.0GB');
+ expect(gigabytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 GB');
});
it('terabytes', () => {
expect(terabytes(1)).toBe('1TB');
expect(terabytes(1, 1)).toBe('1.0TB');
+ expect(terabytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 TB');
});
it('petabytes', () => {
expect(petabytes(1)).toBe('1PB');
expect(petabytes(1, 1)).toBe('1.0PB');
+ expect(petabytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 PB');
});
it('bytes', () => {
expect(bytes(1)).toBe('1B');
expect(bytes(1, 1)).toBe('1.0B');
+ expect(bytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 B');
expect(bytes(10)).toBe('10B');
expect(bytes(100)).toBe('100B');
@@ -142,26 +152,31 @@ describe('unit_format', () => {
it('kibibytes', () => {
expect(kibibytes(1)).toBe('1KiB');
expect(kibibytes(1, 1)).toBe('1.0KiB');
+ expect(kibibytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 KiB');
});
it('mebibytes', () => {
expect(mebibytes(1)).toBe('1MiB');
expect(mebibytes(1, 1)).toBe('1.0MiB');
+ expect(mebibytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 MiB');
});
it('gibibytes', () => {
expect(gibibytes(1)).toBe('1GiB');
expect(gibibytes(1, 1)).toBe('1.0GiB');
+ expect(gibibytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 GiB');
});
it('tebibytes', () => {
expect(tebibytes(1)).toBe('1TiB');
expect(tebibytes(1, 1)).toBe('1.0TiB');
+ expect(tebibytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 TiB');
});
it('pebibytes', () => {
expect(pebibytes(1)).toBe('1PiB');
expect(pebibytes(1, 1)).toBe('1.0PiB');
+ expect(pebibytes(1, 1, { unitSeparator: ' ' })).toBe('1.0 PiB');
});
describe('getFormatter', () => {
diff --git a/spec/lib/gitlab/seeder_spec.rb b/spec/lib/gitlab/seeder_spec.rb
index 71d0a41ef98..a22d47cbfb3 100644
--- a/spec/lib/gitlab/seeder_spec.rb
+++ b/spec/lib/gitlab/seeder_spec.rb
@@ -3,6 +3,24 @@
require 'spec_helper'
RSpec.describe Gitlab::Seeder do
+ describe Namespace do
+ subject { described_class }
+
+ it 'has not_mass_generated scope' do
+ expect { Namespace.not_mass_generated }.to raise_error(NoMethodError)
+
+ Gitlab::Seeder.quiet do
+ expect { Namespace.not_mass_generated }.not_to raise_error
+ end
+ end
+
+ it 'includes NamespaceSeed module' do
+ Gitlab::Seeder.quiet do
+ is_expected.to include_module(Gitlab::Seeder::NamespaceSeed)
+ end
+ end
+ end
+
describe '.quiet' do
let(:database_base_models) do
{
@@ -50,4 +68,13 @@ RSpec.describe Gitlab::Seeder do
notification_service.new_note(note)
end
end
+
+ describe '.log_message' do
+ it 'prepends timestamp to the logged message' do
+ freeze_time do
+ message = "some message."
+ expect { described_class.log_message(message) }.to output(/#{Time.current}: #{message}/).to_stdout
+ end
+ end
+ end
end
diff --git a/spec/models/integrations/emails_on_push_spec.rb b/spec/models/integrations/emails_on_push_spec.rb
index bdca267f6cb..15aa105e379 100644
--- a/spec/models/integrations/emails_on_push_spec.rb
+++ b/spec/models/integrations/emails_on_push_spec.rb
@@ -78,9 +78,10 @@ RSpec.describe Integrations::EmailsOnPush do
end
describe '.valid_recipients' do
- let(:recipients) { '<invalid> foobar Valid@recipient.com Dup@lica.te dup@lica.te Dup@Lica.te' }
+ let(:recipients) { '<invalid> foobar valid@dup@asd Valid@recipient.com Dup@lica.te dup@lica.te Dup@Lica.te' }
it 'removes invalid email addresses and removes duplicates by keeping the original capitalization' do
+ expect(described_class.valid_recipients(recipients)).not_to contain_exactly('valid@dup@asd')
expect(described_class.valid_recipients(recipients)).to contain_exactly('Valid@recipient.com', 'Dup@lica.te')
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 3bff45f80dd..622eb0614bb 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -726,6 +726,33 @@ RSpec.describe Project, factory_default: :keep do
end
end
+ describe '#personal_namespace_holder?' do
+ let_it_be(:group) { create(:group) }
+ let_it_be(:namespace_user) { create(:user) }
+ let_it_be(:admin_user) { create(:user, :admin) }
+ let_it_be(:personal_project) { create(:project, namespace: namespace_user.namespace) }
+ let_it_be(:group_project) { create(:project, group: group) }
+ let_it_be(:another_user) { create(:user) }
+ let_it_be(:group_owner_user) { create(:user).tap { |user| group.add_owner(user) } }
+
+ where(:project, :user, :result) do
+ ref(:personal_project) | ref(:namespace_user) | true
+ ref(:personal_project) | ref(:admin_user) | false
+ ref(:personal_project) | ref(:another_user) | false
+ ref(:personal_project) | nil | false
+ ref(:group_project) | ref(:namespace_user) | false
+ ref(:group_project) | ref(:group_owner_user) | false
+ ref(:group_project) | ref(:another_user) | false
+ ref(:group_project) | nil | false
+ ref(:group_project) | nil | false
+ ref(:group_project) | ref(:admin_user) | false
+ end
+
+ with_them do
+ it { expect(project.personal_namespace_holder?(user)).to eq(result) }
+ end
+ end
+
describe '#default_pipeline_lock' do
let(:project) { build_stubbed(:project) }
diff --git a/spec/tasks/dev_rake_spec.rb b/spec/tasks/dev_rake_spec.rb
index 7bc27d2732c..ebcea338291 100644
--- a/spec/tasks/dev_rake_spec.rb
+++ b/spec/tasks/dev_rake_spec.rb
@@ -17,7 +17,9 @@ RSpec.describe 'dev rake tasks' do
it 'sets up the development environment', :aggregate_failures do
expect(Rake::Task['gitlab:setup']).to receive(:invoke)
+ expect(connections).to all(receive(:execute).with('SET statement_timeout TO 0'))
expect(connections).to all(receive(:execute).with('ANALYZE'))
+ expect(connections).to all(receive(:execute).with('RESET statement_timeout'))
expect(Rake::Task['gitlab:shell:setup']).to receive(:invoke)