Commit 64e85fda authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '33149-rename-more-builds' into 'master'

Fix raw_path with the new job path, rename builds to jobs in test

Closes #33149

See merge request !11941
parents 823b17cf f5b97e80
...@@ -25,7 +25,7 @@ class BuildDetailsEntity < JobEntity ...@@ -25,7 +25,7 @@ class BuildDetailsEntity < JobEntity
end end
expose :raw_path do |build| expose :raw_path do |build|
raw_namespace_project_build_path(project.namespace, project, build) raw_namespace_project_job_path(project.namespace, project, build)
end end
private private
......
...@@ -28,7 +28,7 @@ describe Projects::JobsController do ...@@ -28,7 +28,7 @@ describe Projects::JobsController do
get_index(scope: 'running') get_index(scope: 'running')
end end
it 'has only running builds' do it 'has only running jobs' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(assigns(:builds).first.status).to eq('running') expect(assigns(:builds).first.status).to eq('running')
end end
...@@ -41,7 +41,7 @@ describe Projects::JobsController do ...@@ -41,7 +41,7 @@ describe Projects::JobsController do
get_index(scope: 'finished') get_index(scope: 'finished')
end end
it 'has only finished builds' do it 'has only finished jobs' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(assigns(:builds).first.status).to eq('success') expect(assigns(:builds).first.status).to eq('success')
end end
...@@ -67,7 +67,7 @@ describe Projects::JobsController do ...@@ -67,7 +67,7 @@ describe Projects::JobsController do
context 'number of queries' do context 'number of queries' do
before do before do
Ci::Build::AVAILABLE_STATUSES.each do |status| Ci::Build::AVAILABLE_STATUSES.each do |status|
create_build(status, status) create_job(status, status)
end end
end end
...@@ -76,7 +76,7 @@ describe Projects::JobsController do ...@@ -76,7 +76,7 @@ describe Projects::JobsController do
expect(recorded.count).to be_within(5).of(7) expect(recorded.count).to be_within(5).of(7)
end end
def create_build(name, status) def create_job(name, status)
pipeline = create(:ci_pipeline, project: project) pipeline = create(:ci_pipeline, project: project)
create(:ci_build, :tags, :triggered, :artifacts, create(:ci_build, :tags, :triggered, :artifacts,
pipeline: pipeline, name: name, status: status) pipeline: pipeline, name: name, status: status)
...@@ -94,21 +94,21 @@ describe Projects::JobsController do ...@@ -94,21 +94,21 @@ describe Projects::JobsController do
end end
describe 'GET show' do describe 'GET show' do
let!(:build) { create(:ci_build, :failed, pipeline: pipeline) } let!(:job) { create(:ci_build, :failed, pipeline: pipeline) }
context 'when requesting HTML' do context 'when requesting HTML' do
context 'when build exists' do context 'when job exists' do
before do before do
get_show(id: build.id) get_show(id: job.id)
end end
it 'has a build' do it 'has a job' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(assigns(:build).id).to eq(build.id) expect(assigns(:build).id).to eq(job.id)
end end
end end
context 'when build does not exist' do context 'when job does not exist' do
before do before do
get_show(id: 1234) get_show(id: 1234)
end end
...@@ -128,12 +128,12 @@ describe Projects::JobsController do ...@@ -128,12 +128,12 @@ describe Projects::JobsController do
allow_any_instance_of(Ci::Build).to receive(:merge_request).and_return(merge_request) allow_any_instance_of(Ci::Build).to receive(:merge_request).and_return(merge_request)
get_show(id: build.id, format: :json) get_show(id: job.id, format: :json)
end end
it 'exposes needed information' do it 'exposes needed information' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(json_response['raw_path']).to match(/builds\/\d+\/raw\z/) expect(json_response['raw_path']).to match(/jobs\/\d+\/raw\z/)
expect(json_response.dig('merge_request', 'path')).to match(/merge_requests\/\d+\z/) expect(json_response.dig('merge_request', 'path')).to match(/merge_requests\/\d+\z/)
expect(json_response['new_issue_path']) expect(json_response['new_issue_path'])
.to include('/issues/new') .to include('/issues/new')
...@@ -155,35 +155,35 @@ describe Projects::JobsController do ...@@ -155,35 +155,35 @@ describe Projects::JobsController do
get_trace get_trace
end end
context 'when build has a trace' do context 'when job has a trace' do
let(:build) { create(:ci_build, :trace, pipeline: pipeline) } let(:job) { create(:ci_build, :trace, pipeline: pipeline) }
it 'returns a trace' do it 'returns a trace' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(json_response['id']).to eq build.id expect(json_response['id']).to eq job.id
expect(json_response['status']).to eq build.status expect(json_response['status']).to eq job.status
expect(json_response['html']).to eq('BUILD TRACE') expect(json_response['html']).to eq('BUILD TRACE')
end end
end end
context 'when build has no traces' do context 'when job has no traces' do
let(:build) { create(:ci_build, pipeline: pipeline) } let(:job) { create(:ci_build, pipeline: pipeline) }
it 'returns no traces' do it 'returns no traces' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(json_response['id']).to eq build.id expect(json_response['id']).to eq job.id
expect(json_response['status']).to eq build.status expect(json_response['status']).to eq job.status
expect(json_response['html']).to be_nil expect(json_response['html']).to be_nil
end end
end end
context 'when build has a trace with ANSI sequence and Unicode' do context 'when job has a trace with ANSI sequence and Unicode' do
let(:build) { create(:ci_build, :unicode_trace, pipeline: pipeline) } let(:job) { create(:ci_build, :unicode_trace, pipeline: pipeline) }
it 'returns a trace with Unicode' do it 'returns a trace with Unicode' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(json_response['id']).to eq build.id expect(json_response['id']).to eq job.id
expect(json_response['status']).to eq build.status expect(json_response['status']).to eq job.status
expect(json_response['html']).to include("ヾ(´༎ຶД༎ຶ`)ノ") expect(json_response['html']).to include("ヾ(´༎ຶД༎ຶ`)ノ")
end end
end end
...@@ -191,23 +191,23 @@ describe Projects::JobsController do ...@@ -191,23 +191,23 @@ describe Projects::JobsController do
def get_trace def get_trace
get :trace, namespace_id: project.namespace, get :trace, namespace_id: project.namespace,
project_id: project, project_id: project,
id: build.id, id: job.id,
format: :json format: :json
end end
end end
describe 'GET status.json' do describe 'GET status.json' do
let(:build) { create(:ci_build, pipeline: pipeline) } let(:job) { create(:ci_build, pipeline: pipeline) }
let(:status) { build.detailed_status(double('user')) } let(:status) { job.detailed_status(double('user')) }
before do before do
get :status, namespace_id: project.namespace, get :status, namespace_id: project.namespace,
project_id: project, project_id: project,
id: build.id, id: job.id,
format: :json format: :json
end end
it 'return a detailed build status in json' do it 'return a detailed job status in json' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(json_response['text']).to eq status.text expect(json_response['text']).to eq status.text
expect(json_response['label']).to eq status.label expect(json_response['label']).to eq status.label
...@@ -224,17 +224,17 @@ describe Projects::JobsController do ...@@ -224,17 +224,17 @@ describe Projects::JobsController do
post_retry post_retry
end end
context 'when build is retryable' do context 'when job is retryable' do
let(:build) { create(:ci_build, :retryable, pipeline: pipeline) } let(:job) { create(:ci_build, :retryable, pipeline: pipeline) }
it 'redirects to the retried build page' do it 'redirects to the retried job page' do
expect(response).to have_http_status(:found) expect(response).to have_http_status(:found)
expect(response).to redirect_to(namespace_project_job_path(id: Ci::Build.last.id)) expect(response).to redirect_to(namespace_project_job_path(id: Ci::Build.last.id))
end end
end end
context 'when build is not retryable' do context 'when job is not retryable' do
let(:build) { create(:ci_build, pipeline: pipeline) } let(:job) { create(:ci_build, pipeline: pipeline) }
it 'renders unprocessable_entity' do it 'renders unprocessable_entity' do
expect(response).to have_http_status(:unprocessable_entity) expect(response).to have_http_status(:unprocessable_entity)
...@@ -244,7 +244,7 @@ describe Projects::JobsController do ...@@ -244,7 +244,7 @@ describe Projects::JobsController do
def post_retry def post_retry
post :retry, namespace_id: project.namespace, post :retry, namespace_id: project.namespace,
project_id: project, project_id: project,
id: build.id id: job.id
end end
end end
...@@ -260,21 +260,21 @@ describe Projects::JobsController do ...@@ -260,21 +260,21 @@ describe Projects::JobsController do
post_play post_play
end end
context 'when build is playable' do context 'when job is playable' do
let(:build) { create(:ci_build, :playable, pipeline: pipeline) } let(:job) { create(:ci_build, :playable, pipeline: pipeline) }
it 'redirects to the played build page' do it 'redirects to the played job page' do
expect(response).to have_http_status(:found) expect(response).to have_http_status(:found)
expect(response).to redirect_to(namespace_project_job_path(id: build.id)) expect(response).to redirect_to(namespace_project_job_path(id: job.id))
end end
it 'transits to pending' do it 'transits to pending' do
expect(build.reload).to be_pending expect(job.reload).to be_pending
end end
end end
context 'when build is not playable' do context 'when job is not playable' do
let(:build) { create(:ci_build, pipeline: pipeline) } let(:job) { create(:ci_build, pipeline: pipeline) }
it 'renders unprocessable_entity' do it 'renders unprocessable_entity' do
expect(response).to have_http_status(:unprocessable_entity) expect(response).to have_http_status(:unprocessable_entity)
...@@ -284,7 +284,7 @@ describe Projects::JobsController do ...@@ -284,7 +284,7 @@ describe Projects::JobsController do
def post_play def post_play
post :play, namespace_id: project.namespace, post :play, namespace_id: project.namespace,
project_id: project, project_id: project,
id: build.id id: job.id
end end
end end
...@@ -296,21 +296,21 @@ describe Projects::JobsController do ...@@ -296,21 +296,21 @@ describe Projects::JobsController do
post_cancel post_cancel
end end
context 'when build is cancelable' do context 'when job is cancelable' do
let(:build) { create(:ci_build, :cancelable, pipeline: pipeline) } let(:job) { create(:ci_build, :cancelable, pipeline: pipeline) }
it 'redirects to the canceled build page' do it 'redirects to the canceled job page' do
expect(response).to have_http_status(:found) expect(response).to have_http_status(:found)
expect(response).to redirect_to(namespace_project_job_path(id: build.id)) expect(response).to redirect_to(namespace_project_job_path(id: job.id))
end end
it 'transits to canceled' do it 'transits to canceled' do
expect(build.reload).to be_canceled expect(job.reload).to be_canceled
end end
end end
context 'when build is not cancelable' do context 'when job is not cancelable' do
let(:build) { create(:ci_build, :canceled, pipeline: pipeline) } let(:job) { create(:ci_build, :canceled, pipeline: pipeline) }
it 'returns unprocessable_entity' do it 'returns unprocessable_entity' do
expect(response).to have_http_status(:unprocessable_entity) expect(response).to have_http_status(:unprocessable_entity)
...@@ -320,7 +320,7 @@ describe Projects::JobsController do ...@@ -320,7 +320,7 @@ describe Projects::JobsController do
def post_cancel def post_cancel
post :cancel, namespace_id: project.namespace, post :cancel, namespace_id: project.namespace,
project_id: project, project_id: project,
id: build.id id: job.id
end end
end end
...@@ -330,7 +330,7 @@ describe Projects::JobsController do ...@@ -330,7 +330,7 @@ describe Projects::JobsController do
sign_in(user) sign_in(user)
end end
context 'when builds are cancelable' do context 'when jobs are cancelable' do
before do before do
create_list(:ci_build, 2, :cancelable, pipeline: pipeline) create_list(:ci_build, 2, :cancelable, pipeline: pipeline)
...@@ -347,7 +347,7 @@ describe Projects::JobsController do ...@@ -347,7 +347,7 @@ describe Projects::JobsController do
end end
end end
context 'when builds are not cancelable' do context 'when jobs are not cancelable' do
before do before do
create_list(:ci_build, 2, :canceled, pipeline: pipeline) create_list(:ci_build, 2, :canceled, pipeline: pipeline)
...@@ -374,26 +374,26 @@ describe Projects::JobsController do ...@@ -374,26 +374,26 @@ describe Projects::JobsController do
post_erase post_erase
end end
context 'when build is erasable' do context 'when job is erasable' do
let(:build) { create(:ci_build, :erasable, :trace, pipeline: pipeline) } let(:job) { create(:ci_build, :erasable, :trace, pipeline: pipeline) }
it 'redirects to the erased build page' do it 'redirects to the erased job page' do
expect(response).to have_http_status(:found) expect(response).to have_http_status(:found)
expect(response).to redirect_to(namespace_project_job_path(id: build.id)) expect(response).to redirect_to(namespace_project_job_path(id: job.id))
end end
it 'erases artifacts' do it 'erases artifacts' do
expect(build.artifacts_file.exists?).to be_falsey expect(job.artifacts_file.exists?).to be_falsey
expect(build.artifacts_metadata.exists?).to be_falsey expect(job.artifacts_metadata.exists?).to be_falsey
end end
it 'erases trace' do it 'erases trace' do
expect(build.trace.exist?).to be_falsey expect(job.trace.exist?).to be_falsey
end end
end end
context 'when build is not erasable' do context 'when job is not erasable' do
let(:build) { create(:ci_build, :erased, pipeline: pipeline) } let(:job) { create(:ci_build, :erased, pipeline: pipeline) }
it 'returns unprocessable_entity' do it 'returns unprocessable_entity' do
expect(response).to have_http_status(:unprocessable_entity) expect(response).to have_http_status(:unprocessable_entity)
...@@ -403,7 +403,7 @@ describe Projects::JobsController do ...@@ -403,7 +403,7 @@ describe Projects::JobsController do
def post_erase def post_erase
post :erase, namespace_id: project.namespace, post :erase, namespace_id: project.namespace,
project_id: project, project_id: project,
id: build.id id: job.id
end end
end end
...@@ -412,8 +412,8 @@ describe Projects::JobsController do ...@@ -412,8 +412,8 @@ describe Projects::JobsController do
get_raw get_raw
end end
context 'when build has a trace file' do context 'when job has a trace file' do
let(:build) { create(:ci_build, :trace, pipeline: pipeline) } let(:job) { create(:ci_build, :trace, pipeline: pipeline) }
it 'send a trace file' do it 'send a trace file' do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
...@@ -422,8 +422,8 @@ describe Projects::JobsController do ...@@ -422,8 +422,8 @@ describe Projects::JobsController do
end end
end end
context 'when build does not have a trace file' do context 'when job does not have a trace file' do
let(:build) { create(:ci_build, pipeline: pipeline) } let(:job) { create(:ci_build, pipeline: pipeline) }
it 'returns not_found' do it 'returns not_found' do
expect(response).to have_http_status(:not_found) expect(response).to have_http_status(:not_found)
...@@ -433,7 +433,7 @@ describe Projects::JobsController do ...@@ -433,7 +433,7 @@ describe Projects::JobsController do
def get_raw def get_raw
post :raw, namespace_id: project.namespace, post :raw, namespace_id: project.namespace,
project_id: project, project_id: project,
id: build.id id: job.id
end end
end end
end end
...@@ -8,8 +8,8 @@ feature 'Jobs', :feature do ...@@ -8,8 +8,8 @@ feature 'Jobs', :feature do
let(:namespace) { project.namespace } let(:namespace) { project.namespace }
let(:pipeline) { create(:ci_pipeline, project: project) } let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, :trace, pipeline: pipeline) } let(:job) { create(:ci_build, :trace, pipeline: pipeline) }
let(:build2) { create(:ci_build) } let(:job2) { create(:ci_build) }
let(:artifacts_file) do let(:artifacts_file) do
fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif')
...@@ -21,7 +21,7 @@ feature 'Jobs', :feature do ...@@ -21,7 +21,7 @@ feature 'Jobs', :feature do
end end
describe "GET /:project/jobs" do describe "GET /:project/jobs" do
let!(:build) { create(:ci_build, pipeline: pipeline) } let!(:job) { create(:ci_build, pipeline: pipeline) }
context "Pending scope" do context "Pending scope" do
before do before do
...@@ -31,30 +31,30 @@ feature 'Jobs', :feature do ...@@ -31,30 +31,30 @@ feature 'Jobs', :feature do
it "shows Pending tab jobs" do it "shows Pending tab jobs" do
expect(page).to have_link 'Cancel running' expect(page).to have_link 'Cancel running'
expect(page).to have_selector('.nav-links li.active', text: 'Pending') expect(page).to have_selector('.nav-links li.active', text: 'Pending')
expect(page).to have_content build.short_sha expect(page).to have_content job.short_sha
expect(page).to have_content build.ref expect(page).to have_content job.ref
expect(page).to have_content build.name expect(page).to have_content job.name
end end
end end
context "Running scope" do context "Running scope" do
before do before do
build.run! job.run!
visit namespace_project_jobs_path(project.namespace, project, scope: :running) visit namespace_project_jobs_path(project.namespace, project, scope: :running)
end end
it "shows Running tab jobs" do it "shows Running tab jobs" do
expect(page).to have_selector('.nav-links li.active', text: 'Running') expect(page).to have_selector('.nav-links li.active', text: 'Running')
expect(page).to have_link 'Cancel running' expect(page).to have_link 'Cancel running'
expect(page).to have_content build.short_sha expect(page).to have_content job.short_sha
expect(page).to have_content build.ref expect(page).to have_content job.ref
expect(page).to have_content build.name expect(page).to have_content job.name
end end
end end
context "Finished scope" do context "Finished scope" do
before do before do
build.run! job.run!
visit namespace_project_jobs_path(project.namespace, project, scope: :finished) visit namespace_project_jobs_path(project.namespace, project, scope: :finished)
end end
...@@ -73,9 +73,9 @@ feature 'Jobs', :feature do ...@@ -73,9 +73,9 @@ feature 'Jobs', :feature do
it "shows All tab jobs" do it "shows All tab jobs" do
expect(page).to have_selector('.nav-links li.active', text: 'All') expect(page).to have_selector('.nav-links li.active', text: 'All')
expect(page).to have_content build.short_sha expect(page).to have_content job.short_sha
expect(page).to have_content build.ref expect(page).to have_content job.ref
expect(page).to have_content build.name expect(page).to have_content job.name
expect(page).not_to have_link 'Cancel running' expect(page).not_to have_link 'Cancel running'
end end
end end
...@@ -97,7 +97,7 @@ feature 'Jobs', :feature do ...@@ -97,7 +97,7 @@ feature 'Jobs', :feature do
describe "POST /:project/jobs/:id/cancel_all" do describe "POST /:project/jobs/:id/cancel_all" do
before do before do
build.run! job.run!
visit namespace_project_jobs_path(project.namespace, project) visit namespace_project_jobs_path(project.namespace, project)
click_link "Cancel running" click_link "Cancel running"
end end
...@@ -105,19 +105,19 @@ feature 'Jobs', :feature do ...@@ -105,19 +105,19 @@ feature 'Jobs', :feature do
it 'shows all necessary content' do it 'shows all necessary content' do
expect(page).to have_selector('.nav-links li.active', text: 'All') expect(page).to have_selector('.nav-links li.active', text: 'All')
expect(page).to have_content 'canceled' expect(page).to have_content 'canceled'
expect(page).to have_content build.short_sha expect(page).to have_content job.short_sha
expect(page).to have_content build.ref expect(page).to have_content job.ref
expect(page).to have_content build.name expect(page).to have_content job.name
expect(page).not_to have_link 'Cancel running' expect(page).not_to have_link 'Cancel running'
end end
end end
describe "GET /:project/jobs/:id" do describe "GET /:project/jobs/:id" do
context "Job from project" do context "Job from project" do
let(:build) { create(:ci_build, :success, pipeline: pipeline) } let(:job) { create(:ci_build, :success, pipeline: pipeline) }
before do before do
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
end end
it 'shows status name', :js do it 'shows status name', :js do
...@@ -131,33 +131,33 @@ feature 'Jobs', :feature do ...@@ -131,33 +131,33 @@ feature 'Jobs', :feature do
expect(page).to have_content pipeline.git_author_name expect(page).to have_content pipeline.git_author_name
end end
it 'shows active build' do it 'shows active job' do
expect(page).to have_selector('.build-job.active') expect(page).to have_selector('.build-job.active')
end end
end end
context 'when job is not running', :js do context 'when job is not running', :js do
let(:build) { create(:ci_build, :success, pipeline: pipeline) } let(:job) { create(:ci_build, :success, pipeline: pipeline) }
before do before do
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
end end
it 'shows retry button' do it 'shows retry button' do
expect(page).to have_link('Retry') expect(page).to have_link('Retry')
end end
context 'if build passed' do context 'if job passed' do
it 'does not show New issue button' do it 'does not show New issue button' do
expect(page).not_to have_link('New issue') expect(page).not_to have_link('New issue')
end end
end end
context 'if build failed' do context 'if job failed' do
let(:build) { create(:ci_build, :failed, pipeline: pipeline) } let(:job) { create(:ci_build, :failed, pipeline: pipeline) }
before do before do
visit namespace_project_job_path(namespace, project, build) visit namespace_project_job_path(namespace, project, job)
end end
it 'shows New issue button' do it 'shows New issue button' do
...@@ -165,9 +165,9 @@ feature 'Jobs', :feature do ...@@ -165,9 +165,9 @@ feature 'Jobs', :feature do
end end
it 'links to issues/new with the title and description filled in' do it 'links to issues/new with the title and description filled in' do
button_title = "Build Failed ##{build.id}" button_title = "Build Failed ##{job.id}"
build_path = namespace_project_job_path(namespace, project, build) job_path = namespace_project_job_path(namespace, project, job)
options = { issue: { title: button_title, description: build_path } } options = { issue: { title: button_title, description: job_path } }
href = new_namespace_project_issue_path(namespace, project, options) href = new_namespace_project_issue_path(namespace, project, options)
...@@ -180,7 +180,7 @@ feature 'Jobs', :feature do ...@@ -180,7 +180,7 @@ feature 'Jobs', :feature do
context "Job from other project" do context "Job from other project" do
before do before do
visit namespace_project_job_path(project.namespace, project, build2) visit namespace_project_job_path(project.namespace, project, job2)
end end
it { expect(page.status_code).to eq(404) } it { expect(page.status_code).to eq(404) }
...@@ -188,8 +188,8 @@ feature 'Jobs', :feature do ...@@ -188,8 +188,8 @@ feature 'Jobs', :feature do
context "Download artifacts" do context "Download artifacts" do
before do before do
build.update_attributes(artifacts_file: artifacts_file) job.update_attributes(artifacts_file: artifacts_file)
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
end end
it 'has button to download artifacts' do it 'has button to download artifacts' do
...@@ -199,10 +199,10 @@ feature 'Jobs', :feature do ...@@ -199,10 +199,10 @@ feature 'Jobs', :feature do
context 'Artifacts expire date' do context 'Artifacts expire date' do
before do before do
build.update_attributes(artifacts_file: artifacts_file, job.update_attributes(artifacts_file: artifacts_file,
artifacts_expire_at: expire_at) artifacts_expire_at: expire_at)
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
end end
context 'no expire date defined' do context 'no expire date defined' do
...@@ -248,7 +248,7 @@ feature 'Jobs', :feature do ...@@ -248,7 +248,7 @@ feature 'Jobs', :feature do
context "when visiting old URL" do context "when visiting old URL" do
let(:job_url) do let(:job_url) do
namespace_project_job_path(project.namespace, project, build) namespace_project_job_path(project.namespace, project, job)
end end
before do before do
...@@ -262,9 +262,9 @@ feature 'Jobs', :feature do ...@@ -262,9 +262,9 @@ feature 'Jobs', :feature do
feature 'Raw trace' do feature 'Raw trace' do
before do before do
build.run! job.run!
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
end end
it do it do
...@@ -274,16 +274,16 @@ feature 'Jobs', :feature do ...@@ -274,16 +274,16 @@ feature 'Jobs', :feature do
feature 'HTML trace', :js do feature 'HTML trace', :js do
before do before do
build.run! job.run!
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
end end
context 'when job has an initial trace' do context 'when job has an initial trace' do
it 'loads job trace' do it 'loads job trace' do
expect(page).to have_content 'BUILD TRACE' expect(page).to have_content 'BUILD TRACE'
build.trace.write do |stream| job.trace.write do |stream|
stream.append(' and more trace', 11) stream.append(' and more trace', 11)
end end
...@@ -295,12 +295,12 @@ feature 'Jobs', :feature do ...@@ -295,12 +295,12 @@ feature 'Jobs', :feature do
feature 'Variables' do feature 'Variables' do
let(:trigger_request) { create(:ci_trigger_request_with_variables) } let(:trigger_request) { create(:ci_trigger_request_with_variables) }
let(:build) do let(:job) do
create :ci_build, pipeline: pipeline, trigger_request: trigger_request create :ci_build, pipeline: pipeline, trigger_request: trigger_request
end end
before do before do
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
end end
it 'shows variable key and value after click', js: true do it 'shows variable key and value after click', js: true do
...@@ -322,20 +322,20 @@ feature 'Jobs', :feature do ...@@ -322,20 +322,20 @@ feature 'Jobs', :feature do
context 'job is successfull and has deployment' do context 'job is successfull and has deployment' do
let(:deployment) { create(:deployment) } let(:deployment) { create(:deployment) }
let(:build) { create(:ci_build, :success, environment: environment.name, deployments: [deployment], pipeline: pipeline) } let(:job) { create(:ci_build, :success, environment: environment.name, deployments: [deployment], pipeline: pipeline) }
it 'shows a link for the job' do it 'shows a link for the job' do
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
expect(page).to have_link environment.name expect(page).to have_link environment.name
end end
end end
context 'job is complete and not successful' do context 'job is complete and not successful' do
let(:build) { create(:ci_build, :failed, environment: environment.name, pipeline: pipeline) } let(:job) { create(:ci_build, :failed, environment: environment.name, pipeline: pipeline) }
it 'shows a link for the job' do it 'shows a link for the job' do
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
expect(page).to have_link environment.name expect(page).to have_link environment.name
end end
...@@ -343,10 +343,10 @@ feature 'Jobs', :feature do ...@@ -343,10 +343,10 @@ feature 'Jobs', :feature do
context 'job creates a new deployment' do context 'job creates a new deployment' do
let!(:deployment) { create(:deployment, environment: environment, sha: project.commit.id) } let!(:deployment) { create(:deployment, environment: environment, sha: project.commit.id) }
let(:build) { create(:ci_build, :success, environment: environment.name, pipeline: pipeline) } let(:job) { create(:ci_build, :success, environment: environment.name, pipeline: pipeline) }
it 'shows a link to latest deployment' do it 'shows a link to latest deployment' do
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
expect(page).to have_link('latest deployment') expect(page).to have_link('latest deployment')
end end
...@@ -357,8 +357,8 @@ feature 'Jobs', :feature do ...@@ -357,8 +357,8 @@ feature 'Jobs', :feature do
describe "POST /:project/jobs/:id/cancel", :js do describe "POST /:project/jobs/:id/cancel", :js do
context "Job from project" do context "Job from project" do
before do before do
build.run! job.run!
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
find('.js-cancel-job').click() find('.js-cancel-job').click()
end end
...@@ -372,8 +372,8 @@ feature 'Jobs', :feature do ...@@ -372,8 +372,8 @@ feature 'Jobs', :feature do
describe "POST /:project/jobs/:id/retry" do describe "POST /:project/jobs/:id/retry" do
context "Job from project", :js do context "Job from project", :js do
before do before do
build.run! job.run!
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
find('.js-cancel-job').click() find('.js-cancel-job').click()
find('.js-retry-button').trigger('click') find('.js-retry-button').trigger('click')
end end
...@@ -388,13 +388,13 @@ feature 'Jobs', :feature do ...@@ -388,13 +388,13 @@ feature 'Jobs', :feature do
context "Job that current user is not allowed to retry" do context "Job that current user is not allowed to retry" do
before do before do
build.run! job.run!
build.cancel! job.cancel!
project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC) project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
logout_direct logout_direct
login_with(create(:user)) login_with(create(:user))
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
end end
it 'does not show the Retry button' do it 'does not show the Retry button' do
...@@ -407,15 +407,15 @@ feature 'Jobs', :feature do ...@@ -407,15 +407,15 @@ feature 'Jobs', :feature do
describe "GET /:project/jobs/:id/download" do describe "GET /:project/jobs/:id/download" do
before do before do
build.update_attributes(artifacts_file: artifacts_file) job.update_attributes(artifacts_file: artifacts_file)
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
click_link 'Download' click_link 'Download'
end end
context "Build from other project" do context "Build from other project" do
before do before do
build2.update_attributes(artifacts_file: artifacts_file) job2.update_attributes(artifacts_file: artifacts_file)
visit download_namespace_project_job_artifacts_path(project.namespace, project, build2) visit download_namespace_project_job_artifacts_path(project.namespace, project, job2)
end end
it { expect(page.status_code).to eq(404) } it { expect(page.status_code).to eq(404) }
...@@ -427,23 +427,23 @@ feature 'Jobs', :feature do ...@@ -427,23 +427,23 @@ feature 'Jobs', :feature do
context 'job from project' do context 'job from project' do
before do before do
Capybara.current_session.driver.headers = { 'X-Sendfile-Type' => 'X-Sendfile' } Capybara.current_session.driver.headers = { 'X-Sendfile-Type' => 'X-Sendfile' }
build.run! job.run!
visit namespace_project_job_path(project.namespace, project, build) visit namespace_project_job_path(project.namespace, project, job)
find('.js-raw-link-controller').click() find('.js-raw-link-controller').click()
end end
it 'sends the right headers' do it 'sends the right headers' do
expect(page.status_code).to eq(200) expect(page.status_code).to eq(200)
expect(page.response_headers['Content-Type']).to eq('text/plain; charset=utf-8') expect(page.response_headers['Content-Type']).to eq('text/plain; charset=utf-8')
expect(page.response_headers['X-Sendfile']).to eq(build.trace.send(:current_path)) expect(page.response_headers['X-Sendfile']).to eq(job.trace.send(:current_path))
end end
end end
context 'job from other project' do context 'job from other project' do
before do before do
Capybara.current_session.driver.headers = { 'X-Sendfile-Type' => 'X-Sendfile' } Capybara.current_session.driver.headers = { 'X-Sendfile-Type' => 'X-Sendfile' }
build2.run! job2.run!
visit raw_namespace_project_job_path(project.namespace, project, build2) visit raw_namespace_project_job_path(project.namespace, project, job2)
end end
it 'sends the right headers' do it 'sends the right headers' do
...@@ -458,16 +458,16 @@ feature 'Jobs', :feature do ...@@ -458,16 +458,16 @@ feature 'Jobs', :feature do
before do before do
Capybara.current_session.driver.headers = { 'X-Sendfile-Type' => 'X-Sendfile' } Capybara.current_session.driver.headers = { 'X-Sendfile-Type' => 'X-Sendfile' }
build.run! job.run!
end end
context 'when build has trace in file', :js do context 'when job has trace in file', :js do
before do before do
allow_any_instance_of(Gitlab::Ci::Trace) allow_any_instance_of(Gitlab::Ci::Trace)
.to receive(:paths) .to receive(:paths)
.and_return([existing_file]) .and_return([existing_file])
visit namespace_project_job_path(namespace, project, build) visit namespace_project_job_path(namespace, project, job)
find('.js-raw-link-controller').click find('.js-raw-link-controller').click
end end
...@@ -485,7 +485,7 @@ feature 'Jobs', :feature do ...@@ -485,7 +485,7 @@ feature 'Jobs', :feature do
.to receive(:paths) .to receive(:paths)
.and_return([]) .and_return([])
visit namespace_project_job_path(namespace, project, build) visit namespace_project_job_path(namespace, project, job)
end end
it 'sends the right headers' do it 'sends the right headers' do
...@@ -496,7 +496,7 @@ feature 'Jobs', :feature do ...@@ -496,7 +496,7 @@ feature 'Jobs', :feature do
context "when visiting old URL" do context "when visiting old URL" do
let(:raw_job_url) do let(:raw_job_url) do
raw_namespace_project_job_path(project.namespace, project, build) raw_namespace_project_job_path(project.namespace, project, job)
end end
before do before do
...@@ -512,7 +512,7 @@ feature 'Jobs', :feature do ...@@ -512,7 +512,7 @@ feature 'Jobs', :feature do
describe "GET /:project/jobs/:id/trace.json" do describe "GET /:project/jobs/:id/trace.json" do
context "Job from project" do context "Job from project" do
before do before do
visit trace_namespace_project_job_path(project.namespace, project, build, format: :json) visit trace_namespace_project_job_path(project.namespace, project, job, format: :json)
end end
it { expect(page.status_code).to eq(200) } it { expect(page.status_code).to eq(200) }
...@@ -520,7 +520,7 @@ feature 'Jobs', :feature do ...@@ -520,7 +520,7 @@ feature 'Jobs', :feature do
context "Job from other project" do context "Job from other project" do
before do before do
visit trace_namespace_project_job_path(project.namespace, project, build2, format: :json) visit trace_namespace_project_job_path(project.namespace, project, job2, format: :json)
end end
it { expect(page.status_code).to eq(404) } it { expect(page.status_code).to eq(404) }
...@@ -530,7 +530,7 @@ feature 'Jobs', :feature do ...@@ -530,7 +530,7 @@ feature 'Jobs', :feature do
describe "GET /:project/jobs/:id/status" do describe "GET /:project/jobs/:id/status" do
context "Job from project" do context "Job from project" do
before do before do
visit status_namespace_project_job_path(project.namespace, project, build) visit status_namespace_project_job_path(project.namespace, project, job)
end end
it { expect(page.status_code).to eq(200) } it { expect(page.status_code).to eq(200) }
...@@ -538,7 +538,7 @@ feature 'Jobs', :feature do ...@@ -538,7 +538,7 @@ feature 'Jobs', :feature do
context "Job from other project" do context "Job from other project" do
before do before do
visit status_namespace_project_job_path(project.namespace, project, build2) visit status_namespace_project_job_path(project.namespace, project, job2)
end end
it { expect(page.status_code).to eq(404) } it { expect(page.status_code).to eq(404) }
......
...@@ -11,7 +11,7 @@ describe API::Jobs, :api do ...@@ -11,7 +11,7 @@ describe API::Jobs, :api do
ref: project.default_branch) ref: project.default_branch)
end end
let!(:build) { create(:ci_build, pipeline: pipeline) } let!(:job) { create(:ci_build, pipeline: pipeline) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:api_user) { user } let(:api_user) { user }
...@@ -42,13 +42,13 @@ describe API::Jobs, :api do ...@@ -42,13 +42,13 @@ describe API::Jobs, :api do
end end
it 'returns pipeline data' do it 'returns pipeline data' do
json_build = json_response.first json_job = json_response.first
expect(json_build['pipeline']).not_to be_empty expect(json_job['pipeline']).not_to be_empty
expect(json_build['pipeline']['id']).to eq build.pipeline.id expect(json_job['pipeline']['id']).to eq job.pipeline.id
expect(json_build['pipeline']['ref']).to eq build.pipeline.ref expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
expect(json_build['pipeline']['sha']).to eq build.pipeline.sha expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
expect(json_build['pipeline']['status']).to eq build.pipeline.status expect(json_job['pipeline']['status']).to eq job.pipeline.status
end end
context 'filter project with one scope element' do context 'filter project with one scope element' do
...@@ -79,7 +79,7 @@ describe API::Jobs, :api do ...@@ -79,7 +79,7 @@ describe API::Jobs, :api do
context 'unauthorized user' do context 'unauthorized user' do
let(:api_user) { nil } let(:api_user) { nil }
it 'does not return project builds' do it 'does not return project jobs' do
expect(response).to have_http_status(401) expect(response).to have_http_status(401)
end end
end end
...@@ -105,13 +105,13 @@ describe API::Jobs, :api do ...@@ -105,13 +105,13 @@ describe API::Jobs, :api do
end end
it 'returns pipeline data' do it 'returns pipeline data' do
json_build = json_response.first json_job = json_response.first
expect(json_build['pipeline']).not_to be_empty expect(json_job['pipeline']).not_to be_empty
expect(json_build['pipeline']['id']).to eq build.pipeline.id expect(json_job['pipeline']['id']).to eq job.pipeline.id
expect(json_build['pipeline']['ref']).to eq build.pipeline.ref expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
expect(json_build['pipeline']['sha']).to eq build.pipeline.sha expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
expect(json_build['pipeline']['status']).to eq build.pipeline.status expect(json_job['pipeline']['status']).to eq job.pipeline.status
end end
context 'filter jobs with one scope element' do context 'filter jobs with one scope element' do
...@@ -140,7 +140,7 @@ describe API::Jobs, :api do ...@@ -140,7 +140,7 @@ describe API::Jobs, :api do
context 'jobs in different pipelines' do context 'jobs in different pipelines' do
let!(:pipeline2) { create(:ci_empty_pipeline, project: project) } let!(:pipeline2) { create(:ci_empty_pipeline, project: project) }
let!(:build2) { create(:ci_build, pipeline: pipeline2) } let!(:job2) { create(:ci_build, pipeline: pipeline2) }
it 'excludes jobs from other pipelines' do it 'excludes jobs from other pipelines' do
json_response.each { |job| expect(job['pipeline']['id']).to eq(pipeline.id) } json_response.each { |job| expect(job['pipeline']['id']).to eq(pipeline.id) }
...@@ -159,7 +159,7 @@ describe API::Jobs, :api do ...@@ -159,7 +159,7 @@ describe API::Jobs, :api do
describe 'GET /projects/:id/jobs/:job_id' do describe 'GET /projects/:id/jobs/:job_id' do
before do before do
get api("/projects/#{project.id}/jobs/#{build.id}", api_user) get api("/projects/#{project.id}/jobs/#{job.id}", api_user)
end end
context 'authorized user' do context 'authorized user' do
...@@ -169,12 +169,13 @@ describe API::Jobs, :api do ...@@ -169,12 +169,13 @@ describe API::Jobs, :api do
end end
it 'returns pipeline data' do it 'returns pipeline data' do
json_build = json_response json_job = json_response
expect(json_build['pipeline']).not_to be_empty
expect(json_build['pipeline']['id']).to eq build.pipeline.id expect(json_job['pipeline']).not_to be_empty
expect(json_build['pipeline']['ref']).to eq build.pipeline.ref expect(json_job['pipeline']['id']).to eq job.pipeline.id
expect(json_build['pipeline']['sha']).to eq build.pipeline.sha expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
expect(json_build['pipeline']['status']).to eq build.pipeline.status expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
expect(json_job['pipeline']['status']).to eq job.pipeline.status
end end
end end
...@@ -189,11 +190,11 @@ describe API::Jobs, :api do ...@@ -189,11 +190,11 @@ describe API::Jobs, :api do
describe 'GET /projects/:id/jobs/:job_id/artifacts' do describe 'GET /projects/:id/jobs/:job_id/artifacts' do
before do before do
get api("/projects/#{project.id}/jobs/#{build.id}/artifacts", api_user) get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
end end
context 'job with artifacts' do context 'job with artifacts' do
let(:build) { create(:ci_build, :artifacts, pipeline: pipeline) } let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
context 'authorized user' do context 'authorized user' do
let(:download_headers) do let(:download_headers) do
...@@ -204,7 +205,7 @@ describe API::Jobs, :api do ...@@ -204,7 +205,7 @@ describe API::Jobs, :api do
it 'returns specific job artifacts' do it 'returns specific job artifacts' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response.headers).to include(download_headers) expect(response.headers).to include(download_headers)
expect(response.body).to match_file(build.artifacts_file.file.file) expect(response.body).to match_file(job.artifacts_file.file.file)
end end
end end
...@@ -224,14 +225,14 @@ describe API::Jobs, :api do ...@@ -224,14 +225,14 @@ describe API::Jobs, :api do
describe 'GET /projects/:id/artifacts/:ref_name/download?job=name' do describe 'GET /projects/:id/artifacts/:ref_name/download?job=name' do
let(:api_user) { reporter } let(:api_user) { reporter }
let(:build) { create(:ci_build, :artifacts, pipeline: pipeline) } let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
before do before do
build.success job.success
end end
def get_for_ref(ref = pipeline.ref, job = build.name) def get_for_ref(ref = pipeline.ref, job_name = job.name)
get api("/projects/#{project.id}/jobs/artifacts/#{ref}/download", api_user), job: job get api("/projects/#{project.id}/jobs/artifacts/#{ref}/download", api_user), job: job_name
end end
context 'when not logged in' do context 'when not logged in' do
...@@ -285,7 +286,7 @@ describe API::Jobs, :api do ...@@ -285,7 +286,7 @@ describe API::Jobs, :api do
let(:download_headers) do let(:download_headers) do
{ 'Content-Transfer-Encoding' => 'binary', { 'Content-Transfer-Encoding' => 'binary',
'Content-Disposition' => 'Content-Disposition' =>
"attachment; filename=#{build.artifacts_file.filename}" } "attachment; filename=#{job.artifacts_file.filename}" }
end end
it { expect(response).to have_http_status(200) } it { expect(response).to have_http_status(200) }
...@@ -321,16 +322,16 @@ describe API::Jobs, :api do ...@@ -321,16 +322,16 @@ describe API::Jobs, :api do
end end
describe 'GET /projects/:id/jobs/:job_id/trace' do describe 'GET /projects/:id/jobs/:job_id/trace' do
let(:build) { create(:ci_build, :trace, pipeline: pipeline) } let(:job) { create(:ci_build, :trace, pipeline: pipeline) }
before do before do
get api("/projects/#{project.id}/jobs/#{build.id}/trace", api_user) get api("/projects/#{project.id}/jobs/#{job.id}/trace", api_user)
end end
context 'authorized user' do context 'authorized user' do
it 'returns specific job trace' do it 'returns specific job trace' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response.body).to eq(build.trace.raw) expect(response.body).to eq(job.trace.raw)
end end
end end
...@@ -345,7 +346,7 @@ describe API::Jobs, :api do ...@@ -345,7 +346,7 @@ describe API::Jobs, :api do
describe 'POST /projects/:id/jobs/:job_id/cancel' do describe 'POST /projects/:id/jobs/:job_id/cancel' do
before do before do
post api("/projects/#{project.id}/jobs/#{build.id}/cancel", api_user) post api("/projects/#{project.id}/jobs/#{job.id}/cancel", api_user)
end end
context 'authorized user' do context 'authorized user' do
...@@ -375,10 +376,10 @@ describe API::Jobs, :api do ...@@ -375,10 +376,10 @@ describe API::Jobs, :api do
end end
describe 'POST /projects/:id/jobs/:job_id/retry' do describe 'POST /projects/:id/jobs/:job_id/retry' do
let(:build) { create(:ci_build, :canceled, pipeline: pipeline) } let(:job) { create(:ci_build, :canceled, pipeline: pipeline) }
before do before do
post api("/projects/#{project.id}/jobs/#{build.id}/retry", api_user) post api("/projects/#{project.id}/jobs/#{job.id}/retry", api_user)
end end
context 'authorized user' do context 'authorized user' do
...@@ -410,28 +411,29 @@ describe API::Jobs, :api do ...@@ -410,28 +411,29 @@ describe API::Jobs, :api do
describe 'POST /projects/:id/jobs/:job_id/erase' do describe 'POST /projects/:id/jobs/:job_id/erase' do
before do before do
post api("/projects/#{project.id}/jobs/#{build.id}/erase", user) post api("/projects/#{project.id}/jobs/#{job.id}/erase", user)
end end
context 'job is erasable' do context 'job is erasable' do
let(:build) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) } let(:job) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) }
it 'erases job content' do it 'erases job content' do
expect(response).to have_http_status(201) expect(response).to have_http_status(201)
expect(build).not_to have_trace expect(job).not_to have_trace
expect(build.artifacts_file.exists?).to be_falsy expect(job.artifacts_file.exists?).to be_falsy
expect(build.artifacts_metadata.exists?).to be_falsy expect(job.artifacts_metadata.exists?).to be_falsy
end end
it 'updates job' do it 'updates job' do
build.reload job.reload
expect(build.erased_at).to be_truthy
expect(build.erased_by).to eq(user) expect(job.erased_at).to be_truthy
expect(job.erased_by).to eq(user)
end end
end end
context 'job is not erasable' do context 'job is not erasable' do
let(:build) { create(:ci_build, :trace, project: project, pipeline: pipeline) } let(:job) { create(:ci_build, :trace, project: project, pipeline: pipeline) }
it 'responds with forbidden' do it 'responds with forbidden' do
expect(response).to have_http_status(403) expect(response).to have_http_status(403)
...@@ -439,25 +441,25 @@ describe API::Jobs, :api do ...@@ -439,25 +441,25 @@ describe API::Jobs, :api do
end end
end end
describe 'POST /projects/:id/jobs/:build_id/artifacts/keep' do describe 'POST /projects/:id/jobs/:job_id/artifacts/keep' do
before do before do
post api("/projects/#{project.id}/jobs/#{build.id}/artifacts/keep", user) post api("/projects/#{project.id}/jobs/#{job.id}/artifacts/keep", user)
end end
context 'artifacts did not expire' do context 'artifacts did not expire' do
let(:build) do let(:job) do
create(:ci_build, :trace, :artifacts, :success, create(:ci_build, :trace, :artifacts, :success,
project: project, pipeline: pipeline, artifacts_expire_at: Time.now + 7.days) project: project, pipeline: pipeline, artifacts_expire_at: Time.now + 7.days)
end end
it 'keeps artifacts' do it 'keeps artifacts' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(build.reload.artifacts_expire_at).to be_nil expect(job.reload.artifacts_expire_at).to be_nil
end end
end end
context 'no artifacts' do context 'no artifacts' do
let(:build) { create(:ci_build, project: project, pipeline: pipeline) } let(:job) { create(:ci_build, project: project, pipeline: pipeline) }
it 'responds with not found' do it 'responds with not found' do
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
...@@ -467,18 +469,18 @@ describe API::Jobs, :api do ...@@ -467,18 +469,18 @@ describe API::Jobs, :api do
describe 'POST /projects/:id/jobs/:job_id/play' do describe 'POST /projects/:id/jobs/:job_id/play' do
before do before do
post api("/projects/#{project.id}/jobs/#{build.id}/play", api_user) post api("/projects/#{project.id}/jobs/#{job.id}/play", api_user)
end end
context 'on an playable job' do context 'on an playable job' do
let(:build) { create(:ci_build, :manual, project: project, pipeline: pipeline) } let(:job) { create(:ci_build, :manual, project: project, pipeline: pipeline) }
context 'when user is authorized to trigger a manual action' do context 'when user is authorized to trigger a manual action' do
it 'plays the job' do it 'plays the job' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['id']).to eq(user.id)
expect(json_response['id']).to eq(build.id) expect(json_response['id']).to eq(job.id)
expect(build.reload).to be_pending expect(job.reload).to be_pending
end end
end end
...@@ -487,7 +489,7 @@ describe API::Jobs, :api do ...@@ -487,7 +489,7 @@ describe API::Jobs, :api do
let(:api_user) { create(:user) } let(:api_user) { create(:user) }
it 'does not trigger a manual action' do it 'does not trigger a manual action' do
expect(build.reload).to be_manual expect(job.reload).to be_manual
expect(response).to have_http_status(404) expect(response).to have_http_status(404)
end end
end end
...@@ -496,7 +498,7 @@ describe API::Jobs, :api do ...@@ -496,7 +498,7 @@ describe API::Jobs, :api do
let(:api_user) { reporter } let(:api_user) { reporter }
it 'does not trigger a manual action' do it 'does not trigger a manual action' do
expect(build.reload).to be_manual expect(job.reload).to be_manual
expect(response).to have_http_status(403) expect(response).to have_http_status(403)
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