Commit 4eb53036 authored by Filipa Lacerda's avatar Filipa Lacerda

Changes after review

parent 2dc907bc
......@@ -14,14 +14,12 @@ module EnvironmentHelper
end
end
def deployment_link(deployment, text)
def deployment_link(deployment, text: nil)
return unless deployment
if text
link_to text, [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable]
else
link_to "##{deployment.iid}", [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable]
end
link_label = text ? text : "##{deployment.iid}"
link_to link_label, [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable]
end
def last_deployment_link_for_environment_build(project, build)
......
......@@ -46,7 +46,7 @@
- else
This build is creating a deployment to #{environment_link_for_build(@build.project, @build)}
- if environment.try(:last_deployment)
and will overwrite the #{deployment_link(environment.last_deployment, 'latest deployment')}
and will overwrite the #{deployment_link(environment.last_deployment, text: 'latest deployment')}
.prepend-top-default
- if @build.erased?
......
......@@ -229,39 +229,36 @@ feature 'Builds', :feature do
end
context 'when build starts environment' do
let(:environment) { create(:environment, project: project) }
let(:pipeline) { create(:ci_pipeline, project: project) }
context 'build is successfull and has deployment' do
it 'shows a link for the build' do
environment = create(:environment, project: project)
pipeline = create(:ci_pipeline, project: project)
deployment = create(:deployment)
build1 = create(:ci_build, :success, environment: environment.name, deployments: [deployment], pipeline: pipeline)
let(:deployment) { create(:deployment) }
let(:build) { create(:ci_build, :success, environment: environment.name, deployments: [deployment], pipeline: pipeline) }
visit namespace_project_build_path(project.namespace, project, build1)
it 'shows a link for the build' do
visit namespace_project_build_path(project.namespace, project, build)
expect(page).to have_link environment.name
end
end
context 'build is complete and not successfull' do
it 'shows a link for the build' do
environment = create(:environment, project: project)
pipeline = create(:ci_pipeline, project: project)
build1 = create(:ci_build, :failed, environment: environment.name, pipeline: pipeline)
let(:build) { create(:ci_build, :failed, environment: environment.name, pipeline: pipeline) }
visit namespace_project_build_path(project.namespace, project, build1)
it 'shows a link for the build' do
visit namespace_project_build_path(project.namespace, project, build)
expect(page).to have_link environment.name
end
end
context 'build creates a new deployment' do
it 'shows a link to lastest deployment' do
environment = create(:environment, project: project)
create(:deployment, environment: environment, sha: project.commit.id)
pipeline = create(:ci_pipeline, project: project)
build1 = create(:ci_build, :success, environment: environment.name, pipeline: pipeline)
let!(:deployment) { create(:deployment, environment: environment, sha: project.commit.id) }
let(:build) { create(:ci_build, :success, environment: environment.name, pipeline: pipeline) }
visit namespace_project_build_path(project.namespace, project, build1)
it 'shows a link to lastest deployment' do
visit namespace_project_build_path(project.namespace, project, build)
expect(page).to have_link('latest deployment')
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