diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-04-01 13:03:14 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-04-06 19:56:34 +0200 |
commit | b7fa7c4d59b2fbdc49db81aa2d6a2531c931a2fe (patch) | |
tree | 01b4f5e2aa9231049caa56196f09b4b8a6ebd406 /spec/lib/gitlab/badge/build_spec.rb | |
parent | 88fc7ccddaab18435bdc85021d06d9aa21d28a68 (diff) | |
download | gitlab-ce-b7fa7c4d59b2fbdc49db81aa2d6a2531c931a2fe.tar.gz |
Extend build status badge, add html/markdown methods
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) } |