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
f61f1e45
Commit
f61f1e45
authored
Jan 07, 2020
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update IDE discard to undo changes on renamed file
https://gitlab.com/gitlab-org/gitlab/issues/31859
parent
a6a3f8c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
14 deletions
+30
-14
app/assets/javascripts/ide/stores/actions/file.js
app/assets/javascripts/ide/stores/actions/file.js
+1
-0
changelogs/unreleased/31859-fix-discarding-renamed-entry-with-changes.yml
...eased/31859-fix-discarding-renamed-entry-with-changes.yml
+5
-0
spec/frontend/ide/stores/actions/file_spec.js
spec/frontend/ide/stores/actions/file_spec.js
+24
-14
No files found.
app/assets/javascripts/ide/stores/actions/file.js
View file @
f61f1e45
...
...
@@ -197,6 +197,7 @@ export const discardFileChanges = ({ dispatch, state, commit, getters }, path) =
if
(
file
.
tempFile
)
{
dispatch
(
'
deleteEntry
'
,
file
.
path
);
}
else
{
commit
(
types
.
DISCARD_FILE_CHANGES
,
file
.
path
);
dispatch
(
'
renameEntry
'
,
{
path
:
file
.
path
,
name
:
file
.
prevName
,
...
...
changelogs/unreleased/31859-fix-discarding-renamed-entry-with-changes.yml
0 → 100644
View file @
f61f1e45
---
title
:
Update IDE discard of renamed entry to also discard file changes
merge_request
:
22573
author
:
type
:
fixed
spec/frontend/ide/stores/actions/file_spec.js
View file @
f61f1e45
...
...
@@ -9,6 +9,7 @@ import router from '~/ide/ide_router';
import
eventHub
from
'
~/ide/eventhub
'
;
import
{
file
}
from
'
../../helpers
'
;
const
ORIGINAL_CONTENT
=
'
original content
'
;
const
RELATIVE_URL_ROOT
=
'
/gitlab
'
;
describe
(
'
IDE store file actions
'
,
()
=>
{
...
...
@@ -583,6 +584,7 @@ describe('IDE store file actions', () => {
tmpFile
=
file
(
'
tempFile
'
);
tmpFile
.
content
=
'
testing
'
;
tmpFile
.
raw
=
ORIGINAL_CONTENT
;
store
.
state
.
changedFiles
.
push
(
tmpFile
);
store
.
state
.
entries
[
tmpFile
.
path
]
=
tmpFile
;
...
...
@@ -594,7 +596,7 @@ describe('IDE store file actions', () => {
store
.
dispatch
(
'
discardFileChanges
'
,
tmpFile
.
path
)
.
then
(()
=>
{
expect
(
tmpFile
.
content
).
not
.
toBe
(
'
testing
'
);
expect
(
tmpFile
.
content
).
toBe
(
ORIGINAL_CONTENT
);
done
();
})
...
...
@@ -624,22 +626,30 @@ describe('IDE store file actions', () => {
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
deleteEntry
'
,
tmpFile
.
path
);
});
it
(
'
renames the file to its original name and closes it if it was open
'
,
()
=>
{
Object
.
assign
(
tmpFile
,
{
prevPath
:
'
parentPath/old_name
'
,
prevName
:
'
old_name
'
,
prevParentPath
:
'
parentPath
'
,
});
describe
(
'
with renamed file
'
,
()
=>
{
beforeEach
(()
=>
{
Object
.
assign
(
tmpFile
,
{
prevPath
:
'
parentPath/old_name
'
,
prevName
:
'
old_name
'
,
prevParentPath
:
'
parentPath
'
,
});
store
.
state
.
entries
.
parentPath
=
file
(
'
parentPath
'
);
store
.
state
.
entries
.
parentPath
=
file
(
'
parentPath
'
);
actions
.
discardFileChanges
(
store
,
tmpFile
.
path
);
actions
.
discardFileChanges
(
store
,
tmpFile
.
path
);
});
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
closeFile
'
,
tmpFile
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
renameEntry
'
,
{
path
:
'
tempFile
'
,
name
:
'
old_name
'
,
parentPath
:
'
parentPath
'
,
it
(
'
renames the file to its original name and closes it if it was open
'
,
()
=>
{
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
closeFile
'
,
tmpFile
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
renameEntry
'
,
{
path
:
'
tempFile
'
,
name
:
'
old_name
'
,
parentPath
:
'
parentPath
'
,
});
});
it
(
'
resets file content
'
,
()
=>
{
expect
(
tmpFile
.
content
).
toBe
(
ORIGINAL_CONTENT
);
});
});
...
...
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