diff options
author | Markus Koller <markus-koller@gmx.ch> | 2016-11-22 19:58:10 +0300 |
---|---|---|
committer | Markus Koller <markus-koller@gmx.ch> | 2016-12-21 18:39:49 +0300 |
commit | 3ef4f74b1acc9399db320b53dffc592542de0126 (patch) | |
tree | edc99011c4ed64ec50e457d3e59c1149fbb3a5ce /spec/models/lfs_objects_project_spec.rb | |
parent | 6fd58ee48dcfbca49c609c45004d6c25035af2eb (diff) |
Add more storage statistics
This adds counters for build artifacts and LFS objects, and moves
the preexisting repository_size and commit_count from the projects
table into a new project_statistics table.
The counters are displayed in the administration area for projects
and groups, and also available through the API for admins (on */all)
and normal users (on */owned)
The statistics are updated through ProjectCacheWorker, which can now
do more granular updates with the new :statistics argument.
Diffstat (limited to 'spec/models/lfs_objects_project_spec.rb')
-rw-r--r-- | spec/models/lfs_objects_project_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/lfs_objects_project_spec.rb b/spec/models/lfs_objects_project_spec.rb new file mode 100644 index 00000000000..7bc278e350f --- /dev/null +++ b/spec/models/lfs_objects_project_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe LfsObjectsProject, models: true do + subject { create(:lfs_objects_project, project: project) } + let(:project) { create(:empty_project) } + + describe 'associations' do + it { is_expected.to belong_to(:project) } + it { is_expected.to belong_to(:lfs_object) } + end + + describe 'validation' do + it { is_expected.to validate_presence_of(:lfs_object_id) } + it { is_expected.to validate_uniqueness_of(:lfs_object_id).scoped_to(:project_id).with_message("already exists in project") } + + it { is_expected.to validate_presence_of(:project_id) } + end + + describe '#update_project_statistics' do + it 'updates project statistics when the object is added' do + expect(ProjectCacheWorker).to receive(:perform_async) + .with(project.id, [], [:lfs_objects_size]) + + subject.save! + end + + it 'updates project statistics when the object is removed' do + subject.save! + + expect(ProjectCacheWorker).to receive(:perform_async) + .with(project.id, [], [:lfs_objects_size]) + + subject.destroy + end + end +end |