diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-02 13:21:06 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-02 13:21:06 +0200 |
commit | 48bb8921240387ce7d8f9401c98e13a9b3d0100f (patch) | |
tree | 92b421a137b3d4b321ec171c790b995273525cb6 | |
parent | 6068b863c66f785bea0a56881d60e8c23da08a0b (diff) | |
download | gitlab-ce-48bb8921240387ce7d8f9401c98e13a9b3d0100f.tar.gz |
Hide environment external URL button if not defined
-rw-r--r-- | app/views/projects/environments/terminal.html.haml | 5 | ||||
-rw-r--r-- | spec/views/projects/environments/terminal.html.haml_spec.rb | 32 |
2 files changed, 35 insertions, 2 deletions
diff --git a/app/views/projects/environments/terminal.html.haml b/app/views/projects/environments/terminal.html.haml index c8363087d6a..4c4aa0baff3 100644 --- a/app/views/projects/environments/terminal.html.haml +++ b/app/views/projects/environments/terminal.html.haml @@ -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 } diff --git a/spec/views/projects/environments/terminal.html.haml_spec.rb b/spec/views/projects/environments/terminal.html.haml_spec.rb new file mode 100644 index 00000000000..d2e47225226 --- /dev/null +++ b/spec/views/projects/environments/terminal.html.haml_spec.rb @@ -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 |