diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-28 14:35:02 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-28 14:35:02 +0200 |
commit | 9ae1ecf876e40ce9dd64c72e025f32e38c882fd6 (patch) | |
tree | 8803b574cf48b2c8bc38e6fce295065d737bc730 /spec/lib/gitlab/badge/build | |
parent | 42c035ee38a6629090da07aea818f4c9e3733075 (diff) | |
download | gitlab-ce-9ae1ecf876e40ce9dd64c72e025f32e38c882fd6.tar.gz |
Extract build status badge metadata to separate class
Diffstat (limited to 'spec/lib/gitlab/badge/build')
-rw-r--r-- | spec/lib/gitlab/badge/build/metadata_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/lib/gitlab/badge/build/metadata_spec.rb b/spec/lib/gitlab/badge/build/metadata_spec.rb new file mode 100644 index 00000000000..ad5388215c2 --- /dev/null +++ b/spec/lib/gitlab/badge/build/metadata_spec.rb @@ -0,0 +1,37 @@ +require 'spec_helper' + +describe Gitlab::Badge::Build::Metadata do + let(:project) { create(:project) } + let(:branch) { 'master' } + let(:badge) { described_class.new(project, branch) } + + 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 +end |