Commit 964933c9 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Create metadata object on build object creation

parent b15dd5df
...@@ -90,6 +90,7 @@ module Ci ...@@ -90,6 +90,7 @@ module Ci
before_save :ensure_token before_save :ensure_token
before_destroy { unscoped_project } before_destroy { unscoped_project }
before_create :ensure_metadata
after_create unless: :importing? do |build| after_create unless: :importing? do |build|
run_after_commit { BuildHooksWorker.perform_async(build.id) } run_after_commit { BuildHooksWorker.perform_async(build.id) }
end end
......
FactoryBot.define do
factory :ci_build_metadata, class: Ci::BuildMetadata do
build factory: :ci_build
after(:build) do |build_metadata, _|
build_metadata.project ||= build_metadata.build.project
end
end
end
...@@ -13,7 +13,7 @@ describe Ci::BuildMetadata do ...@@ -13,7 +13,7 @@ describe Ci::BuildMetadata do
end end
let(:build) { create(:ci_build, pipeline: pipeline) } let(:build) { create(:ci_build, pipeline: pipeline) }
let(:build_metadata) { create(:ci_build_metadata, build: build) } let(:build_metadata) { build.metadata }
describe '#update_timeout_state' do describe '#update_timeout_state' do
subject { build_metadata } subject { build_metadata }
......
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