Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
58f1cb7e
Commit
58f1cb7e
authored
Jul 14, 2021
by
Jacques Erasmus
Committed by
jerasmus
Jul 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to view blobs accross forks
Added ref support to blin info query
parent
f6995ca5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
4 deletions
+51
-4
app/assets/javascripts/repository/components/blob_content_viewer.vue
...javascripts/repository/components/blob_content_viewer.vue
+8
-0
app/assets/javascripts/repository/queries/blob_info.query.graphql
...ts/javascripts/repository/queries/blob_info.query.graphql
+2
-2
spec/frontend/repository/components/blob_content_viewer_spec.js
...rontend/repository/components/blob_content_viewer_spec.js
+41
-2
No files found.
app/assets/javascripts/repository/components/blob_content_viewer.vue
View file @
58f1cb7e
...
...
@@ -8,6 +8,7 @@ import createFlash from '~/flash';
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
isLoggedIn
}
from
'
~/lib/utils/common_utils
'
;
import
{
__
}
from
'
~/locale
'
;
import
getRefMixin
from
'
../mixins/get_ref
'
;
import
blobInfoQuery
from
'
../queries/blob_info.query.graphql
'
;
import
BlobButtonGroup
from
'
./blob_button_group.vue
'
;
import
BlobEdit
from
'
./blob_edit.vue
'
;
...
...
@@ -21,6 +22,12 @@ export default {
BlobContent
,
GlLoadingIcon
,
},
mixins
:
[
getRefMixin
],
inject
:
{
originalBranch
:
{
default
:
''
,
},
},
apollo
:
{
project
:
{
query
:
blobInfoQuery
,
...
...
@@ -28,6 +35,7 @@ export default {
return
{
projectPath
:
this
.
projectPath
,
filePath
:
this
.
path
,
ref
:
this
.
originalBranch
||
this
.
ref
,
};
},
result
()
{
...
...
app/assets/javascripts/repository/queries/blob_info.query.graphql
View file @
58f1cb7e
query
getBlobInfo
(
$projectPath
:
ID
!,
$filePath
:
String
!)
{
query
getBlobInfo
(
$projectPath
:
ID
!,
$filePath
:
String
!
,
$ref
:
String
!
)
{
project
(
fullPath
:
$projectPath
)
{
userPermissions
{
pushCode
}
repository
{
empty
blobs
(
paths
:
[
$filePath
])
{
blobs
(
paths
:
[
$filePath
]
,
ref
:
$ref
)
{
nodes
{
webPath
name
...
...
spec/frontend/repository/components/blob_content_viewer_spec.js
View file @
58f1cb7e
...
...
@@ -20,6 +20,8 @@ import blobInfoQuery from '~/repository/queries/blob_info.query.graphql';
jest
.
mock
(
'
~/repository/components/blob_viewers
'
);
let
wrapper
;
let
mockResolver
;
const
simpleMockData
=
{
name
:
'
some_file.js
'
,
size
:
123
,
...
...
@@ -71,14 +73,14 @@ const projectMockData = {
const
localVue
=
createLocalVue
();
const
mockAxios
=
new
MockAdapter
(
axios
);
const
createComponentWithApollo
=
(
mockData
=
{})
=>
{
const
createComponentWithApollo
=
(
mockData
=
{}
,
inject
=
{}
)
=>
{
localVue
.
use
(
VueApollo
);
const
defaultPushCode
=
projectMockData
.
userPermissions
.
pushCode
;
const
defaultEmptyRepo
=
projectMockData
.
repository
.
empty
;
const
{
blobs
,
emptyRepo
=
defaultEmptyRepo
,
canPushCode
=
defaultPushCode
}
=
mockData
;
const
mockResolver
=
jest
.
fn
().
mockResolvedValue
({
mockResolver
=
jest
.
fn
().
mockResolvedValue
({
data
:
{
project
:
{
userPermissions
:
{
pushCode
:
canPushCode
},
...
...
@@ -101,6 +103,14 @@ const createComponentWithApollo = (mockData = {}) => {
path
:
'
some_file.js
'
,
projectPath
:
'
some/path
'
,
},
mixins
:
[
{
data
:
()
=>
({
ref
:
'
default-ref
'
}),
},
],
provide
:
{
...
inject
,
},
});
};
...
...
@@ -119,6 +129,7 @@ const createFactory = (mountFn) => (
queries
:
{
project
:
{
loading
,
refetch
:
jest
.
fn
(),
},
},
},
...
...
@@ -382,4 +393,32 @@ describe('Blob content viewer component', () => {
});
});
});
describe
(
'
blob info query
'
,
()
=>
{
it
(
'
is called with originalBranch value if the prop has a value
'
,
async
()
=>
{
const
inject
=
{
originalBranch
:
'
some-branch
'
};
createComponentWithApollo
({
blobs
:
simpleMockData
},
inject
);
await
waitForPromises
();
expect
(
mockResolver
).
toHaveBeenCalledWith
(
expect
.
objectContaining
({
ref
:
'
some-branch
'
,
}),
);
});
it
(
'
is called with ref value if the originalBranch prop has no value
'
,
async
()
=>
{
const
inject
=
{
originalBranch
:
null
};
createComponentWithApollo
({
blobs
:
simpleMockData
},
inject
);
await
waitForPromises
();
expect
(
mockResolver
).
toHaveBeenCalledWith
(
expect
.
objectContaining
({
ref
:
'
default-ref
'
,
}),
);
});
});
});
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