Commit dcd2eeb1 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Rename container image to repository in specs

parent 3e01fed5
......@@ -150,7 +150,7 @@ class Namespace < ActiveRecord::Base
end
def any_project_has_container_registry_images?
projects.joins(:container_images).any?
projects.joins(:container_repositories).any?
end
def send_update_instructions
......
......@@ -157,7 +157,7 @@ class Project < ActiveRecord::Base
has_one :import_data, dependent: :destroy, class_name: "ProjectImportData"
has_one :project_feature, dependent: :destroy
has_one :statistics, class_name: 'ProjectStatistics', dependent: :delete
has_many :container_images, dependent: :destroy
has_many :container_repositories, dependent: :destroy
has_many :commit_statuses, dependent: :destroy
has_many :pipelines, dependent: :destroy, class_name: 'Ci::Pipeline'
......@@ -908,7 +908,7 @@ class Project < ActiveRecord::Base
expire_caches_before_rename(old_path_with_namespace)
if container_images.present?
if container_repositories.present?
Rails.logger.error "Project #{old_path_with_namespace} cannot be renamed because container registry images are present"
# we currently doesn't support renaming repository if it contains images in container registry
......
......@@ -36,7 +36,7 @@ module Projects
raise TransferError.new("Project with same path in target namespace already exists")
end
unless project.container_images.empty?
unless project.container_repositories.empty?
# we currently doesn't support renaming repository if it contains images in container registry
raise TransferError.new('Project cannot be transferred, because images are present in its container registry')
end
......
......@@ -5,15 +5,15 @@ describe "Container Registry" do
let(:registry) { project.container_registry }
let(:tag_name) { 'latest' }
let(:tags) { [tag_name] }
let(:container_image) { create(:container_image) }
let(:image_name) { container_image.name }
let(:container_repository) { create(:container_repository) }
let(:image_name) { container_repository.name }
before do
login_as(:user)
project.team << [@user, :developer]
stub_container_registry_config(enabled: true)
stub_container_registry_tags(*tags)
project.container_images << container_image unless container_image.nil?
project.container_repositories << container_repository unless container_repository.nil?
allow(Auth::ContainerRegistryAuthenticationService).to receive(:full_access_token).and_return('token')
end
......@@ -23,7 +23,7 @@ describe "Container Registry" do
end
context 'when no images' do
let(:container_image) { }
let(:container_repository) { }
it { expect(page).to have_content('No container images in Container Registry for this project') }
end
......
......@@ -443,12 +443,12 @@ describe "Internal Project Access", feature: true do
end
describe "GET /:project_path/container_registry" do
let(:container_image) { create(:container_image) }
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_tags('latest')
stub_container_registry_config(enabled: true)
project.container_images << container_image
project.container_repositories << container_repository
end
subject { namespace_project_container_registry_index_path(project.namespace, project) }
......
......@@ -432,12 +432,12 @@ describe "Private Project Access", feature: true do
end
describe "GET /:project_path/container_registry" do
let(:container_image) { create(:container_image) }
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_tags('latest')
stub_container_registry_config(enabled: true)
project.container_images << container_image
project.container_repositories << container_repository
end
subject { namespace_project_container_registry_index_path(project.namespace, project) }
......
......@@ -443,12 +443,12 @@ describe "Public Project Access", feature: true do
end
describe "GET /:project_path/container_registry" do
let(:container_image) { create(:container_image) }
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_tags('latest')
stub_container_registry_config(enabled: true)
project.container_images << container_image
project.container_repositories << container_repository
end
subject { namespace_project_container_registry_index_path(project.namespace, project) }
......
......@@ -15,7 +15,7 @@ describe ContainerRegistry::Blob do
let(:project) { create(:project, path: 'test', group: group) }
let(:example_host) { 'example.com' }
let(:registry_url) { 'http://' + example_host }
let(:repository) { create(:container_image, name: '', project: project) }
let(:repository) { create(:container_repository, name: '', project: project) }
let(:blob) { repository.blob(config) }
before do
......
......@@ -5,7 +5,7 @@ describe ContainerRegistry::Tag do
let(:project) { create(:project, path: 'test', group: group) }
let(:example_host) { 'example.com' }
let(:registry_url) { 'http://' + example_host }
let(:repository) { create(:container_image, name: '', project: project) }
let(:repository) { create(:container_repository, name: '', project: project) }
let(:tag) { repository.tag('tag') }
let(:headers) { { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' } }
......
......@@ -115,7 +115,7 @@ merge_access_levels:
- protected_branch
push_access_levels:
- protected_branch
container_images:
container_repositories:
- name
project:
- taggings
......
......@@ -149,13 +149,13 @@ describe Namespace, models: true do
end
context "when any project has container images" do
let(:container_image) { create(:container_image) }
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_config(enabled: true)
stub_container_registry_tags('tag')
create(:empty_project, namespace: @namespace, container_images: [container_image])
create(:empty_project, namespace: @namespace, container_repositories: [container_repository])
allow(@namespace).to receive(:path_was).and_return(@namespace.path)
allow(@namespace).to receive(:path).and_return('new_path')
......
......@@ -1186,12 +1186,12 @@ describe Project, models: true do
end
context 'container registry with images' do
let(:container_image) { create(:container_image) }
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_config(enabled: true)
stub_container_registry_tags('tag')
project.container_images << container_image
project.container_repositories << container_repository
end
subject { project.rename_repo }
......
......@@ -3,13 +3,13 @@ require 'spec_helper'
describe ContainerImages::DestroyService, services: true do
describe '#execute' do
let(:user) { create(:user) }
let(:container_image) { create(:container_image, name: '') }
let(:project) { create(:project, path: 'test', namespace: user.namespace, container_images: [container_image]) }
let(:container_repository) { create(:container_repository, name: '') }
let(:project) { create(:project, path: 'test', namespace: user.namespace, container_repositorys: [container_repository]) }
let(:example_host) { 'example.com' }
let(:registry_url) { 'http://' + example_host }
it { expect(container_image).to be_valid }
it { expect(project.container_images).not_to be_empty }
it { expect(container_repository).to be_valid }
it { expect(project.container_repositorys).not_to be_empty }
context 'when container image has tags' do
before do
......@@ -19,15 +19,15 @@ describe ContainerImages::DestroyService, services: true do
it 'removes all tags before destroy' do
service = described_class.new(project, user)
expect(container_image).to receive(:delete_tags).and_return(true)
expect { service.execute(container_image) }.to change(project.container_images, :count).by(-1)
expect(container_repository).to receive(:delete_tags).and_return(true)
expect { service.execute(container_repository) }.to change(project.container_repositorys, :count).by(-1)
end
it 'fails when tags are not removed' do
service = described_class.new(project, user)
expect(container_image).to receive(:delete_tags).and_return(false)
expect { service.execute(container_image) }.to raise_error(ActiveRecord::RecordNotDestroyed)
expect(container_repository).to receive(:delete_tags).and_return(false)
expect { service.execute(container_repository) }.to raise_error(ActiveRecord::RecordNotDestroyed)
end
end
end
......
......@@ -90,12 +90,12 @@ describe Projects::DestroyService, services: true do
end
context 'container registry' do
let(:container_image) { create(:container_image) }
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_config(enabled: true)
stub_container_registry_tags('tag')
project.container_images << container_image
project.container_repositorys << container_repository
end
context 'images deletion succeeds' do
......
......@@ -29,12 +29,12 @@ describe Projects::TransferService, services: true do
end
context 'disallow transfering of project with tags' do
let(:container_image) { create(:container_image) }
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_config(enabled: true)
stub_container_registry_tags('tag')
project.container_images << container_image
project.container_repositorys << container_repository
end
subject { transfer_project(project, user, group) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment