diff options
author | blackst0ne <blackst0ne.ru@gmail.com> | 2018-06-13 10:14:42 +1100 |
---|---|---|
committer | blackst0ne <blackst0ne.ru@gmail.com> | 2018-06-13 10:14:42 +1100 |
commit | 7c5af956486a177e34a1785ca5e713207b019782 (patch) | |
tree | 92e534c1492d4531b3bc253825db887a67549423 | |
parent | b4f29f589ba49d5a127f2a3076bb25997de9f29a (diff) | |
download | gitlab-ce-blackst0ne-rails5-fix-storage-counter-helper.tar.gz |
[Rails5] Fix `storage_counter` helperblackst0ne-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.
-rw-r--r-- | spec/helpers/storage_helper_spec.rb | 13 |
1 files 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 |