From 7c5af956486a177e34a1785ca5e713207b019782 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Wed, 13 Jun 2018 10:14:42 +1100 Subject: [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 The `number_to_human` method is used in the GitLab's `storage_counter` helper. Since 5.0 rails now returns thousands of terabytes as petabytes, so there's no any comma as the thousands separator. So we don't want to check that anymore. And we don't want to test that rails returns petabytes either as rails team already does it in rails code itself. --- spec/helpers/storage_helper_spec.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/spec/helpers/storage_helper_spec.rb b/spec/helpers/storage_helper_spec.rb index 4627a1e1872..aa9ff5f8db7 100644 --- a/spec/helpers/storage_helper_spec.rb +++ b/spec/helpers/storage_helper_spec.rb @@ -14,8 +14,17 @@ describe StorageHelper 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' + # 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 + # The `number_to_human` method is used in the GitLab's `storage_counter` helper. + # Since 5.0 rails now returns thousands of terabytes as petabytes, so there's no any comma as the thousands separator. + # So we don't want to check that anymore. And we don't want to test that rails returns petabytes either + # as rails team already does it in rails code itself. + # Remove this test when removing rails5 code. + unless Gitlab.rails5? + it 'uses commas as thousands separator' do + expect(helper.storage_counter(100_000_000_000_000_000)).to eq '90,949.5 TB' + end end end end -- cgit v1.2.1