Commit 1a5a3be8 authored by Annabel Dunstone Gray's avatar Annabel Dunstone Gray

First pass at tests

parent c70acb57
......@@ -29,7 +29,10 @@
- if @build.deployable?
.prepend-top-default
.environment-information
= ci_icon_for_status(@build.status)
- if @build.status == 'success' && (!@build.last_deployment.try(:last?))
= ci_icon_for_status('success_with_warnings')
- else
= ci_icon_for_status(@build.status)
- last_deployment = @build.last_deployment
- if @build.complete?
......@@ -38,18 +41,16 @@
This build is the most recent deployment to
= environment_link_for_build(@build.project, @build)
- else
This build is an out-of-date deployment to
= environment_link_for_build(@build.project, @build)
View the most recent deployment
= deployment_link(@project, last_deployment)
This build is an out-of-date deployment to #{environment_link_for_build(@build.project, @build)}. View the most recent deployment #{deployment_link(@project, last_deployment)}.
- else
The deployment of this build to
= environment_link_for_build(@build.project, @build)
did not complete
did not complete.
- else
This build is creating a deployment to
= environment_link_for_build(@build.project, @build)
and will overwrite the latest deployment
and will overwrite the
= link_to "latest deployment.", deployment_link(@project, last_deployment)
.prepend-top-default
- if @build.erased?
......
......@@ -17,6 +17,56 @@ describe 'projects/builds/show' do
allow(view).to receive(:can?).and_return(true)
end
describe 'environment info in build view' do
context 'build with latest deployment' do
let(:build) { create(:ci_build, :success, environment: 'staging') }
let(:environment) { create(:environment, name: 'staging') }
let!(:deployment) { create(:deployment, deployable: build) }
it 'shows deployment message' do
expect(rendered).to have_css('.environment-information', text: 'This build is the most recent deployment')
end
end
context 'build with outdated deployment' do
let(:build) { create(:ci_build, :success, environment: 'staging', pipeline: pipeline) }
let(:environment) { create(:environment, name: 'staging', project: project) }
let!(:deployment) { create(:deployment, environment: environment, deployable: build) }
let!(:newer_deployment) { create(:deployment, environment: environment, deployable: build) }
before do
assign(:build, build)
assign(:project, project)
allow(view).to receive(:can?).and_return(true)
render
end
it 'shows deployment message' do
expect(rendered).to have_css('.environment-information', text: "This build is an out-of-date deployment to #{environment.name}. View the most recent deployment #1")
end
end
context 'build failed to deploy' do
let(:build) { create(:ci_build, :failed, environment: 'staging') }
let!(:environment) { create(:environment, name: 'staging') }
end
context 'build will deploy' do
let(:build) { create(:ci_build, :running, environment: 'staging') }
let!(:environment) { create(:environment, name: 'staging') }
end
context 'build that failed to deploy and environment has not been created' do
let(:build) { create(:ci_build, :failed, environment: 'staging') }
end
context 'build that will deploy and environment has not been created' do
let(:build) { create(:ci_build, :running, environment: 'staging') }
let!(:environment) { create(:environment, name: 'staging') }
end
end
context 'when build is running' do
before do
build.run!
......
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