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