summaryrefslogtreecommitdiff
path: root/spec/lib/api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 03:07:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-13 03:07:50 +0000
commit38bab6e1581d30c0e9d312474fd796404cc7b484 (patch)
treee4e6b11e2788cae577ecb1efa5195f9bc77b83f2 /spec/lib/api
parent47b8f79a0896f406008d5a7eda2781f8da301e91 (diff)
downloadgitlab-ce-38bab6e1581d30c0e9d312474fd796404cc7b484.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/api')
-rw-r--r--spec/lib/api/projects_batch_counting_spec.rb72
1 files changed, 0 insertions, 72 deletions
diff --git a/spec/lib/api/projects_batch_counting_spec.rb b/spec/lib/api/projects_batch_counting_spec.rb
deleted file mode 100644
index 6094952bb52..00000000000
--- a/spec/lib/api/projects_batch_counting_spec.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-describe API::ProjectsBatchCounting do
- subject do
- Class.new do
- include ::API::ProjectsBatchCounting
- end
- end
-
- describe '.preload_and_batch_count!' do
- let(:projects) { double }
- let(:preloaded_projects) { double }
-
- it 'preloads the relation' do
- allow(subject).to receive(:execute_batch_counting).with(preloaded_projects)
-
- expect(subject).to receive(:preload_relation).with(projects).and_return(preloaded_projects)
-
- expect(subject.preload_and_batch_count!(projects)).to eq(preloaded_projects)
- end
-
- it 'executes batch counting' do
- allow(subject).to receive(:preload_relation).with(projects).and_return(preloaded_projects)
-
- expect(subject).to receive(:execute_batch_counting).with(preloaded_projects)
-
- subject.preload_and_batch_count!(projects)
- end
- end
-
- describe '.execute_batch_counting' do
- let(:projects) { create_list(:project, 2) }
- let(:count_service) { double }
-
- it 'counts forks' do
- allow(::Projects::BatchForksCountService).to receive(:new).with(projects).and_return(count_service)
-
- expect(count_service).to receive(:refresh_cache)
-
- subject.execute_batch_counting(projects)
- end
-
- it 'counts open issues' do
- allow(::Projects::BatchOpenIssuesCountService).to receive(:new).with(projects).and_return(count_service)
-
- expect(count_service).to receive(:refresh_cache)
-
- subject.execute_batch_counting(projects)
- end
-
- context 'custom fork counting' do
- subject do
- Class.new do
- include ::API::ProjectsBatchCounting
- def self.forks_counting_projects(projects)
- [projects.first]
- end
- end
- end
-
- it 'counts forks for other projects' do
- allow(::Projects::BatchForksCountService).to receive(:new).with([projects.first]).and_return(count_service)
-
- expect(count_service).to receive(:refresh_cache)
-
- subject.execute_batch_counting(projects)
- end
- end
- end
-end