2015-10-06 18:36:22 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Builds" do
|
2015-10-12 21:47:32 +00:00
|
|
|
let(:artifacts_file) { fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') }
|
|
|
|
|
2015-10-06 18:36:22 +00:00
|
|
|
before do
|
|
|
|
login_as(:user)
|
|
|
|
@commit = FactoryGirl.create :ci_commit
|
|
|
|
@build = FactoryGirl.create :ci_build, commit: @commit
|
2015-12-04 11:55:23 +00:00
|
|
|
@project = @commit.project
|
2016-02-04 11:57:46 +00:00
|
|
|
@project.team << [@user, :developer]
|
2015-10-06 18:36:22 +00:00
|
|
|
end
|
|
|
|
|
2015-10-14 10:15:03 +00:00
|
|
|
describe "GET /:project/builds" do
|
2015-10-14 12:21:49 +00:00
|
|
|
context "Running scope" do
|
2015-10-14 10:15:03 +00:00
|
|
|
before do
|
2015-10-14 12:21:49 +00:00
|
|
|
@build.run!
|
2015-12-30 14:25:42 +00:00
|
|
|
visit namespace_project_builds_path(@project.namespace, @project, scope: :running)
|
2015-10-14 10:15:03 +00:00
|
|
|
end
|
|
|
|
|
2016-02-03 19:21:26 +00:00
|
|
|
it { expect(page).to have_selector('.nav-links li.active', text: 'Running') }
|
2015-12-30 14:25:42 +00:00
|
|
|
it { expect(page).to have_link 'Cancel running' }
|
2015-10-14 10:15:03 +00:00
|
|
|
it { expect(page).to have_content @build.short_sha }
|
|
|
|
it { expect(page).to have_content @build.ref }
|
|
|
|
it { expect(page).to have_content @build.name }
|
|
|
|
end
|
|
|
|
|
2015-10-14 12:21:49 +00:00
|
|
|
context "Finished scope" do
|
2015-10-14 10:15:03 +00:00
|
|
|
before do
|
2015-10-14 12:21:49 +00:00
|
|
|
@build.run!
|
2015-12-04 11:55:23 +00:00
|
|
|
visit namespace_project_builds_path(@project.namespace, @project, scope: :finished)
|
2015-10-14 10:15:03 +00:00
|
|
|
end
|
|
|
|
|
2016-02-03 19:21:26 +00:00
|
|
|
it { expect(page).to have_selector('.nav-links li.active', text: 'Finished') }
|
2015-10-14 10:15:03 +00:00
|
|
|
it { expect(page).to have_content 'No builds to show' }
|
2015-12-30 14:25:42 +00:00
|
|
|
it { expect(page).to have_link 'Cancel running' }
|
2015-10-14 10:15:03 +00:00
|
|
|
end
|
|
|
|
|
2015-10-14 12:21:49 +00:00
|
|
|
context "All builds" do
|
2015-10-14 10:15:03 +00:00
|
|
|
before do
|
2015-12-10 16:44:06 +00:00
|
|
|
@project.builds.running_or_pending.each(&:success)
|
2015-12-30 14:25:42 +00:00
|
|
|
visit namespace_project_builds_path(@project.namespace, @project)
|
2015-10-14 10:15:03 +00:00
|
|
|
end
|
|
|
|
|
2016-02-03 19:21:26 +00:00
|
|
|
it { expect(page).to have_selector('.nav-links li.active', text: 'All') }
|
2016-05-11 14:46:19 +00:00
|
|
|
it { expect(page).to have_selector('.row-content-block', text: 'All builds from this project') }
|
2015-10-14 10:15:03 +00:00
|
|
|
it { expect(page).to have_content @build.short_sha }
|
|
|
|
it { expect(page).to have_content @build.ref }
|
|
|
|
it { expect(page).to have_content @build.name }
|
2015-12-30 14:25:42 +00:00
|
|
|
it { expect(page).to_not have_link 'Cancel running' }
|
2015-10-14 10:15:03 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-03 10:44:07 +00:00
|
|
|
describe "POST /:project/builds/:id/cancel_all" do
|
2015-10-14 10:15:03 +00:00
|
|
|
before do
|
|
|
|
@build.run!
|
2015-12-04 11:55:23 +00:00
|
|
|
visit namespace_project_builds_path(@project.namespace, @project)
|
2015-12-08 13:13:03 +00:00
|
|
|
click_link "Cancel running"
|
2015-10-14 10:15:03 +00:00
|
|
|
end
|
|
|
|
|
2016-02-03 19:21:26 +00:00
|
|
|
it { expect(page).to have_selector('.nav-links li.active', text: 'All') }
|
2015-12-30 14:25:42 +00:00
|
|
|
it { expect(page).to have_content 'canceled' }
|
|
|
|
it { expect(page).to have_content @build.short_sha }
|
|
|
|
it { expect(page).to have_content @build.ref }
|
|
|
|
it { expect(page).to have_content @build.name }
|
|
|
|
it { expect(page).to_not have_link 'Cancel running' }
|
2015-10-14 10:15:03 +00:00
|
|
|
end
|
|
|
|
|
2015-10-06 18:36:22 +00:00
|
|
|
describe "GET /:project/builds/:id" do
|
|
|
|
before do
|
2015-12-04 11:55:23 +00:00
|
|
|
visit namespace_project_build_path(@project.namespace, @project, @build)
|
2015-10-06 18:36:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(page).to have_content @commit.sha[0..7] }
|
|
|
|
it { expect(page).to have_content @commit.git_commit_message }
|
|
|
|
it { expect(page).to have_content @commit.git_author_name }
|
2015-10-12 21:47:32 +00:00
|
|
|
|
|
|
|
context "Download artifacts" do
|
|
|
|
before do
|
|
|
|
@build.update_attributes(artifacts_file: artifacts_file)
|
2015-12-04 11:55:23 +00:00
|
|
|
visit namespace_project_build_path(@project.namespace, @project, @build)
|
2015-10-12 21:47:32 +00:00
|
|
|
end
|
|
|
|
|
2015-12-28 11:34:47 +00:00
|
|
|
it 'has button to download artifacts' do
|
|
|
|
page.within('.artifacts') do
|
|
|
|
expect(page).to have_content 'Download'
|
|
|
|
end
|
|
|
|
end
|
2015-10-12 21:47:32 +00:00
|
|
|
end
|
2016-04-17 16:19:23 +00:00
|
|
|
|
|
|
|
context 'Build raw trace' do
|
|
|
|
before do
|
|
|
|
@build.run!
|
|
|
|
@build.trace = 'BUILD TRACE'
|
|
|
|
visit namespace_project_build_path(@project.namespace, @project, @build)
|
|
|
|
end
|
|
|
|
|
|
|
|
it do
|
|
|
|
page.within('.build-controls') do
|
2016-04-19 11:02:41 +00:00
|
|
|
expect(page).to have_link 'Raw'
|
2016-04-17 16:19:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-10-06 18:36:22 +00:00
|
|
|
end
|
2015-10-07 13:24:32 +00:00
|
|
|
|
2015-11-03 10:44:07 +00:00
|
|
|
describe "POST /:project/builds/:id/cancel" do
|
2015-10-07 13:24:32 +00:00
|
|
|
before do
|
|
|
|
@build.run!
|
2015-12-04 11:55:23 +00:00
|
|
|
visit namespace_project_build_path(@project.namespace, @project, @build)
|
2015-11-03 10:44:07 +00:00
|
|
|
click_link "Cancel"
|
2015-10-07 13:24:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(page).to have_content 'canceled' }
|
|
|
|
it { expect(page).to have_content 'Retry' }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "POST /:project/builds/:id/retry" do
|
|
|
|
before do
|
2015-11-03 10:44:07 +00:00
|
|
|
@build.run!
|
2015-12-04 11:55:23 +00:00
|
|
|
visit namespace_project_build_path(@project.namespace, @project, @build)
|
2015-11-03 10:44:07 +00:00
|
|
|
click_link "Cancel"
|
2015-10-07 13:24:32 +00:00
|
|
|
click_link 'Retry'
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(page).to have_content 'pending' }
|
|
|
|
it { expect(page).to have_content 'Cancel' }
|
|
|
|
end
|
2015-10-12 21:47:32 +00:00
|
|
|
|
|
|
|
describe "GET /:project/builds/:id/download" do
|
|
|
|
before do
|
|
|
|
@build.update_attributes(artifacts_file: artifacts_file)
|
2015-12-04 11:55:23 +00:00
|
|
|
visit namespace_project_build_path(@project.namespace, @project, @build)
|
2015-12-28 11:34:47 +00:00
|
|
|
page.within('.artifacts') { click_link 'Download' }
|
2015-10-12 21:47:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(page.response_headers['Content-Type']).to eq(artifacts_file.content_type) }
|
|
|
|
end
|
2016-04-17 16:19:23 +00:00
|
|
|
|
|
|
|
describe "GET /:project/builds/:id/raw" do
|
|
|
|
before do
|
2016-04-19 11:02:41 +00:00
|
|
|
Capybara.current_session.driver.header('X-Sendfile-Type', 'X-Sendfile')
|
2016-04-17 16:19:23 +00:00
|
|
|
@build.run!
|
|
|
|
@build.trace = 'BUILD TRACE'
|
|
|
|
visit namespace_project_build_path(@project.namespace, @project, @build)
|
|
|
|
end
|
|
|
|
|
2016-04-19 11:02:41 +00:00
|
|
|
it 'sends the right headers' do
|
|
|
|
page.within('.build-controls') { click_link 'Raw' }
|
|
|
|
|
|
|
|
expect(page.response_headers['Content-Type']).to eq('text/plain; charset=utf-8')
|
|
|
|
expect(page.response_headers['X-Sendfile']).to eq(@build.path_to_trace)
|
|
|
|
end
|
2016-04-17 16:19:23 +00:00
|
|
|
end
|
2015-10-06 18:36:22 +00:00
|
|
|
end
|