Commit d4d9b731 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'dm-changelog-viewer' into 'master'

Add auxiliary blob viewer for CHANGELOG

See merge request !11365
parents 17e79998 d1bce8ea
...@@ -41,7 +41,8 @@ class Blob < SimpleDelegator ...@@ -41,7 +41,8 @@ class Blob < SimpleDelegator
BlobViewer::RouteMap, BlobViewer::RouteMap,
BlobViewer::License, BlobViewer::License,
BlobViewer::Contributing BlobViewer::Contributing,
BlobViewer::Changelog
].freeze ].freeze
attr_reader :project attr_reader :project
......
...@@ -11,6 +11,8 @@ module BlobViewer ...@@ -11,6 +11,8 @@ module BlobViewer
attr_reader :blob attr_reader :blob
attr_accessor :override_max_size attr_accessor :override_max_size
delegate :project, to: :blob
def initialize(blob) def initialize(blob)
@blob = blob @blob = blob
end 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 @@ module BlobViewer ...@@ -8,7 +8,7 @@ module BlobViewer
self.binary = false self.binary = false
def license def license
blob.project.repository.license project.repository.license
end end
def render_error 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