Commit 83a34286 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch '333776-update-blob-to-use-canpushcode' into 'master'

Update to use correct push code permission

See merge request gitlab-org/gitlab!65090
parents c37b441f 93f9c146
...@@ -65,6 +65,9 @@ export default { ...@@ -65,6 +65,9 @@ export default {
isLoadingLegacyViewer: false, isLoadingLegacyViewer: false,
activeViewerType: SIMPLE_BLOB_VIEWER, activeViewerType: SIMPLE_BLOB_VIEWER,
project: { project: {
userPermissions: {
pushCode: false,
},
repository: { repository: {
blobs: { blobs: {
nodes: [ nodes: [
...@@ -86,7 +89,6 @@ export default { ...@@ -86,7 +89,6 @@ export default {
canLock: false, canLock: false,
isLocked: false, isLocked: false,
lockLink: '', lockLink: '',
canModifyBlob: true,
forkPath: '', forkPath: '',
simpleViewer: {}, simpleViewer: {},
richViewer: null, richViewer: null,
...@@ -168,7 +170,7 @@ export default { ...@@ -168,7 +170,7 @@ export default {
:path="path" :path="path"
:name="blobInfo.name" :name="blobInfo.name"
:replace-path="blobInfo.replacePath" :replace-path="blobInfo.replacePath"
:can-push-code="blobInfo.canModifyBlob" :can-push-code="project.userPermissions.pushCode"
/> />
</template> </template>
</blob-header> </blob-header>
......
query getBlobInfo($projectPath: ID!, $filePath: String!) { query getBlobInfo($projectPath: ID!, $filePath: String!) {
project(fullPath: $projectPath) { project(fullPath: $projectPath) {
userPermissions {
pushCode
}
repository { repository {
blobs(paths: [$filePath]) { blobs(paths: [$filePath]) {
nodes { nodes {
...@@ -15,7 +18,6 @@ query getBlobInfo($projectPath: ID!, $filePath: String!) { ...@@ -15,7 +18,6 @@ query getBlobInfo($projectPath: ID!, $filePath: String!) {
storedExternally storedExternally
rawPath rawPath
replacePath replacePath
canModifyBlob
simpleViewer { simpleViewer {
fileType fileType
tooLarge tooLarge
......
...@@ -37,7 +37,6 @@ const simpleMockData = { ...@@ -37,7 +37,6 @@ const simpleMockData = {
canLock: true, canLock: true,
isLocked: false, isLocked: false,
lockLink: 'some_file.js/lock', lockLink: 'some_file.js/lock',
canModifyBlob: true,
forkPath: 'some_file.js/fork', forkPath: 'some_file.js/fork',
simpleViewer: { simpleViewer: {
fileType: 'text', fileType: 'text',
...@@ -56,16 +55,26 @@ const richMockData = { ...@@ -56,16 +55,26 @@ const richMockData = {
renderError: null, renderError: null,
}, },
}; };
const userPermissionsMockData = {
userPermissions: {
pushCode: true,
},
};
const localVue = createLocalVue(); const localVue = createLocalVue();
const mockAxios = new MockAdapter(axios); const mockAxios = new MockAdapter(axios);
const createComponentWithApollo = (mockData) => { const createComponentWithApollo = (mockData, mockPermissionData = true) => {
localVue.use(VueApollo); localVue.use(VueApollo);
const mockResolver = jest const mockResolver = jest.fn().mockResolvedValue({
.fn() data: {
.mockResolvedValue({ data: { project: { repository: { blobs: { nodes: [mockData] } } } } }); project: {
userPermissions: { pushCode: mockPermissionData },
repository: { blobs: { nodes: [mockData] } },
},
},
});
const fakeApollo = createMockApollo([[blobInfoQuery, mockResolver]]); const fakeApollo = createMockApollo([[blobInfoQuery, mockResolver]]);
...@@ -276,13 +285,16 @@ describe('Blob content viewer component', () => { ...@@ -276,13 +285,16 @@ describe('Blob content viewer component', () => {
}); });
describe('BlobButtonGroup', () => { describe('BlobButtonGroup', () => {
const { name, path } = simpleMockData; const { name, path, replacePath } = simpleMockData;
const {
userPermissions: { pushCode },
} = userPermissionsMockData;
it('renders component', async () => { it('renders component', async () => {
window.gon.current_user_id = 1; window.gon.current_user_id = 1;
fullFactory({ fullFactory({
mockData: { blobInfo: simpleMockData }, mockData: { blobInfo: simpleMockData, project: userPermissionsMockData },
stubs: { stubs: {
BlobContent: true, BlobContent: true,
BlobButtonGroup: true, BlobButtonGroup: true,
...@@ -294,6 +306,8 @@ describe('Blob content viewer component', () => { ...@@ -294,6 +306,8 @@ describe('Blob content viewer component', () => {
expect(findBlobButtonGroup().props()).toMatchObject({ expect(findBlobButtonGroup().props()).toMatchObject({
name, name,
path, path,
replacePath,
canPushCode: pushCode,
}); });
}); });
......
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