Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
GitLab FOSS
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
Container Registry
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GitLab.org
GitLab FOSS
Commits
6cbe3867
Commit
6cbe3867
authored
Jun 08, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dm-blob-file-type' into 'master'
Add Blob#file_type convenience method See merge request
!11982
parents
299a3a9a
369d681e
Pipeline
#8871702
failed with stages
in 181 minutes and 42 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
1 deletion
+13
-1
app/models/blob.rb
app/models/blob.rb
+4
-0
app/models/blob_viewer/base.rb
app/models/blob_viewer/base.rb
+1
-1
spec/models/blob_spec.rb
spec/models/blob_spec.rb
+8
-0
No files found.
app/models/blob.rb
View file @
6cbe3867
...
...
@@ -155,6 +155,10 @@ class Blob < SimpleDelegator
@extension
||=
extname
.
downcase
.
delete
(
'.'
)
end
def
file_type
Gitlab
::
FileDetector
.
type_of
(
path
)
end
def
video?
UploaderHelper
::
VIDEO_EXT
.
include?
(
extension
)
end
...
...
app/models/blob_viewer/base.rb
View file @
6cbe3867
...
...
@@ -52,7 +52,7 @@ module BlobViewer
def
self
.
can_render?
(
blob
,
verify_binary:
true
)
return
false
if
verify_binary
&&
binary?
!=
blob
.
binary?
return
true
if
extensions
&
.
include?
(
blob
.
extension
)
return
true
if
file_types
&
.
include?
(
Gitlab
::
FileDetector
.
type_of
(
blob
.
path
)
)
return
true
if
file_types
&
.
include?
(
blob
.
file_type
)
false
end
...
...
spec/models/blob_spec.rb
View file @
6cbe3867
...
...
@@ -199,6 +199,14 @@ describe Blob do
end
end
describe
'#file_type'
do
it
'returns the file type'
do
blob
=
fake_blob
(
path:
'README.md'
)
expect
(
blob
.
file_type
).
to
eq
(
:readme
)
end
end
describe
'#simple_viewer'
do
context
'when the blob is empty'
do
it
'returns an empty viewer'
do
...
...
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