debian-mirror-gitlab/spec/helpers/storage_helper_spec.rb

26 lines
741 B
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
require "spec_helper"
2017-08-17 22:00:37 +05:30
describe StorageHelper do
2018-11-08 19:23:39 +05:30
describe "#storage_counter" do
it "formats bytes to one decimal place" do
expect(helper.storage_counter(1.23.megabytes)).to eq("1.2 MB")
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
it "does not add decimals for sizes < 1 MB" do
expect(helper.storage_counter(23.5.kilobytes)).to eq("24 KB")
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
it "does not add decimals for zeroes" do
expect(helper.storage_counter(2.megabytes)).to eq("2 MB")
2017-08-17 22:00:37 +05:30
end
2018-11-08 19:23:39 +05:30
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
2017-08-17 22:00:37 +05:30
end
end
end