diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2018-03-25 22:13:55 +0200 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2018-03-25 22:13:55 +0200 |
commit | d1cb1da8ea065e8ca530a1b441616c2944f8bdc1 (patch) | |
tree | a3539b3c5048622b45f2f1179ec8f3a80bbc7025 | |
parent | 5ddde3fbb0829b3053435b95f668915bae81c5d5 (diff) | |
download | gitlab-ce-d1cb1da8ea065e8ca530a1b441616c2944f8bdc1.tar.gz |
Fixes for Tests on file.js and tabs tests
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/file.js | 43 | ||||
-rw-r--r-- | spec/javascripts/ide/components/repo_tabs_spec.js | 1 |
2 files changed, 21 insertions, 23 deletions
diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js index d7701463605..b6b7dae5713 100644 --- a/app/assets/javascripts/ide/stores/actions/file.js +++ b/app/assets/javascripts/ide/stores/actions/file.js @@ -48,29 +48,26 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => { export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive = true }) => { const file = state.entries[path]; - return new Promise((resolve, reject) => { - commit(types.TOGGLE_LOADING, { entry: file }); - service - .getFileData(file.url) - .then(res => { - const pageTitle = decodeURI(normalizeHeaders(res.headers)['PAGE-TITLE']); - - setPageTitle(pageTitle); - - return res.json(); - }) - .then(data => { - commit(types.SET_FILE_DATA, { data, file }); - commit(types.TOGGLE_FILE_OPEN, path); - if (makeFileActive) dispatch('setFileActive', file.path); - commit(types.TOGGLE_LOADING, { entry: file }); - }) - .catch(err => { - commit(types.TOGGLE_LOADING, { entry: file }); - flash('Error loading file data. Please try again.', 'alert', document, null, false, true); - reject(err); - }); - }); + commit(types.TOGGLE_LOADING, { entry: file }); + return service + .getFileData(file.url) + .then(res => { + const pageTitle = decodeURI(normalizeHeaders(res.headers)['PAGE-TITLE']); + + setPageTitle(pageTitle); + + return res.json(); + }) + .then(data => { + commit(types.SET_FILE_DATA, { data, file }); + commit(types.TOGGLE_FILE_OPEN, path); + if (makeFileActive) dispatch('setFileActive', file.path); + commit(types.TOGGLE_LOADING, { entry: file }); + }) + .catch(() => { + commit(types.TOGGLE_LOADING, { entry: file }); + flash('Error loading file data. Please try again.', 'alert', document, null, false, true); + }); }; export const setFileMrChange = ({ state, commit }, { file, mrChange }) => { diff --git a/spec/javascripts/ide/components/repo_tabs_spec.js b/spec/javascripts/ide/components/repo_tabs_spec.js index ceb0416aff8..454aa62be1f 100644 --- a/spec/javascripts/ide/components/repo_tabs_spec.js +++ b/spec/javascripts/ide/components/repo_tabs_spec.js @@ -17,6 +17,7 @@ describe('RepoTabs', () => { files: openedFiles, viewer: 'editor', hasChanges: false, + hasMergeRequest: false, }); openedFiles[0].active = true; |