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:
authorYorick Peterse <yorickpeterse@gmail.com>2019-03-12 16:04:05 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2019-03-12 16:04:05 +0300
commitae9838d03556a15d5543a9c42a97d5cf6e3085e9 (patch)
tree7dc90be384b4c87f1c78ffeaf5ae465ab353dbfa /spec/lib/gitlab/utils_spec.rb
parent018fc6c696bc2f557211102b163154439b1fc589 (diff)
Backport try_megabytes_to_bytes from EE
EE adds this method to Gitlab::Utils, which is also required by our SimpleCov helper. This prevents us from injecting EE modules into Gitlab::Utils, because the necessary bits for this are not yet in place. To work around this we just backport try_megabytes_to_bytes, as there's no particular reason to keep this in EE only.
Diffstat (limited to 'spec/lib/gitlab/utils_spec.rb')
-rw-r--r--spec/lib/gitlab/utils_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb
index 8f5029b3565..4645339f439 100644
--- a/spec/lib/gitlab/utils_spec.rb
+++ b/spec/lib/gitlab/utils_spec.rb
@@ -213,4 +213,22 @@ describe Gitlab::Utils do
expect(subject[:variables].first[:key]).to eq('VAR1')
end
end
+
+ describe '.try_megabytes_to_bytes' do
+ context 'when the size can be converted to megabytes' do
+ it 'returns the size in megabytes' do
+ size = described_class.try_megabytes_to_bytes(1)
+
+ expect(size).to eq(1.megabytes)
+ end
+ end
+
+ context 'when the size can not be converted to megabytes' do
+ it 'returns the input size' do
+ size = described_class.try_megabytes_to_bytes('foo')
+
+ expect(size).to eq('foo')
+ end
+ end
+ end
end