2021-09-04 01:27:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Projects::Packages::InfrastructureRegistryController do
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project, :private) }
|
|
|
|
|
|
|
|
let(:params) { { namespace_id: project.namespace, project_id: project } }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
project.add_maintainer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #index' do
|
|
|
|
subject { get :index, params: params, format: :html }
|
|
|
|
|
|
|
|
it_behaves_like 'returning response status', :ok
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
context 'when the packages registry is not available' do
|
2021-09-04 01:27:46 +05:30
|
|
|
before do
|
2021-10-27 15:23:28 +05:30
|
|
|
stub_config(packages: { enabled: false })
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'returning response status', :not_found
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
|
|
|
let_it_be(:terraform_module) { create(:terraform_module_package, project: project) }
|
|
|
|
|
|
|
|
subject { get :show, params: params.merge(id: terraform_module.id), format: :html }
|
|
|
|
|
|
|
|
it_behaves_like 'returning response status', :ok
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
context 'when the packages registry is not available' do
|
2021-09-04 01:27:46 +05:30
|
|
|
before do
|
2021-10-27 15:23:28 +05:30
|
|
|
stub_config(packages: { enabled: false })
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'returning response status', :not_found
|
|
|
|
end
|
2022-03-02 08:16:31 +05:30
|
|
|
|
|
|
|
context 'with package file pending destruction' do
|
|
|
|
let_it_be(:package_file_pending_destruction) { create(:package_file, :pending_destruction, package: terraform_module) }
|
|
|
|
|
|
|
|
let(:terraform_module_package_file) { terraform_module.package_files.first }
|
|
|
|
|
|
|
|
it 'does not return them' do
|
|
|
|
subject
|
|
|
|
|
|
|
|
expect(assigns(:package_files)).to contain_exactly(terraform_module_package_file)
|
|
|
|
end
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
|
|
|
end
|