Commit d1bce8ea authored by Douwe Maan's avatar Douwe Maan Committed by Rémy Coutable
Browse files

Add auxiliary blob viewer for CHANGELOG

parent e08334000f32
......@@ -41,7 +41,8 @@ class Blob < SimpleDelegator
BlobViewer::RouteMap,
BlobViewer::License,
BlobViewer::Contributing
BlobViewer::Contributing,
BlobViewer::Changelog
].freeze
attr_reader :project
......
......@@ -11,6 +11,8 @@ class Base
attr_reader :blob
attr_accessor :override_max_size
delegate :project, to: :blob
def initialize(blob)
@blob = blob
end
......
module BlobViewer
class Changelog < Base
include Auxiliary
include Static
self.partial_name = 'changelog'
self.file_types = %i(changelog)
self.binary = false
def render_error
return if project.repository.tag_count > 0
:no_tags
end
end
end
......@@ -8,7 +8,7 @@ class License < Base
self.binary = false
def license
blob.project.repository.license
project.repository.license
end
def render_error
......
= icon('history fw')
= succeed '.' do
To find the state of this project's repository at the time of any of these versions, check out
= link_to "the tags", namespace_project_tags_path(viewer.project.namespace, viewer.project)
require 'spec_helper'
describe BlobViewer::Changelog, model: true do
include FakeBlobHelpers
let(:project) { create(:project, :repository) }
let(:blob) { fake_blob(path: 'CHANGELOG') }
subject { described_class.new(blob) }
describe '#render_error' do
context 'when there are no tags' do
before do
allow(project.repository).to receive(:tag_count).and_return(0)
end
it 'returns :no_tags' do
expect(subject.render_error).to eq(:no_tags)
end
end
context 'when there are tags' do
it 'returns nil' do
expect(subject.render_error).to be_nil
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment