summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/namespace_spec.rb12
-rw-r--r--spec/models/project_statistics_spec.rb30
2 files changed, 13 insertions, 29 deletions
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index bfde367c47f..dd5edca5059 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -146,20 +146,20 @@ describe Namespace do
create(:project,
namespace: namespace,
statistics: build(:project_statistics,
+ storage_size: 606,
repository_size: 101,
lfs_objects_size: 202,
- build_artifacts_size: 303,
- packages_size: 404))
+ build_artifacts_size: 303))
end
let(:project2) do
create(:project,
namespace: namespace,
statistics: build(:project_statistics,
+ storage_size: 60,
repository_size: 10,
lfs_objects_size: 20,
- build_artifacts_size: 30,
- packages_size: 40))
+ build_artifacts_size: 30))
end
it "sums all project storage counters in the namespace" do
@@ -167,11 +167,10 @@ describe Namespace do
project2
statistics = described_class.with_statistics.find(namespace.id)
- expect(statistics.storage_size).to eq 1110
+ expect(statistics.storage_size).to eq 666
expect(statistics.repository_size).to eq 111
expect(statistics.lfs_objects_size).to eq 222
expect(statistics.build_artifacts_size).to eq 333
- expect(statistics.packages_size).to eq 444
end
it "correctly handles namespaces without projects" do
@@ -181,7 +180,6 @@ describe Namespace do
expect(statistics.repository_size).to eq 0
expect(statistics.lfs_objects_size).to eq 0
expect(statistics.build_artifacts_size).to eq 0
- expect(statistics.packages_size).to eq 0
end
end
diff --git a/spec/models/project_statistics_spec.rb b/spec/models/project_statistics_spec.rb
index 738398a06f9..c670b6aac56 100644
--- a/spec/models/project_statistics_spec.rb
+++ b/spec/models/project_statistics_spec.rb
@@ -124,30 +124,16 @@ describe ProjectStatistics do
end
describe '.increment_statistic' do
- shared_examples 'a statistic that increases storage_size' do
- it 'increases the statistic by that amount' do
- expect { described_class.increment_statistic(project.id, stat, 13) }
- .to change { statistics.reload.send(stat) || 0 }
- .by(13)
- end
-
- it 'increases also storage size by that amount' do
- expect { described_class.increment_statistic(project.id, stat, 20) }
- .to change { statistics.reload.storage_size }
- .by(20)
- end
+ it 'increases the statistic by that amount' do
+ expect { described_class.increment_statistic(project.id, :build_artifacts_size, 13) }
+ .to change { statistics.reload.build_artifacts_size }
+ .by(13)
end
- context 'when adjusting :build_artifacts_size' do
- let(:stat) { :build_artifacts_size }
-
- it_behaves_like 'a statistic that increases storage_size'
- end
-
- context 'when adjusting :packages_size' do
- let(:stat) { :packages_size }
-
- it_behaves_like 'a statistic that increases storage_size'
+ it 'increases also storage size by that amount' do
+ expect { described_class.increment_statistic(project.id, :build_artifacts_size, 20) }
+ .to change { statistics.reload.storage_size }
+ .by(20)
end
context 'when the amount is 0' do