120f9abaa1
- The pages are created when build artifacts for `pages` job are uploaded - Pages serve the content under: http://group.pages.domain.com/project - Pages can be used to serve the group page, special project named as host: group.pages.domain.com - User can provide own 403 and 404 error pages by creating 403.html and 404.html in group page project - Pages can be explicitly removed from the project by clicking Remove Pages in Project Settings - The size of pages is limited by Application Setting: max pages size, which limits the maximum size of unpacked archive (default: 100MB) - The public/ is extracted from artifacts and content is served as static pages - Pages asynchronous worker use `dd` to limit the unpacked tar size - Pages needs to be explicitly enabled and domain needs to be specified in gitlab.yml - Pages are part of backups - Pages notify the deployment status using Commit Status API - Pages use a new sidekiq queue: pages - Pages use a separate nginx config which needs to be explicitly added
58 lines
1.9 KiB
Ruby
58 lines
1.9 KiB
Ruby
require "spec_helper"
|
|
|
|
describe PagesWorker do
|
|
let(:project) { create :project }
|
|
let(:commit) { create :ci_commit, project: project, sha: project.commit('HEAD').sha }
|
|
let(:build) { create :ci_build, commit: commit, ref: 'HEAD' }
|
|
let(:worker) { PagesWorker.new }
|
|
let(:file) { fixture_file_upload(Rails.root + 'spec/fixtures/pages.tar.gz', 'application/octet-stream') }
|
|
let(:empty_file) { fixture_file_upload(Rails.root + 'spec/fixtures/pages_empty.tar.gz', 'application/octet-stream') }
|
|
let(:invalid_file) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'application/octet-stream') }
|
|
|
|
before do
|
|
project.remove_pages
|
|
end
|
|
|
|
context 'for valid file' do
|
|
before { build.update_attributes(artifacts_file: file) }
|
|
|
|
it 'succeeds' do
|
|
expect(project.pages_url).to be_nil
|
|
expect(worker.perform(build.id)).to be_truthy
|
|
expect(project.pages_url).to_not be_nil
|
|
end
|
|
|
|
it 'limits pages size' do
|
|
stub_application_setting(max_pages_size: 1)
|
|
expect(worker.perform(build.id)).to_not be_truthy
|
|
end
|
|
|
|
it 'removes pages after destroy' do
|
|
expect(project.pages_url).to be_nil
|
|
expect(worker.perform(build.id)).to be_truthy
|
|
expect(project.pages_url).to_not be_nil
|
|
project.destroy
|
|
expect(Dir.exist?(project.public_pages_path)).to be_falsey
|
|
end
|
|
end
|
|
|
|
it 'fails if no artifacts' do
|
|
expect(worker.perform(build.id)).to_not be_truthy
|
|
end
|
|
|
|
it 'fails for empty file fails' do
|
|
build.update_attributes(artifacts_file: empty_file)
|
|
expect(worker.perform(build.id)).to_not be_truthy
|
|
end
|
|
|
|
it 'fails for invalid archive' do
|
|
build.update_attributes(artifacts_file: invalid_file)
|
|
expect(worker.perform(build.id)).to_not be_truthy
|
|
end
|
|
|
|
it 'fails if sha on branch is not latest' do
|
|
commit.update_attributes(sha: 'old_sha')
|
|
build.update_attributes(artifacts_file: file)
|
|
expect(worker.perform(build.id)).to_not be_truthy
|
|
end
|
|
end
|