Commit 9fcba59b authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix tests

parent bf20a3aa
......@@ -16,16 +16,6 @@ module Ci
validates :source_project, presence: true
validates :source_job, presence: true
validates :source_pipeline, presence: true
before_validation :set_dependent_objects
private
def set_dependent_objects
project ||= pipeline.project
source_pipeline ||= source_job.pipeline
source_project ||= source_pipeline.project
end
end
end
end
......@@ -51,12 +51,6 @@ module Ci
return error('No builds for this pipeline.')
end
_create_pipeline
end
private
def _create_pipeline
Ci::Pipeline.transaction do
update_merge_requests_head_pipeline if pipeline.save
......@@ -72,6 +66,8 @@ module Ci
pipeline.tap(&:process!)
end
private
def update_merge_requests_head_pipeline
return unless pipeline.latest?
......
......@@ -34,7 +34,11 @@ module Ci
pipeline = Ci::CreatePipelineService.new(project, job.user, ref: params[:ref]).
execute(:pipeline, ignore_skip_ci: true) do |pipeline|
job.sourced_pipelines.create!(pipeline: pipeline)
job.sourced_pipelines.create!(
source_pipeline: job.pipeline,
source_project: job.project,
pipeline: pipeline,
project: project)
end
if pipeline.persisted?
......
......@@ -55,7 +55,7 @@ describe API::Triggers do
post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'other-branch')
expect(response).to have_http_status(400)
expect(json_response['message']).to eq('No pipeline created')
expect(json_response['message']).to eq('base' => ["Reference not found"])
end
context 'Validates variables' do
......@@ -87,8 +87,8 @@ describe API::Triggers do
end
context 'when triggering a pipeline from a trigger token' do
it 'does not leak the presence of project when using valid token' do
post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' }
it 'does not leak the presence of project when token is for different project' do
post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' }
expect(response).to have_http_status(404)
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