Commit 031ee142 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'blackst0ne-rails5-fix-storage-counter-helper' into 'master'

Resolve "[Rails5] `StorageHelper#storage_counter uses commas as thousands separator` fails"

Closes #47375

See merge request gitlab-org/gitlab-ce!19725
parents 4970c8c5 9a37ef43
require 'spec_helper' require "spec_helper"
describe StorageHelper do describe StorageHelper do
describe '#storage_counter' do describe "#storage_counter" do
it 'formats bytes to one decimal place' do it "formats bytes to one decimal place" do
expect(helper.storage_counter(1.23.megabytes)).to eq '1.2 MB' expect(helper.storage_counter(1.23.megabytes)).to eq("1.2 MB")
end end
it 'does not add decimals for sizes < 1 MB' do it "does not add decimals for sizes < 1 MB" do
expect(helper.storage_counter(23.5.kilobytes)).to eq '24 KB' expect(helper.storage_counter(23.5.kilobytes)).to eq("24 KB")
end end
it 'does not add decimals for zeroes' do it "does not add decimals for zeroes" do
expect(helper.storage_counter(2.megabytes)).to eq '2 MB' expect(helper.storage_counter(2.megabytes)).to eq("2 MB")
end end
it 'uses commas as thousands separator' do it "uses commas as thousands separator" do
expect(helper.storage_counter(100_000_000_000_000_000)).to eq '90,949.5 TB' 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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment