2018-06-13 08:39:47 +00:00
|
|
|
require "spec_helper"
|
2016-11-22 16:58:10 +00:00
|
|
|
|
|
|
|
describe StorageHelper do
|
2018-06-13 08:39:47 +00:00
|
|
|
describe "#storage_counter" do
|
|
|
|
it "formats bytes to one decimal place" do
|
|
|
|
expect(helper.storage_counter(1.23.megabytes)).to eq("1.2 MB")
|
2016-11-22 16:58:10 +00:00
|
|
|
end
|
|
|
|
|
2018-06-13 08:39:47 +00:00
|
|
|
it "does not add decimals for sizes < 1 MB" do
|
|
|
|
expect(helper.storage_counter(23.5.kilobytes)).to eq("24 KB")
|
2016-11-22 16:58:10 +00:00
|
|
|
end
|
|
|
|
|
2018-06-13 08:39:47 +00:00
|
|
|
it "does not add decimals for zeroes" do
|
|
|
|
expect(helper.storage_counter(2.megabytes)).to eq("2 MB")
|
2016-11-22 16:58:10 +00:00
|
|
|
end
|
|
|
|
|
2018-06-13 08:39:47 +00:00
|
|
|
it "uses commas as thousands separator" do
|
2018-12-15 09:06:56 +00:00
|
|
|
expect(helper.storage_counter(100_000_000_000_000_000_000_000)).to eq("86,736.2 EB")
|
2016-11-22 16:58:10 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|