2016-06-28 12:05:32 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-11-09 18:40:25 +00:00
|
|
|
describe 'projects/builds/show', :view do
|
2016-07-14 12:51:10 +00:00
|
|
|
let(:project) { create(:project) }
|
2016-11-09 18:40:25 +00:00
|
|
|
let(:build) { create(:ci_build, pipeline: pipeline) }
|
|
|
|
|
2016-07-18 08:40:33 +00:00
|
|
|
let(:pipeline) do
|
2016-11-09 18:40:25 +00:00
|
|
|
create(:ci_pipeline, project: project, sha: project.commit.id)
|
2016-07-18 08:40:33 +00:00
|
|
|
end
|
2016-06-28 12:05:32 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:build, build)
|
|
|
|
assign(:project, project)
|
|
|
|
|
|
|
|
allow(view).to receive(:can?).and_return(true)
|
|
|
|
end
|
|
|
|
|
2017-01-25 11:30:08 +00:00
|
|
|
describe 'build information in header' do
|
|
|
|
let(:build) do
|
|
|
|
create(:ci_build, :success, environment: 'staging')
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows status name' do
|
|
|
|
expect(rendered).to have_css('.ci-status.ci-success', text: 'passed')
|
|
|
|
end
|
|
|
|
|
2017-01-26 20:03:45 +00:00
|
|
|
it 'does not render a link to the build' do
|
|
|
|
expect(rendered).not_to have_link('passed')
|
|
|
|
end
|
|
|
|
|
2017-01-25 11:30:08 +00:00
|
|
|
it 'shows build id' do
|
|
|
|
expect(rendered).to have_css('.js-build-id', text: build.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a link to the pipeline' do
|
|
|
|
expect(rendered).to have_link(build.pipeline.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows a link to the commit' do
|
|
|
|
expect(rendered).to have_link(build.pipeline.short_sha)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-08 22:29:55 +00:00
|
|
|
describe 'environment info in build view' do
|
|
|
|
context 'build with latest deployment' do
|
2016-11-09 18:40:25 +00:00
|
|
|
let(:build) do
|
|
|
|
create(:ci_build, :success, environment: 'staging')
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
create(:environment, name: 'staging')
|
|
|
|
create(:deployment, deployable: build)
|
|
|
|
end
|
2016-11-08 22:29:55 +00:00
|
|
|
|
|
|
|
it 'shows deployment message' do
|
2016-11-09 18:40:25 +00:00
|
|
|
expected_text = 'This build is the most recent deployment'
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_css(
|
|
|
|
'.environment-information', text: expected_text)
|
2016-11-08 22:29:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'build with outdated deployment' do
|
2016-11-09 18:40:25 +00:00
|
|
|
let(:build) do
|
|
|
|
create(:ci_build, :success, environment: 'staging', pipeline: pipeline)
|
|
|
|
end
|
2016-11-08 22:29:55 +00:00
|
|
|
|
2016-11-17 19:33:53 +00:00
|
|
|
let(:second_build) do
|
|
|
|
create(:ci_build, :success, environment: 'staging', pipeline: pipeline)
|
|
|
|
end
|
|
|
|
|
2016-11-09 18:40:25 +00:00
|
|
|
let(:environment) do
|
|
|
|
create(:environment, name: 'staging', project: project)
|
|
|
|
end
|
2016-11-08 22:29:55 +00:00
|
|
|
|
2016-11-09 18:40:25 +00:00
|
|
|
let!(:first_deployment) do
|
|
|
|
create(:deployment, environment: environment, deployable: build)
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:second_deployment) do
|
2016-11-17 19:33:53 +00:00
|
|
|
create(:deployment, environment: environment, deployable: second_build)
|
2016-11-08 22:29:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows deployment message' do
|
2016-11-09 18:40:25 +00:00
|
|
|
expected_text = 'This build is an out-of-date deployment ' \
|
2016-11-17 19:33:53 +00:00
|
|
|
"to staging.\nView the most recent deployment ##{second_deployment.iid}."
|
2016-11-09 18:40:25 +00:00
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_css('.environment-information', text: expected_text)
|
2016-11-08 22:29:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'build failed to deploy' do
|
2016-11-09 21:30:58 +00:00
|
|
|
let(:build) do
|
|
|
|
create(:ci_build, :failed, environment: 'staging', pipeline: pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:environment) do
|
|
|
|
create(:environment, name: 'staging', project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows deployment message' do
|
2016-11-17 19:33:53 +00:00
|
|
|
expected_text = 'The deployment of this build to staging did not succeed.'
|
2016-11-09 21:30:58 +00:00
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_css(
|
|
|
|
'.environment-information', text: expected_text)
|
|
|
|
end
|
2016-11-08 22:29:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'build will deploy' do
|
2016-11-09 21:30:58 +00:00
|
|
|
let(:build) do
|
|
|
|
create(:ci_build, :running, environment: 'staging', pipeline: pipeline)
|
|
|
|
end
|
|
|
|
|
2016-11-23 13:37:42 +00:00
|
|
|
context 'when environment exists' do
|
2016-11-23 13:18:06 +00:00
|
|
|
let!(:environment) do
|
|
|
|
create(:environment, name: 'staging', project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows deployment message' do
|
|
|
|
expected_text = 'This build is creating a deployment to staging'
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_css(
|
|
|
|
'.environment-information', text: expected_text)
|
|
|
|
end
|
|
|
|
|
2016-11-23 13:37:42 +00:00
|
|
|
context 'when it has deployment' do
|
2016-11-23 13:18:06 +00:00
|
|
|
let!(:deployment) do
|
|
|
|
create(:deployment, environment: environment)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows that deployment will be overwritten' do
|
|
|
|
expected_text = 'This build is creating a deployment to staging'
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_css(
|
|
|
|
'.environment-information', text: expected_text)
|
|
|
|
expect(rendered).to have_css(
|
|
|
|
'.environment-information', text: 'latest deployment')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-23 13:37:42 +00:00
|
|
|
context 'when environment does not exist' do
|
2016-11-23 13:18:06 +00:00
|
|
|
it 'shows deployment message' do
|
|
|
|
expected_text = 'This build is creating a deployment to staging'
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_css(
|
|
|
|
'.environment-information', text: expected_text)
|
|
|
|
expect(rendered).not_to have_css(
|
|
|
|
'.environment-information', text: 'latest deployment')
|
|
|
|
end
|
2016-11-09 21:30:58 +00:00
|
|
|
end
|
2016-11-08 22:29:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'build that failed to deploy and environment has not been created' do
|
2016-11-09 21:30:58 +00:00
|
|
|
let(:build) do
|
|
|
|
create(:ci_build, :failed, environment: 'staging', pipeline: pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:environment) do
|
|
|
|
create(:environment, name: 'staging', project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows deployment message' do
|
2016-11-17 19:33:53 +00:00
|
|
|
expected_text = 'The deployment of this build to staging did not succeed'
|
2016-11-09 21:30:58 +00:00
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_css(
|
|
|
|
'.environment-information', text: expected_text)
|
|
|
|
end
|
2016-11-08 22:29:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'build that will deploy and environment has not been created' do
|
2016-11-09 21:30:58 +00:00
|
|
|
let(:build) do
|
|
|
|
create(:ci_build, :running, environment: 'staging', pipeline: pipeline)
|
|
|
|
end
|
|
|
|
|
|
|
|
let!(:environment) do
|
|
|
|
create(:environment, name: 'staging', project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows deployment message' do
|
|
|
|
expected_text = 'This build is creating a deployment to staging'
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_css(
|
|
|
|
'.environment-information', text: expected_text)
|
2016-11-23 13:18:06 +00:00
|
|
|
expect(rendered).not_to have_css(
|
|
|
|
'.environment-information', text: 'latest deployment')
|
2016-11-09 21:30:58 +00:00
|
|
|
end
|
2016-11-08 22:29:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-28 12:05:32 +00:00
|
|
|
context 'when build is running' do
|
|
|
|
before do
|
|
|
|
build.run!
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show retry button' do
|
|
|
|
expect(rendered).not_to have_link('Retry')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when build is not running' do
|
|
|
|
before do
|
|
|
|
build.success!
|
|
|
|
render
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows retry button' do
|
|
|
|
expect(rendered).to have_link('Retry')
|
|
|
|
end
|
2016-07-14 12:51:10 +00:00
|
|
|
end
|
2016-07-11 07:11:20 +00:00
|
|
|
|
2016-07-18 08:40:33 +00:00
|
|
|
describe 'commit title in sidebar' do
|
|
|
|
let(:commit_title) { project.commit.title }
|
|
|
|
|
|
|
|
it 'shows commit title and not show commit message' do
|
|
|
|
render
|
2016-07-21 09:23:21 +00:00
|
|
|
|
2016-07-18 08:40:33 +00:00
|
|
|
expect(rendered).to have_css('p.build-light-text.append-bottom-0',
|
|
|
|
text: /\A\n#{Regexp.escape(commit_title)}\n\Z/)
|
|
|
|
end
|
2016-07-14 12:51:10 +00:00
|
|
|
end
|
2016-07-21 09:23:21 +00:00
|
|
|
|
|
|
|
describe 'shows trigger variables in sidebar' do
|
2016-07-21 11:50:01 +00:00
|
|
|
let(:trigger_request) { create(:ci_trigger_request_with_variables, pipeline: pipeline) }
|
2016-07-21 09:23:21 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
build.trigger_request = trigger_request
|
2016-07-21 11:50:01 +00:00
|
|
|
render
|
2016-07-21 09:23:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows trigger variables in separate lines' do
|
2016-08-30 15:37:49 +00:00
|
|
|
expect(rendered).to have_css('.js-build-variable', visible: false, text: 'TRIGGER_KEY_1')
|
|
|
|
expect(rendered).to have_css('.js-build-variable', visible: false, text: 'TRIGGER_KEY_2')
|
|
|
|
expect(rendered).to have_css('.js-build-value', visible: false, text: 'TRIGGER_VALUE_1')
|
|
|
|
expect(rendered).to have_css('.js-build-value', visible: false, text: 'TRIGGER_VALUE_2')
|
2016-07-21 09:23:21 +00:00
|
|
|
end
|
|
|
|
end
|
2016-06-28 12:05:32 +00:00
|
|
|
end
|