Skip to content
Snippets Groups Projects
Commit d1bce8ea authored by Douwe Maan's avatar Douwe Maan Committed by Rémy Coutable
Browse files

Add auxiliary blob viewer for CHANGELOG

parent 17e79998
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -41,7 +41,8 @@ class Blob < SimpleDelegator
BlobViewer::RouteMap,
 
BlobViewer::License,
BlobViewer::Contributing
BlobViewer::Contributing,
BlobViewer::Changelog
].freeze
 
attr_reader :project
Loading
Loading
Loading
Loading
@@ -11,6 +11,8 @@ module BlobViewer
attr_reader :blob
attr_accessor :override_max_size
 
delegate :project, to: :blob
def initialize(blob)
@blob = blob
end
Loading
Loading
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
Loading
Loading
@@ -8,7 +8,7 @@ module BlobViewer
self.binary = false
 
def license
blob.project.repository.license
project.repository.license
end
 
def render_error
Loading
Loading
= 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment