Commit d3994058 authored by Vladimir Shushlin's avatar Vladimir Shushlin

Fail pages deployment if it isn't latest

parent 17732266
......@@ -156,6 +156,9 @@ module Projects
deployment = project.pages_deployments.create!(file: file,
file_count: entries_count,
file_sha256: sha256)
raise InvalidStateError, 'build SHA is outdated for this ref' unless latest?
project.update_pages_deployment!(deployment)
end
......
......@@ -79,6 +79,19 @@ RSpec.describe Projects::UpdatePagesService do
end
end
it 'fails if sha on branch was updated before deployment was uploaded' do
expect(subject).to receive(:create_pages_deployment).and_wrap_original do |m, *args|
build.update!(ref: 'feature')
m.call(*args)
end
expect(execute).not_to eq(:success)
expect(project.pages_metadatum).not_to be_deployed
expect(deploy_status).to be_failed
expect(deploy_status.description).to eq('build SHA is outdated for this ref')
end
it 'does not fail if pages_metadata is absent' do
project.pages_metadatum.destroy!
project.reload
......
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