Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
c559ddbdfe63
Commit
d1bce8ea
authored
May 17, 2017
by
Douwe Maan
Committed by
Rémy Coutable
May 17, 2017
Browse files
Add auxiliary blob viewer for CHANGELOG
parent
e08334000f32
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/models/blob.rb
View file @
c559ddbd
...
...
@@ -41,7 +41,8 @@ class Blob < SimpleDelegator
BlobViewer
::
RouteMap
,
BlobViewer
::
License
,
BlobViewer
::
Contributing
BlobViewer
::
Contributing
,
BlobViewer
::
Changelog
].
freeze
attr_reader
:project
...
...
app/models/blob_viewer/base.rb
View file @
c559ddbd
...
...
@@ -11,6 +11,8 @@ class Base
attr_reader
:blob
attr_accessor
:override_max_size
delegate
:project
,
to: :blob
def
initialize
(
blob
)
@blob
=
blob
end
...
...
app/models/blob_viewer/changelog.rb
0 → 100644
View file @
c559ddbd
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
app/models/blob_viewer/license.rb
View file @
c559ddbd
...
...
@@ -8,7 +8,7 @@ class License < Base
self
.
binary
=
false
def
license
blob
.
project
.
repository
.
license
project
.
repository
.
license
end
def
render_error
...
...
app/views/projects/blob/viewers/_changelog.html.haml
0 → 100644
View file @
c559ddbd
=
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
)
spec/models/blob_viewer/changelog_spec.rb
0 → 100644
View file @
c559ddbd
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment