debian-mirror-gitlab/spec/controllers/repositories/git_http_controller_spec.rb

90 lines
2.8 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe Repositories::GitHttpController do
2020-03-13 15:44:24 +05:30
let_it_be(:project) { create(:project, :public, :repository) }
2020-04-08 14:13:33 +05:30
let_it_be(:personal_snippet) { create(:personal_snippet, :public, :repository) }
let_it_be(:project_snippet) { create(:project_snippet, :public, :repository, project: project) }
2020-03-13 15:44:24 +05:30
2021-02-22 17:27:13 +05:30
context 'when repository container is a project' do
it_behaves_like Repositories::GitHttpController do
let(:container) { project }
let(:user) { project.owner }
let(:access_checker_class) { Gitlab::GitAccess }
2020-03-13 15:44:24 +05:30
2021-02-22 17:27:13 +05:30
describe 'POST #git_upload_pack' do
2020-03-13 15:44:24 +05:30
before do
2021-02-22 17:27:13 +05:30
allow(controller).to receive(:verify_workhorse_api!).and_return(true)
2020-03-13 15:44:24 +05:30
end
2021-02-22 17:27:13 +05:30
def send_request
post :git_upload_pack, params: params
2020-03-13 15:44:24 +05:30
end
2021-02-22 17:27:13 +05:30
context 'on a read-only instance' do
before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
2020-03-13 15:44:24 +05:30
end
2021-02-22 17:27:13 +05:30
it 'does not update project statistics' do
expect(ProjectDailyStatisticsWorker).not_to receive(:perform_async)
2020-07-01 16:08:20 +05:30
2021-02-22 17:27:13 +05:30
send_request
2020-07-01 16:08:20 +05:30
end
end
2020-03-13 15:44:24 +05:30
2020-04-22 19:07:51 +05:30
context 'when project_statistics_sync feature flag is disabled' do
before do
stub_feature_flags(project_statistics_sync: false)
end
2021-02-22 17:27:13 +05:30
it 'updates project statistics async for projects' do
2020-04-22 19:07:51 +05:30
expect(ProjectDailyStatisticsWorker).to receive(:perform_async)
send_request
end
end
2021-02-22 17:27:13 +05:30
it 'updates project statistics sync for projects' do
2020-04-22 19:07:51 +05:30
expect { send_request }.to change {
2021-02-22 17:27:13 +05:30
Projects::DailyStatisticsFinder.new(container).total_fetch_count
2020-04-22 19:07:51 +05:30
}.from(0).to(1)
2020-03-13 15:44:24 +05:30
end
2020-04-22 19:07:51 +05:30
2021-02-22 17:27:13 +05:30
it 'records a namespace onboarding progress action' do
expect_next_instance_of(OnboardingProgressService) do |service|
expect(service).to receive(:execute).with(action: :git_read)
2020-04-22 19:07:51 +05:30
end
2021-02-22 17:27:13 +05:30
send_request
2020-03-13 15:44:24 +05:30
end
end
end
end
2021-02-22 17:27:13 +05:30
context 'when repository container is a project wiki' do
it_behaves_like Repositories::GitHttpController do
let(:container) { create(:project_wiki, :empty_repo, project: project) }
2020-04-08 14:13:33 +05:30
let(:user) { project.owner }
2021-02-22 17:27:13 +05:30
let(:access_checker_class) { Gitlab::GitAccessWiki }
2020-03-13 15:44:24 +05:30
end
end
2020-04-08 14:13:33 +05:30
context 'when repository container is a personal snippet' do
2021-02-22 17:27:13 +05:30
it_behaves_like Repositories::GitHttpController do
let(:container) { personal_snippet }
2020-04-08 14:13:33 +05:30
let(:user) { personal_snippet.author }
2021-02-22 17:27:13 +05:30
let(:access_checker_class) { Gitlab::GitAccessSnippet }
2020-04-08 14:13:33 +05:30
end
end
context 'when repository container is a project snippet' do
2021-02-22 17:27:13 +05:30
it_behaves_like Repositories::GitHttpController do
let(:container) { project_snippet }
2020-04-08 14:13:33 +05:30
let(:user) { project_snippet.author }
2021-02-22 17:27:13 +05:30
let(:access_checker_class) { Gitlab::GitAccessSnippet }
2020-04-08 14:13:33 +05:30
end
end
2020-03-13 15:44:24 +05:30
end