summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-06-13 19:39:47 +1100
committerblackst0ne <blackst0ne.ru@gmail.com>2018-06-13 19:39:47 +1100
commit9a37ef438e52fd33bb592f1b5cf637ecc2bb962d (patch)
treed0c6c42b2cc228fb220b8aff5456fdc22ae08431
parentb4f29f589ba49d5a127f2a3076bb25997de9f29a (diff)
downloadgitlab-ce-9a37ef438e52fd33bb592f1b5cf637ecc2bb962d.tar.gz
[Rails5] Fix `storage_counter` helper
Since rails 5 beta 2 support of petabytes and exabytes were added to the `number_to_human*` methods. See https://github.com/rails/rails/pull/22759 So for rails5 the comma separator gets shown for big numbers (EBs).
-rw-r--r--spec/helpers/storage_helper_spec.rb24
1 files changed, 14 insertions, 10 deletions
diff --git a/spec/helpers/storage_helper_spec.rb b/spec/helpers/storage_helper_spec.rb
index 4627a1e1872..c580b78c908 100644
--- a/spec/helpers/storage_helper_spec.rb
+++ b/spec/helpers/storage_helper_spec.rb
@@ -1,21 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe StorageHelper do
- describe '#storage_counter' do
- it 'formats bytes to one decimal place' do
- expect(helper.storage_counter(1.23.megabytes)).to eq '1.2 MB'
+ describe "#storage_counter" do
+ it "formats bytes to one decimal place" do
+ expect(helper.storage_counter(1.23.megabytes)).to eq("1.2 MB")
end
- it 'does not add decimals for sizes < 1 MB' do
- expect(helper.storage_counter(23.5.kilobytes)).to eq '24 KB'
+ it "does not add decimals for sizes < 1 MB" do
+ expect(helper.storage_counter(23.5.kilobytes)).to eq("24 KB")
end
- it 'does not add decimals for zeroes' do
- expect(helper.storage_counter(2.megabytes)).to eq '2 MB'
+ it "does not add decimals for zeroes" do
+ expect(helper.storage_counter(2.megabytes)).to eq("2 MB")
end
- it 'uses commas as thousands separator' do
- expect(helper.storage_counter(100_000_000_000_000_000)).to eq '90,949.5 TB'
+ it "uses commas as thousands separator" do
+ if Gitlab.rails5?
+ expect(helper.storage_counter(100_000_000_000_000_000_000_000)).to eq("86,736.2 EB")
+ else
+ expect(helper.storage_counter(100_000_000_000_000_000)).to eq("90,949.5 TB")
+ end
end
end
end