Commit 943cd119 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'jv-pages-deployed' into 'master'

Use pages_metadatum in Project#pages_deployed?

See merge request gitlab-org/gitlab!37610
parents 8a2700a6 cd67df08
......@@ -1740,7 +1740,7 @@ class Project < ApplicationRecord
end
def pages_deployed?
Dir.exist?(public_pages_path)
pages_metadatum&.deployed?
end
def pages_group_url
......@@ -1773,10 +1773,6 @@ class Project < ApplicationRecord
File.join(Settings.pages.path, full_path)
end
def public_pages_path
File.join(pages_path, 'public')
end
def pages_available?
Gitlab.config.pages.enabled
end
......
......@@ -1698,9 +1698,9 @@ RSpec.describe Project do
subject { project.pages_deployed? }
context 'if public folder does exist' do
context 'if pages are deployed' do
before do
allow(Dir).to receive(:exist?).with(project.public_pages_path).and_return(true)
project.pages_metadatum.update_column(:deployed, true)
end
it { is_expected.to be_truthy }
......
......@@ -53,7 +53,7 @@ RSpec.describe Projects::UpdatePagesService do
# Check that all expected files are extracted
%w[index.html zero .hidden/file].each do |filename|
expect(File.exist?(File.join(project.public_pages_path, filename))).to be_truthy
expect(File.exist?(File.join(project.pages_path, 'public', filename))).to be_truthy
end
end
......@@ -65,15 +65,17 @@ RSpec.describe Projects::UpdatePagesService do
it 'removes pages after destroy' do
expect(PagesWorker).to receive(:perform_in)
expect(project.pages_deployed?).to be_falsey
expect(Dir.exist?(File.join(project.pages_path))).to be_falsey
expect(execute).to eq(:success)
expect(project.pages_metadatum).to be_deployed
expect(project.pages_deployed?).to be_truthy
expect(Dir.exist?(File.join(project.pages_path))).to be_truthy
project.destroy
expect(project.pages_deployed?).to be_falsey
expect(Dir.exist?(File.join(project.pages_path))).to be_falsey
expect(ProjectPagesMetadatum.find_by_project_id(project)).to be_nil
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