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

Fix creation of job_artifact_uploader

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