Commit 9c76d457 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'vshushlin-dont-migrate-pages-metadata-in-flyight' into 'master'

Stop migrating pages metadata on API requests

See merge request gitlab-org/gitlab!62570
parents dca443fc 38277618
......@@ -437,12 +437,6 @@ class Namespace < ApplicationRecord
end
def all_projects_with_pages
if all_projects.pages_metadata_not_migrated.exists?
Gitlab::BackgroundMigration::MigratePagesMetadata.new.perform_on_relation(
all_projects.pages_metadata_not_migrated
)
end
all_projects.with_pages_deployed
end
......
......@@ -227,16 +227,6 @@ class PagesDomain < ApplicationRecord
def pages_deployed?
return false unless project
# TODO: remove once `pages_metadatum` is migrated
# https://gitlab.com/gitlab-org/gitlab/issues/33106
unless project.pages_metadatum
Gitlab::BackgroundMigration::MigratePagesMetadata
.new
.perform_on_relation(Project.where(id: project_id))
project.reset
end
project.pages_metadatum&.deployed?
end
......
......@@ -1387,38 +1387,16 @@ RSpec.describe Namespace do
describe '#pages_virtual_domain' do
let(:project) { create(:project, namespace: namespace) }
context 'when there are pages deployed for the project' do
context 'but pages metadata is not migrated' do
before do
generic_commit_status = create(:generic_commit_status, :success, stage: 'deploy', name: 'pages:deploy')
generic_commit_status.update!(project: project)
project.pages_metadatum.destroy!
end
it 'migrates pages metadata and returns the virual domain' do
virtual_domain = namespace.pages_virtual_domain
expect(project.reload.pages_metadatum.deployed).to eq(true)
expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
expect(virtual_domain.lookup_paths).not_to be_empty
end
end
context 'and pages metadata is migrated' do
before do
it 'returns the virual domain' do
project.mark_pages_as_deployed
end
project.update_pages_deployment!(create(:pages_deployment, project: project))
it 'returns the virual domain' do
virtual_domain = namespace.pages_virtual_domain
expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
expect(virtual_domain.lookup_paths).not_to be_empty
end
end
end
end
describe '#any_project_with_pages_deployed?' do
it 'returns true if any project nested under the group has pages deployed' do
......
......@@ -664,25 +664,16 @@ RSpec.describe PagesDomain do
end
end
context 'when there are pages deployed for the project' do
before do
generic_commit_status = create(:generic_commit_status, :success, stage: 'deploy', name: 'pages:deploy')
generic_commit_status.update!(project: project)
project.pages_metadatum.destroy!
project.reload
end
it 'returns the virual domain when there are pages deployed for the project' do
project.mark_pages_as_deployed
project.update_pages_deployment!(create(:pages_deployment, project: project))
it 'returns the virual domain' do
expect(Pages::VirtualDomain).to receive(:new).with([project], domain: pages_domain).and_call_original
expect(pages_domain.pages_virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
end
virtual_domain = pages_domain.pages_virtual_domain
it 'migrates project pages metadata' do
expect { pages_domain.pages_virtual_domain }.to change {
project.reload.pages_metadatum&.deployed
}.from(nil).to(true)
end
expect(virtual_domain).to be_an_instance_of(Pages::VirtualDomain)
expect(virtual_domain.lookup_paths).not_to be_empty
end
end
......
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