diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2019-06-10 15:44:51 +0000 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-06-10 15:44:51 +0000 |
commit | d5e8e1ef1341c65fe9105c38b9532239462ace9d (patch) | |
tree | 079289e2a8c8ba98241ccb90674495eccecd01c5 | |
parent | de4e63b3fcec455549f69d604424c70205694e55 (diff) | |
parent | c699c6fe3ce0a0dffecfa380377fa44a6866a148 (diff) | |
download | gitlab-ce-d5e8e1ef1341c65fe9105c38b9532239462ace9d.tar.gz |
Merge branch 'ac-63020-typeerror-nil-can-t-be-coerced-into-integer' into 'master'
Fix nil coercion updating storage size on project statistics
See merge request gitlab-org/gitlab-ce!29425
-rw-r--r-- | app/models/project_statistics.rb | 2 | ||||
-rw-r--r-- | changelogs/unreleased/ac-63020-typeerror-nil-can-t-be-coerced-into-integer.yml | 5 | ||||
-rw-r--r-- | spec/models/project_statistics_spec.rb | 12 |
3 files changed, 18 insertions, 1 deletions
diff --git a/app/models/project_statistics.rb b/app/models/project_statistics.rb index 11e3737298c..8a179b4d56d 100644 --- a/app/models/project_statistics.rb +++ b/app/models/project_statistics.rb @@ -54,7 +54,7 @@ class ProjectStatistics < ApplicationRecord end def update_storage_size - self.storage_size = repository_size + wiki_size + lfs_objects_size + build_artifacts_size + packages_size + self.storage_size = repository_size + wiki_size.to_i + lfs_objects_size + build_artifacts_size + packages_size end # Since this incremental update method does not call update_storage_size above, diff --git a/changelogs/unreleased/ac-63020-typeerror-nil-can-t-be-coerced-into-integer.yml b/changelogs/unreleased/ac-63020-typeerror-nil-can-t-be-coerced-into-integer.yml new file mode 100644 index 00000000000..51ac2358fba --- /dev/null +++ b/changelogs/unreleased/ac-63020-typeerror-nil-can-t-be-coerced-into-integer.yml @@ -0,0 +1,5 @@ +--- +title: Fix nil coercion updating storage size on project statistics +merge_request: 29425 +author: +type: fixed diff --git a/spec/models/project_statistics_spec.rb b/spec/models/project_statistics_spec.rb index 358873f9a2f..1cb49d83ffa 100644 --- a/spec/models/project_statistics_spec.rb +++ b/spec/models/project_statistics_spec.rb @@ -197,6 +197,18 @@ describe ProjectStatistics do expect(statistics.storage_size).to eq 9 end + + it 'works during wiki_size backfill' do + statistics.update!( + repository_size: 2, + wiki_size: nil, + lfs_objects_size: 3 + ) + + statistics.reload + + expect(statistics.storage_size).to eq 5 + end end describe '.increment_statistic' do |