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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
47fe2a52
Commit
47fe2a52
authored
Jun 28, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more specs!
parent
d4fce4dc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
234 additions
and
73 deletions
+234
-73
app/assets/javascripts/ide/stores/actions/merge_request.js
app/assets/javascripts/ide/stores/actions/merge_request.js
+2
-4
spec/javascripts/ide/stores/actions/merge_request_spec.js
spec/javascripts/ide/stores/actions/merge_request_spec.js
+198
-69
spec/javascripts/ide/stores/actions/tree_spec.js
spec/javascripts/ide/stores/actions/tree_spec.js
+34
-0
No files found.
app/assets/javascripts/ide/stores/actions/merge_request.js
View file @
47fe2a52
...
@@ -10,8 +10,7 @@ export const getMergeRequestData = (
...
@@ -10,8 +10,7 @@ export const getMergeRequestData = (
if
(
!
state
.
projects
[
projectId
].
mergeRequests
[
mergeRequestId
]
||
force
)
{
if
(
!
state
.
projects
[
projectId
].
mergeRequests
[
mergeRequestId
]
||
force
)
{
service
service
.
getProjectMergeRequestData
(
projectId
,
mergeRequestId
)
.
getProjectMergeRequestData
(
projectId
,
mergeRequestId
)
.
then
(
res
=>
res
.
data
)
.
then
(({
data
})
=>
{
.
then
(
data
=>
{
commit
(
types
.
SET_MERGE_REQUEST
,
{
commit
(
types
.
SET_MERGE_REQUEST
,
{
projectPath
:
projectId
,
projectPath
:
projectId
,
mergeRequestId
,
mergeRequestId
,
...
@@ -45,8 +44,7 @@ export const getMergeRequestChanges = (
...
@@ -45,8 +44,7 @@ export const getMergeRequestChanges = (
if
(
!
state
.
projects
[
projectId
].
mergeRequests
[
mergeRequestId
].
changes
.
length
||
force
)
{
if
(
!
state
.
projects
[
projectId
].
mergeRequests
[
mergeRequestId
].
changes
.
length
||
force
)
{
service
service
.
getProjectMergeRequestChanges
(
projectId
,
mergeRequestId
)
.
getProjectMergeRequestChanges
(
projectId
,
mergeRequestId
)
.
then
(
res
=>
res
.
data
)
.
then
(({
data
})
=>
{
.
then
(
data
=>
{
commit
(
types
.
SET_MERGE_REQUEST_CHANGES
,
{
commit
(
types
.
SET_MERGE_REQUEST_CHANGES
,
{
projectPath
:
projectId
,
projectPath
:
projectId
,
mergeRequestId
,
mergeRequestId
,
...
...
spec/javascripts/ide/stores/actions/merge_request_spec.js
View file @
47fe2a52
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
store
from
'
~/ide/stores
'
;
import
store
from
'
~/ide/stores
'
;
import
{
getMergeRequestData
,
getMergeRequestChanges
,
getMergeRequestVersions
,
}
from
'
~/ide/stores/actions/merge_request
'
;
import
service
from
'
~/ide/services
'
;
import
service
from
'
~/ide/services
'
;
import
{
resetStore
}
from
'
../../helpers
'
;
import
{
resetStore
}
from
'
../../helpers
'
;
describe
(
'
IDE store merge request actions
'
,
()
=>
{
describe
(
'
IDE store merge request actions
'
,
()
=>
{
let
mock
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
store
.
state
.
projects
.
abcproject
=
{
store
.
state
.
projects
.
abcproject
=
{
mergeRequests
:
{},
mergeRequests
:
{},
};
};
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
mock
.
restore
();
resetStore
(
store
);
resetStore
(
store
);
});
});
describe
(
'
getMergeRequestData
'
,
()
=>
{
describe
(
'
getMergeRequestData
'
,
()
=>
{
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'
getProjectMergeRequestData
'
).
and
.
returnValue
(
spyOn
(
service
,
'
getProjectMergeRequestData
'
).
and
.
callThrough
();
Promise
.
resolve
({
data
:
{
title
:
'
mergerequest
'
}
}),
);
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests
\/
1/
)
.
reply
(
200
,
{
title
:
'
mergerequest
'
});
});
});
it
(
'
calls getProjectMergeRequestData service method
'
,
done
=>
{
it
(
'
calls getProjectMergeRequestData service method
'
,
done
=>
{
...
@@ -44,15 +59,55 @@ describe('IDE store merge request actions', () => {
...
@@ -44,15 +59,55 @@ describe('IDE store merge request actions', () => {
});
});
});
});
describe
(
'
getMergeRequestChanges
'
,
()
=>
{
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'
getProjectMergeRequestChanges
'
).
and
.
returnValue
(
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests
\/
1/
).
networkError
();
Promise
.
resolve
({
data
:
{
title
:
'
mergerequest
'
}
}),
});
);
it
(
'
dispatches error action
'
,
done
=>
{
const
dispatch
=
jasmine
.
createSpy
(
'
dispatch
'
);
getMergeRequestData
(
{
commit
()
{},
dispatch
,
state
:
store
.
state
,
},
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
},
)
.
then
(
done
.
fail
)
.
catch
(()
=>
{
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
setErrorMessage
'
,
{
text
:
'
An error occured whilst loading the merge request.
'
,
action
:
jasmine
.
any
(
Function
),
actionText
:
'
Please try again
'
,
actionPayload
:
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
,
force
:
false
,
},
});
done
();
});
});
});
});
describe
(
'
getMergeRequestChanges
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'
1
'
]
=
{
changes
:
[]
};
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'
1
'
]
=
{
changes
:
[]
};
});
});
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'
getProjectMergeRequestChanges
'
).
and
.
callThrough
();
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests
\/
1
\/
changes/
)
.
reply
(
200
,
{
title
:
'
mergerequest
'
});
});
it
(
'
calls getProjectMergeRequestChanges service method
'
,
done
=>
{
it
(
'
calls getProjectMergeRequestChanges service method
'
,
done
=>
{
store
store
.
dispatch
(
'
getMergeRequestChanges
'
,
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
})
.
dispatch
(
'
getMergeRequestChanges
'
,
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
})
...
@@ -77,15 +132,54 @@ describe('IDE store merge request actions', () => {
...
@@ -77,15 +132,54 @@ describe('IDE store merge request actions', () => {
});
});
});
});
describe
(
'
getMergeRequestVersions
'
,
()
=>
{
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'
getProjectMergeRequestVersions
'
).
and
.
returnValue
(
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests
\/
1
\/
changes/
).
networkError
();
Promise
.
resolve
({
data
:
[{
id
:
789
}]
}),
});
);
it
(
'
dispatches error action
'
,
done
=>
{
const
dispatch
=
jasmine
.
createSpy
(
'
dispatch
'
);
getMergeRequestChanges
(
{
commit
()
{},
dispatch
,
state
:
store
.
state
,
},
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
},
)
.
then
(
done
.
fail
)
.
catch
(()
=>
{
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
setErrorMessage
'
,
{
text
:
'
An error occured whilst loading the merge request changes.
'
,
action
:
jasmine
.
any
(
Function
),
actionText
:
'
Please try again
'
,
actionPayload
:
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
,
force
:
false
,
},
});
done
();
});
});
});
});
describe
(
'
getMergeRequestVersions
'
,
()
=>
{
beforeEach
(()
=>
{
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'
1
'
]
=
{
versions
:
[]
};
store
.
state
.
projects
.
abcproject
.
mergeRequests
[
'
1
'
]
=
{
versions
:
[]
};
});
});
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests
\/
1
\/
versions/
)
.
reply
(
200
,
[{
id
:
789
}]);
spyOn
(
service
,
'
getProjectMergeRequestVersions
'
).
and
.
callThrough
();
});
it
(
'
calls getProjectMergeRequestVersions service method
'
,
done
=>
{
it
(
'
calls getProjectMergeRequestVersions service method
'
,
done
=>
{
store
store
.
dispatch
(
'
getMergeRequestVersions
'
,
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
})
.
dispatch
(
'
getMergeRequestVersions
'
,
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
})
...
@@ -107,4 +201,39 @@ describe('IDE store merge request actions', () => {
...
@@ -107,4 +201,39 @@ describe('IDE store merge request actions', () => {
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
error
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
/api
\/(
.*
)\/
projects
\/
abcproject
\/
merge_requests
\/
1
\/
versions/
).
networkError
();
});
it
(
'
dispatches error action
'
,
done
=>
{
const
dispatch
=
jasmine
.
createSpy
(
'
dispatch
'
);
getMergeRequestVersions
(
{
commit
()
{},
dispatch
,
state
:
store
.
state
,
},
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
},
)
.
then
(
done
.
fail
)
.
catch
(()
=>
{
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
setErrorMessage
'
,
{
text
:
'
An error occured whilst loading the merge request version data.
'
,
action
:
jasmine
.
any
(
Function
),
actionText
:
'
Please try again
'
,
actionPayload
:
{
projectId
:
'
abcproject
'
,
mergeRequestId
:
1
,
force
:
false
,
},
});
done
();
});
});
});
});
});
});
spec/javascripts/ide/stores/actions/tree_spec.js
View file @
47fe2a52
...
@@ -116,6 +116,40 @@ describe('Multi-file store tree actions', () => {
...
@@ -116,6 +116,40 @@ describe('Multi-file store tree actions', () => {
done
();
done
();
});
});
});
});
it
(
'
dispatches error action
'
,
done
=>
{
const
dispatch
=
jasmine
.
createSpy
(
'
dispatchSpy
'
);
store
.
state
.
projects
=
{
'
abc/def
'
:
{
web_url
:
`
${
gl
.
TEST_HOST
}
/files`
,
},
};
mock
.
onGet
(
/
(
.*
)
/
).
replyOnce
(
500
);
getFiles
(
{
commit
()
{},
dispatch
,
state
:
store
.
state
,
},
{
projectId
:
'
abc/def
'
,
branchId
:
'
master-testing
'
,
},
)
.
then
(
done
.
fail
)
.
catch
(()
=>
{
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
setErrorMessage
'
,
{
text
:
'
An error occured whilst loading all the files.
'
,
action
:
jasmine
.
any
(
Function
),
actionText
:
'
Please try again
'
,
actionPayload
:
{
projectId
:
'
abc/def
'
,
branchId
:
'
master-testing
'
},
});
done
();
});
});
});
});
});
});
...
...
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