Commit 02c6cbf5 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Add tests

parent afa5afc5
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
This build is the most recent deployment to #{environment_link_for_build(@build.project, @build)}. This build is the most recent deployment to #{environment_link_for_build(@build.project, @build)}.
- else - else
This build is an out-of-date deployment to #{environment_link_for_build(@build.project, @build)}. This build is an out-of-date deployment to #{environment_link_for_build(@build.project, @build)}.
- if environment.try(:last_deployment)
View the most recent deployment #{deployment_link(environment.last_deployment)}. View the most recent deployment #{deployment_link(environment.last_deployment)}.
- elsif @build.complete? && !@build.success? - elsif @build.complete? && !@build.success?
The deployment of this build to #{environment_link_for_build(@build.project, @build)} did not succeed. The deployment of this build to #{environment_link_for_build(@build.project, @build)} did not succeed.
......
...@@ -88,6 +88,7 @@ describe 'projects/builds/show', :view do ...@@ -88,6 +88,7 @@ describe 'projects/builds/show', :view do
create(:ci_build, :running, environment: 'staging', pipeline: pipeline) create(:ci_build, :running, environment: 'staging', pipeline: pipeline)
end end
context 'and environment does exist' do
let!(:environment) do let!(:environment) do
create(:environment, name: 'staging', project: project) create(:environment, name: 'staging', project: project)
end end
...@@ -99,6 +100,35 @@ describe 'projects/builds/show', :view do ...@@ -99,6 +100,35 @@ describe 'projects/builds/show', :view do
expect(rendered).to have_css( expect(rendered).to have_css(
'.environment-information', text: expected_text) '.environment-information', text: expected_text)
end end
context 'and has deployment' do
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
context 'and environment does not exist' do
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
end
end end
context 'build that failed to deploy and environment has not been created' do context 'build that failed to deploy and environment has not been created' do
...@@ -134,6 +164,8 @@ describe 'projects/builds/show', :view do ...@@ -134,6 +164,8 @@ describe 'projects/builds/show', :view do
expect(rendered).to have_css( expect(rendered).to have_css(
'.environment-information', text: expected_text) '.environment-information', text: expected_text)
expect(rendered).not_to have_css(
'.environment-information', text: 'latest deployment')
end end
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