Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/projects/builds/show.html.haml3
-rw-r--r--spec/views/projects/builds/show.html.haml_spec.rb52
2 files changed, 43 insertions, 12 deletions
diff --git a/app/views/projects/builds/show.html.haml b/app/views/projects/builds/show.html.haml
index b40d193eb39..108674dbba6 100644
--- a/app/views/projects/builds/show.html.haml
+++ b/app/views/projects/builds/show.html.haml
@@ -40,8 +40,7 @@
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)}.
- - 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?
The deployment of this build to #{environment_link_for_build(@build.project, @build)} did not succeed.
- else
diff --git a/spec/views/projects/builds/show.html.haml_spec.rb b/spec/views/projects/builds/show.html.haml_spec.rb
index e0c77201116..869dcb417e6 100644
--- a/spec/views/projects/builds/show.html.haml_spec.rb
+++ b/spec/views/projects/builds/show.html.haml_spec.rb
@@ -88,16 +88,46 @@ describe 'projects/builds/show', :view 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)
+ context 'and environment does exist' do
+ 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
+
+ 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
@@ -134,6 +164,8 @@ describe 'projects/builds/show', :view do
expect(rendered).to have_css(
'.environment-information', text: expected_text)
+ expect(rendered).not_to have_css(
+ '.environment-information', text: 'latest deployment')
end
end
end