Hide environment external URL button if not defined

This commit is contained in:
Grzegorz Bizon 2017-05-02 13:21:06 +02:00
parent 6068b863c6
commit 48bb892124
2 changed files with 35 additions and 2 deletions

View File

@ -16,8 +16,9 @@
.col-sm-6
.nav-controls
= link_to @environment.external_url, class: 'btn btn-default', target: '_blank', rel: 'noopener noreferrer nofollow' do
= icon('external-link')
- if @environment.external_url.present?
= link_to @environment.external_url, class: 'btn btn-default', target: '_blank', rel: 'noopener noreferrer nofollow' do
= icon('external-link')
= render 'projects/deployments/actions', deployment: @environment.last_deployment
.terminal-container{ class: container_class }

View File

@ -0,0 +1,32 @@
require 'spec_helper'
describe 'projects/environments/terminal' do
let!(:environment) { create(:environment, :with_review_app) }
before do
assign(:environment, environment)
assign(:project, environment.project)
allow(view).to receive(:can?).and_return(true)
end
context 'when environment has external URL' do
it 'shows external URL button' do
environment.update_attribute(:external_url, 'https://gitlab.com')
render
expect(rendered).to have_link(nil, href: 'https://gitlab.com')
end
end
context 'when environment does not have external URL' do
it 'shows external URL button' do
environment.update_attribute(:external_url, nil)
render
expect(rendered).not_to have_link(nil, href: 'https://gitlab.com')
end
end
end