diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2018-12-13 20:26:56 +0100 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2019-02-27 11:52:35 +0100 |
commit | 5ae9a44aa17c8929627cc450f936cd960c143e25 (patch) | |
tree | 6a14d388f5687979a683d443868b4297ebc6838c /spec/workers | |
parent | 6fa88ed77e1693cda845efe49bf2c9a77aed2e4f (diff) | |
download | gitlab-ce-5ae9a44aa17c8929627cc450f936cd960c143e25.tar.gz |
Add project http fetch statistics API
The API get projects/:id/traffic/fetches allows user with write
access to the repository to get the number of clones for the
last 30 days.
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/project_daily_statistics_worker_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/workers/project_daily_statistics_worker_spec.rb b/spec/workers/project_daily_statistics_worker_spec.rb new file mode 100644 index 00000000000..8640add99e5 --- /dev/null +++ b/spec/workers/project_daily_statistics_worker_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true +require 'spec_helper' + +describe ProjectDailyStatisticsWorker, '#perform' do + let(:worker) { described_class.new } + let(:project) { create(:project) } + + describe '#perform' do + context 'with a non-existing project' do + it 'does nothing' do + expect(Projects::FetchStatisticsIncrementService).not_to receive(:new) + + worker.perform(-1) + end + end + + context 'with an existing project without a repository' do + it 'does nothing' do + expect(Projects::FetchStatisticsIncrementService).not_to receive(:new) + + worker.perform(project.id) + end + end + + it 'calls daily_statistics_service with the given project' do + project = create(:project, :repository) + + expect_next_instance_of(Projects::FetchStatisticsIncrementService, project) do |service| + expect(service).to receive(:execute) + end + + worker.perform(project.id) + end + end +end |