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
c5aeddee
Commit
c5aeddee
authored
Dec 18, 2019
by
Ezekiel Kigbo
Committed by
Mike Greiling
Dec 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for 422 error when editing stage
parent
8c3ea04a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
8 deletions
+56
-8
ee/app/assets/javascripts/analytics/cycle_analytics/store/actions.js
...ts/javascripts/analytics/cycle_analytics/store/actions.js
+17
-3
ee/spec/features/analytics/cycle_analytics/cycle_analytics_spec.rb
...eatures/analytics/cycle_analytics/cycle_analytics_spec.rb
+8
-0
ee/spec/frontend/analytics/cycle_analytics/store/actions_spec.js
.../frontend/analytics/cycle_analytics/store/actions_spec.js
+31
-5
No files found.
ee/app/assets/javascripts/analytics/cycle_analytics/store/actions.js
View file @
c5aeddee
...
...
@@ -259,9 +259,23 @@ export const receiveUpdateStageSuccess = ({ commit, dispatch }, updatedData) =>
dispatch
(
'
setSelectedStage
'
,
updatedData
);
};
export
const
receiveUpdateStageError
=
({
commit
})
=>
{
export
const
receiveUpdateStageError
=
(
{
commit
},
{
error
:
{
response
:
{
status
=
400
,
data
:
errorData
}
=
{}
}
=
{},
data
},
)
=>
{
commit
(
types
.
RECEIVE_UPDATE_STAGE_RESPONSE
);
createFlash
(
__
(
'
There was a problem saving your custom stage, please try again
'
));
const
ERROR_NAME_RESERVED
=
'
is reserved
'
;
let
message
=
__
(
'
There was a problem saving your custom stage, please try again
'
);
if
(
status
&&
status
===
httpStatus
.
UNPROCESSABLE_ENTITY
)
{
const
{
errors
}
=
errorData
;
const
{
name
}
=
data
;
if
(
errors
.
name
&&
errors
.
name
[
0
]
===
ERROR_NAME_RESERVED
)
{
message
=
__
(
`'
${
name
}
' stage already exists`
);
}
}
createFlash
(
__
(
message
));
};
export
const
updateStage
=
({
dispatch
,
state
},
{
id
,
...
rest
})
=>
{
...
...
@@ -273,7 +287,7 @@ export const updateStage = ({ dispatch, state }, { id, ...rest }) => {
return
Api
.
cycleAnalyticsUpdateStage
(
id
,
fullPath
,
{
...
rest
})
.
then
(({
data
})
=>
dispatch
(
'
receiveUpdateStageSuccess
'
,
data
))
.
catch
(
error
=>
dispatch
(
'
receiveUpdateStageError
'
,
error
));
.
catch
(
error
=>
dispatch
(
'
receiveUpdateStageError
'
,
{
error
,
data
:
{
id
,
...
rest
}
}
));
};
export
const
requestRemoveStage
=
({
commit
})
=>
commit
(
types
.
REQUEST_REMOVE_STAGE
);
...
...
ee/spec/features/analytics/cycle_analytics/cycle_analytics_spec.rb
View file @
c5aeddee
...
...
@@ -399,6 +399,14 @@ describe 'Group Cycle Analytics', :js do
expect
(
page
.
find
(
stage_save_button
)[
:disabled
]).
to
eq
"true"
end
it
'with a default name'
do
name
=
'issue'
fill_in
name_field
,
with:
name
page
.
find
(
stage_save_button
).
click
expect
(
page
.
find
(
'.flash-alert'
)).
to
have_text
(
"'
#{
name
}
' stage already exists"
)
end
end
end
...
...
ee/spec/frontend/analytics/cycle_analytics/store/actions_spec.js
View file @
c5aeddee
...
...
@@ -562,25 +562,51 @@ describe('Cycle analytics actions', () => {
});
it
(
'
dispatches receiveUpdateStageError
'
,
done
=>
{
const
data
=
{
id
:
stageId
,
...
payload
,
};
testAction
(
actions
.
updateStage
,
{
id
:
stageId
,
...
payload
,
},
data
,
state
,
[],
[
{
type
:
'
requestUpdateStage
'
},
{
type
:
'
receiveUpdateStageError
'
,
payload
:
error
,
payload
:
{
error
,
data
}
,
},
],
done
,
);
});
it
(
'
flashes an error if the stage name already exists
'
,
done
=>
{
actions
.
receiveUpdateStageError
(
{
commit
:
()
=>
{},
state
,
},
{
error
:
{
response
:
{
status
:
422
,
data
:
{
errors
:
{
name
:
[
'
is reserved
'
]
},
},
},
},
data
:
{
name
:
stageId
,
},
},
);
shouldFlashAMessage
(
`'
${
stageId
}
' stage already exists`
);
done
();
});
it
(
'
flashes an error message
'
,
done
=>
{
actions
.
receiveUpdateStageError
(
{
...
...
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