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
Boxiang Sun
gitlab-ce
Commits
8f646faf
Commit
8f646faf
authored
May 30, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved stored data
created reset action to reset stored merge requests
parent
c7609650
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
45 additions
and
3 deletions
+45
-3
app/assets/javascripts/ide/stores/modules/merge_requests/actions.js
.../javascripts/ide/stores/modules/merge_requests/actions.js
+3
-1
app/assets/javascripts/ide/stores/modules/merge_requests/mutation_types.js
...ripts/ide/stores/modules/merge_requests/mutation_types.js
+2
-0
app/assets/javascripts/ide/stores/modules/merge_requests/mutations.js
...avascripts/ide/stores/modules/merge_requests/mutations.js
+9
-1
spec/javascripts/ide/mock_data.js
spec/javascripts/ide/mock_data.js
+2
-0
spec/javascripts/ide/stores/modules/merge_requests/actions_spec.js
...scripts/ide/stores/modules/merge_requests/actions_spec.js
+15
-1
spec/javascripts/ide/stores/modules/merge_requests/mutations_spec.js
...ripts/ide/stores/modules/merge_requests/mutations_spec.js
+14
-0
No files found.
app/assets/javascripts/ide/stores/modules/merge_requests/actions.js
View file @
8f646faf
...
...
@@ -14,11 +14,13 @@ export const receiveMergeRequestsSuccess = ({ commit }, data) =>
export
const
fetchMergeRequests
=
({
dispatch
,
state
})
=>
{
dispatch
(
'
requestMergeRequests
'
);
Api
.
mergeRequests
({
scope
:
state
.
scope
,
view
:
'
simple
'
})
Api
.
mergeRequests
({
scope
:
state
.
scope
,
state
:
'
opened
'
})
.
then
(({
data
})
=>
{
dispatch
(
'
receiveMergeRequestsSuccess
'
,
data
);
})
.
catch
(()
=>
dispatch
(
'
receiveMergeRequestsError
'
));
};
export
const
resetMergeRequests
=
({
commit
})
=>
commit
(
types
.
RESET_MERGE_REQUESTS
);
export
default
()
=>
{};
app/assets/javascripts/ide/stores/modules/merge_requests/mutation_types.js
View file @
8f646faf
export
const
REQUEST_MERGE_REQUESTS
=
'
REQUEST_MERGE_REQUESTS
'
;
export
const
RECEIVE_MERGE_REQUESTS_ERROR
=
'
RECEIVE_MERGE_REQUESTS_ERROR
'
;
export
const
RECEIVE_MERGE_REQUESTS_SUCCESS
=
'
RECEIVE_MERGE_REQUESTS_SUCCESS
'
;
export
const
RESET_MERGE_REQUESTS
=
'
RESET_MERGE_REQUESTS
'
;
app/assets/javascripts/ide/stores/modules/merge_requests/mutations.js
View file @
8f646faf
...
...
@@ -10,8 +10,16 @@ export default {
},
[
types
.
RECEIVE_MERGE_REQUESTS_SUCCESS
](
state
,
data
)
{
state
.
mergeRequests
=
data
.
map
(
mergeRequest
=>
({
id
:
mergeRequest
.
iid
,
id
:
mergeRequest
.
id
,
iid
:
mergeRequest
.
iid
,
title
:
mergeRequest
.
title
,
projectId
:
mergeRequest
.
project_id
,
projectPathWithNamespace
:
mergeRequest
.
web_url
.
replace
(
`
${
gon
.
gitlab_url
}
/`
,
''
)
.
replace
(
`/merge_requests/
${
mergeRequest
.
iid
}
`
,
''
),
}));
},
[
types
.
RESET_MERGE_REQUESTS
](
state
)
{
state
.
mergeRequests
=
[];
},
};
spec/javascripts/ide/mock_data.js
View file @
8f646faf
...
...
@@ -96,8 +96,10 @@ export const fullPipelinesResponse = {
export
const
mergeRequests
=
[
{
id
:
1
,
iid
:
1
,
title
:
'
Test merge request
'
,
project_id
:
1
,
web_url
:
`
${
gl
.
TEST_HOST
}
/namespace/project-path/merge_requests/1`
,
},
];
spec/javascripts/ide/stores/modules/merge_requests/actions_spec.js
View file @
8f646faf
...
...
@@ -7,6 +7,7 @@ import actions, {
receiveMergeRequestsError
,
receiveMergeRequestsSuccess
,
fetchMergeRequests
,
resetMergeRequests
,
}
from
'
~/ide/stores/modules/merge_requests/actions
'
;
import
{
mergeRequests
}
from
'
../../../mock_data
'
;
import
testAction
from
'
../../../../helpers/vuex_action_helper
'
;
...
...
@@ -93,7 +94,7 @@ describe('IDe merge requests actions', () => {
expect
(
apiSpy
).
toHaveBeenCalledWith
(
jasmine
.
anything
(),
{
params
:
{
scope
:
'
assigned-to-me
'
,
view
:
'
simple
'
,
state
:
'
opened
'
,
},
});
});
...
...
@@ -141,4 +142,17 @@ describe('IDe merge requests actions', () => {
});
});
});
describe
(
'
resetMergeRequests
'
,
()
=>
{
it
(
'
commits reset
'
,
done
=>
{
testAction
(
resetMergeRequests
,
null
,
mockedState
,
[{
type
:
types
.
RESET_MERGE_REQUESTS
}],
[],
done
,
);
});
});
});
spec/javascripts/ide/stores/modules/merge_requests/mutations_spec.js
View file @
8f646faf
...
...
@@ -28,14 +28,28 @@ describe('IDE merge requests mutations', () => {
describe
(
types
.
RECEIVE_MERGE_REQUESTS_SUCCESS
,
()
=>
{
it
(
'
sets merge requests
'
,
()
=>
{
gon
.
gitlab_url
=
gl
.
TEST_HOST
;
mutations
[
types
.
RECEIVE_MERGE_REQUESTS_SUCCESS
](
mockedState
,
mergeRequests
);
expect
(
mockedState
.
mergeRequests
).
toEqual
([
{
id
:
1
,
iid
:
1
,
title
:
'
Test merge request
'
,
projectId
:
1
,
projectPathWithNamespace
:
'
namespace/project-path
'
,
},
]);
});
});
describe
(
types
.
RESET_MERGE_REQUESTS
,
()
=>
{
it
(
'
clears merge request array
'
,
()
=>
{
mockedState
.
mergeRequests
=
[
'
test
'
];
mutations
[
types
.
RESET_MERGE_REQUESTS
](
mockedState
);
expect
(
mockedState
.
mergeRequests
).
toEqual
([]);
});
});
});
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