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

Changes after review

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