Commit 303f165c authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix creation of job_artifact_uploader

parent 61864a5a
......@@ -15,11 +15,11 @@ module Ci
has_one :last_deployment, -> { order('deployments.id DESC') }, as: :deployable, class_name: 'Deployment'
has_many :trace_sections, class_name: 'Ci::BuildTraceSection'
has_many :job_artifacts, class_name: 'Ci::JobArtifact', foreign_key: :ci_job_id
# TODO: what to do with dependent destroy
has_many :job_artifacts, class_name: 'Ci::JobArtifact', foreign_key: :ci_job_id, dependent: :destroy
has_one :job_archive, -> () { where(file_type: Ci::JobArtifact.file_types[:archive]) }, class_name: 'Ci::JobArtifact', foreign_key: :ci_job_id
has_one :job_metadata, -> () { where(file_type: Ci::JobArtifact.file_types[:metadata]) }, class_name: 'Ci::JobArtifact', foreign_key: :ci_job_id
# The "environment" field for builds is a String, and is the unexpanded name
def persisted_environment
@persisted_environment ||= Environment.find_by(
......
......@@ -3,12 +3,6 @@ class JobArtifactUploader < ArtifactUploader
@artifact = artifact
end
# If this record exists, the associatied artifact is there. Every artifact
# persisted will have an associated file
def exists?
true
end
def size
return super unless @artifact.size
......
......@@ -155,8 +155,10 @@ FactoryGirl.define do
end
trait :artifacts do
job_archive factory: :ci_job_artifact
job_metadata factory: :ci_job_metadata
after(:create) do |build|
create(:ci_job_artifact, job: build)
create(:ci_job_metadata, job: build)
end
end
trait :expired do
......
......@@ -2,15 +2,17 @@ include ActionDispatch::TestProcess
FactoryGirl.define do
factory :ci_job_artifact, class: Ci::JobArtifact do
project
job factory: :ci_build
file_type :archive
after :build do |artifact|
artifact.project ||= artifact.job.project
end
after :create do |artifact|
if artifact.archive?
artifact.file = fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'),
'application/zip')
artifact.save
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