diff options
author | Douwe Maan <douwe@gitlab.com> | 2019-04-09 12:52:27 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2019-04-09 12:52:27 +0300 |
commit | ca03848d212d46c72857e4ae5a698762c6958535 (patch) | |
tree | dbc22feccbb52a65f63143aa0adfba3a64a14099 /spec/services | |
parent | 87f665e83e2139363f94d19bae08c3a2682c6481 (diff) | |
parent | 770f721962cd30e930ab7b6e06e9386da6325c3c (diff) |
Merge branch 'delay-update-statictics' into 'master'
Fix the bug that the project statistics is not updated
See merge request gitlab-org/gitlab-ce!26854
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/projects/update_statistics_service_spec.rb | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/services/projects/update_statistics_service_spec.rb b/spec/services/projects/update_statistics_service_spec.rb new file mode 100644 index 00000000000..7e351c9ce54 --- /dev/null +++ b/spec/services/projects/update_statistics_service_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe Projects::UpdateStatisticsService do + let(:service) { described_class.new(project, nil, statistics: statistics)} + let(:statistics) { %w(repository_size) } + + describe '#execute' do + context 'with a non-existing project' do + let(:project) { nil } + + it 'does nothing' do + expect_any_instance_of(ProjectStatistics).not_to receive(:refresh!) + + service.execute + end + end + + context 'with an existing project without a repository' do + let(:project) { create(:project) } + + it 'does nothing' do + expect_any_instance_of(ProjectStatistics).not_to receive(:refresh!) + + service.execute + end + end + + context 'with an existing project with a repository' do + let(:project) { create(:project, :repository) } + + it 'refreshes the project statistics' do + expect_any_instance_of(ProjectStatistics).to receive(:refresh!) + .with(only: statistics.map(&:to_sym)) + .and_call_original + + service.execute + end + end + end +end |