diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2016-04-11 16:45:58 -0500 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-04-11 16:45:58 -0500 |
commit | 44727525952f22c2234d2991e20f4f4f8bac3221 (patch) | |
tree | c34babda3b6b6014f8a05870922fe8f4855983cf /spec/lib/gitlab/badge/build_spec.rb | |
parent | 38a4f5cec6ab85525ab9db1d7d2669a77171f768 (diff) | |
parent | 7998725e3c2557c04ceece028dd73a316a3a746c (diff) | |
download | gitlab-ce-44727525952f22c2234d2991e20f4f4f8bac3221.tar.gz |
Merge branch 'master' into issue_14206issue_14206
Diffstat (limited to 'spec/lib/gitlab/badge/build_spec.rb')
-rw-r--r-- | spec/lib/gitlab/badge/build_spec.rb | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/spec/lib/gitlab/badge/build_spec.rb b/spec/lib/gitlab/badge/build_spec.rb index b78c2b6224f..329792bb685 100644 --- a/spec/lib/gitlab/badge/build_spec.rb +++ b/spec/lib/gitlab/badge/build_spec.rb @@ -3,13 +3,44 @@ require 'spec_helper' describe Gitlab::Badge::Build do let(:project) { create(:project) } let(:sha) { project.commit.sha } - let(:badge) { described_class.new(project, 'master') } + let(:branch) { 'master' } + let(:badge) { described_class.new(project, branch) } describe '#type' do subject { badge.type } it { is_expected.to eq 'image/svg+xml' } end + describe '#to_html' do + let(:html) { Nokogiri::HTML.parse(badge.to_html) } + let(:a_href) { html.at('a') } + + it 'points to link' do + expect(a_href[:href]).to eq badge.link_url + end + + it 'contains clickable image' do + expect(a_href.children.first.name).to eq 'img' + end + end + + describe '#to_markdown' do + subject { badge.to_markdown } + + it { is_expected.to include badge.image_url } + it { is_expected.to include badge.link_url } + end + + describe '#image_url' do + subject { badge.image_url } + it { is_expected.to include "badges/#{branch}/build.svg" } + end + + describe '#link_url' do + subject { badge.link_url } + it { is_expected.to include "commits/#{branch}" } + end + context 'build exists' do let(:ci_commit) { create(:ci_commit, project: project, sha: sha) } let!(:build) { create(:ci_build, commit: ci_commit) } |