summaryrefslogtreecommitdiff
path: root/spec/helpers/commits_helper_spec.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-01-29 22:01:31 -0600
committerDouwe Maan <douwe@selenight.nl>2017-02-06 16:12:24 -0600
commit3aa1264dc6c0de3625bb1a2d6a0ee90140a2f519 (patch)
tree73b450be24d8ea336adedca5dc2ed2edd02474c6 /spec/helpers/commits_helper_spec.rb
parent8f85a11d9fcc1f4ccde7c46652f0be00edf46a78 (diff)
downloadgitlab-ce-3aa1264dc6c0de3625bb1a2d6a0ee90140a2f519.tar.gz
Add tests
Diffstat (limited to 'spec/helpers/commits_helper_spec.rb')
-rw-r--r--spec/helpers/commits_helper_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/helpers/commits_helper_spec.rb b/spec/helpers/commits_helper_spec.rb
index 727c25ff529..85c663030d8 100644
--- a/spec/helpers/commits_helper_spec.rb
+++ b/spec/helpers/commits_helper_spec.rb
@@ -26,4 +26,23 @@ describe CommitsHelper do
not_to include('onmouseover="alert(1)"')
end
end
+
+ describe '#view_on_environment_btn' do
+ let(:project) { create(:empty_project) }
+ let(:environment) { create(:environment, external_url: 'http://example.com') }
+ let(:path) { 'source/file.html' }
+ let(:sha) { RepoHelpers.sample_commit.id }
+
+ before do
+ allow(environment).to receive(:external_url_for).with(path, sha).and_return('http://example.com/file.html')
+ end
+
+ it 'returns a link tag linking to the file in the environment' do
+ html = helper.view_on_environment_btn(sha, path, environment)
+ node = Nokogiri::HTML.parse(html).at_css('a')
+
+ expect(node[:title]).to eq('View on example.com')
+ expect(node[:href]).to eq('http://example.com/file.html')
+ end
+ end
end