Commit 7c77e047 authored by Reuben Pereira's avatar Reuben Pereira

Ignore the projects.container_registry_enabled column

projects.container_registry_enabled is no longer used. Use
project_features.container_registry_access_level instead.
parent 411012c4
...@@ -95,10 +95,6 @@ module ProjectFeaturesCompatibility ...@@ -95,10 +95,6 @@ module ProjectFeaturesCompatibility
# attribute. # attribute.
def container_registry_enabled=(value) def container_registry_enabled=(value)
write_feature_attribute_boolean(:container_registry_access_level, value) write_feature_attribute_boolean(:container_registry_access_level, value)
# TODO: Remove this when we remove the projects.container_registry_enabled
# column. https://gitlab.com/gitlab-org/gitlab/-/issues/335425
super
end end
private private
......
...@@ -43,6 +43,8 @@ class Project < ApplicationRecord ...@@ -43,6 +43,8 @@ class Project < ApplicationRecord
extend Gitlab::ConfigHelper extend Gitlab::ConfigHelper
ignore_columns :container_registry_enabled, remove_after: '2021-09-22', remove_with: '14.4'
BoardLimitExceeded = Class.new(StandardError) BoardLimitExceeded = Class.new(StandardError)
ignore_columns :mirror_last_update_at, :mirror_last_successful_update_at, remove_after: '2021-09-22', remove_with: '14.4' ignore_columns :mirror_last_update_at, :mirror_last_successful_update_at, remove_after: '2021-09-22', remove_with: '14.4'
......
...@@ -2421,39 +2421,20 @@ RSpec.describe Project, factory_default: :keep do ...@@ -2421,39 +2421,20 @@ RSpec.describe Project, factory_default: :keep do
let_it_be_with_reload(:project) { create(:project) } let_it_be_with_reload(:project) { create(:project) }
it 'updates project_feature', :aggregate_failures do it 'updates project_feature', :aggregate_failures do
# Simulate an existing project that has container_registry enabled
project.update_column(:container_registry_enabled, true)
project.project_feature.update_column(:container_registry_access_level, ProjectFeature::ENABLED)
project.update!(container_registry_enabled: false) project.update!(container_registry_enabled: false)
expect(project.read_attribute(:container_registry_enabled)).to eq(false)
expect(project.project_feature.container_registry_access_level).to eq(ProjectFeature::DISABLED) expect(project.project_feature.container_registry_access_level).to eq(ProjectFeature::DISABLED)
project.update!(container_registry_enabled: true) project.update!(container_registry_enabled: true)
expect(project.read_attribute(:container_registry_enabled)).to eq(true)
expect(project.project_feature.container_registry_access_level).to eq(ProjectFeature::ENABLED) expect(project.project_feature.container_registry_access_level).to eq(ProjectFeature::ENABLED)
end end
it 'rollsback both projects and project_features row in case of error', :aggregate_failures do
project.update_column(:container_registry_enabled, true)
project.project_feature.update_column(:container_registry_access_level, ProjectFeature::ENABLED)
allow(project).to receive(:valid?).and_return(false)
expect { project.update!(container_registry_enabled: false) }.to raise_error(ActiveRecord::RecordInvalid)
expect(project.reload.read_attribute(:container_registry_enabled)).to eq(true)
expect(project.project_feature.reload.container_registry_access_level).to eq(ProjectFeature::ENABLED)
end
end end
describe '#container_registry_enabled' do describe '#container_registry_enabled' do
let_it_be_with_reload(:project) { create(:project) } let_it_be_with_reload(:project) { create(:project) }
it 'delegates to project_feature', :aggregate_failures do it 'delegates to project_feature', :aggregate_failures do
project.update_column(:container_registry_enabled, true)
project.project_feature.update_column(:container_registry_access_level, ProjectFeature::DISABLED) project.project_feature.update_column(:container_registry_access_level, ProjectFeature::DISABLED)
expect(project.container_registry_enabled).to eq(false) expect(project.container_registry_enabled).to eq(false)
......
...@@ -231,7 +231,6 @@ RSpec.describe API::Projects do ...@@ -231,7 +231,6 @@ RSpec.describe API::Projects do
end end
it 'includes correct value of container_registry_enabled', :aggregate_failures do it 'includes correct value of container_registry_enabled', :aggregate_failures do
project.update_column(:container_registry_enabled, true)
project.project_feature.update!(container_registry_access_level: ProjectFeature::DISABLED) project.project_feature.update!(container_registry_access_level: ProjectFeature::DISABLED)
get api('/projects', user) get api('/projects', user)
...@@ -1113,6 +1112,16 @@ RSpec.describe API::Projects do ...@@ -1113,6 +1112,16 @@ RSpec.describe API::Projects do
expect(Project.find_by(path: project[:path]).container_registry_access_level).to eq(ProjectFeature::ENABLED) expect(Project.find_by(path: project[:path]).container_registry_access_level).to eq(ProjectFeature::ENABLED)
end end
it 'assigns container_registry_enabled to project' do
project = attributes_for(:project, { container_registry_enabled: true })
post api('/projects', user), params: project
expect(response).to have_gitlab_http_status(:created)
expect(json_response['container_registry_enabled']).to eq(true)
expect(Project.find_by(path: project[:path]).container_registry_access_level).to eq(ProjectFeature::ENABLED)
end
it 'creates a project using a template' do it 'creates a project using a template' do
expect { post api('/projects', user), params: { template_name: 'rails', name: 'rails-test' } } expect { post api('/projects', user), params: { template_name: 'rails', name: 'rails-test' } }
.to change { Project.count }.by(1) .to change { Project.count }.by(1)
...@@ -1560,6 +1569,18 @@ RSpec.describe API::Projects do ...@@ -1560,6 +1569,18 @@ RSpec.describe API::Projects do
expect(json_response['error']).to eq('name is missing') expect(json_response['error']).to eq('name is missing')
end end
it 'sets container_registry_enabled' do
project = attributes_for(:project).tap do |attrs|
attrs[:container_registry_enabled] = true
end
post api("/projects/user/#{user.id}", admin), params: project
expect(response).to have_gitlab_http_status(:created)
expect(json_response['container_registry_enabled']).to eq(true)
expect(Project.find_by(path: project[:path]).container_registry_access_level).to eq(ProjectFeature::ENABLED)
end
it 'assigns attributes to project' do it 'assigns attributes to project' do
project = attributes_for(:project, { project = attributes_for(:project, {
issues_enabled: false, issues_enabled: false,
...@@ -3050,6 +3071,16 @@ RSpec.describe API::Projects do ...@@ -3050,6 +3071,16 @@ RSpec.describe API::Projects do
expect(Project.find_by(path: project[:path]).container_registry_access_level).to eq(ProjectFeature::PRIVATE) expect(Project.find_by(path: project[:path]).container_registry_access_level).to eq(ProjectFeature::PRIVATE)
end end
it 'sets container_registry_enabled' do
project.project_feature.update!(container_registry_access_level: ProjectFeature::DISABLED)
put(api("/projects/#{project.id}", user), params: { container_registry_enabled: true })
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['container_registry_enabled']).to eq(true)
expect(project.reload.container_registry_access_level).to eq(ProjectFeature::ENABLED)
end
it 'returns 400 when nothing sent' do it 'returns 400 when nothing sent' do
project_param = {} project_param = {}
......
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