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
9712a6dd
Commit
9712a6dd
authored
Jul 31, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
specs
parent
fd3ef2eb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
208 additions
and
15 deletions
+208
-15
app/assets/javascripts/ide/components/new_dropdown/modal.vue
app/assets/javascripts/ide/components/new_dropdown/modal.vue
+4
-4
app/assets/javascripts/ide/stores/mutations.js
app/assets/javascripts/ide/stores/mutations.js
+4
-4
locale/gitlab.pot
locale/gitlab.pot
+6
-0
spec/javascripts/ide/stores/actions_spec.js
spec/javascripts/ide/stores/actions_spec.js
+54
-0
spec/javascripts/ide/stores/mutations_spec.js
spec/javascripts/ide/stores/mutations_spec.js
+97
-0
spec/javascripts/ide/stores/utils_spec.js
spec/javascripts/ide/stores/utils_spec.js
+16
-0
spec/javascripts/vue_shared/components/gl_modal_spec.js
spec/javascripts/vue_shared/components/gl_modal_spec.js
+27
-7
No files found.
app/assets/javascripts/ide/components/new_dropdown/modal.vue
View file @
9712a6dd
...
@@ -25,19 +25,19 @@ export default {
...
@@ -25,19 +25,19 @@ export default {
},
},
},
},
modalTitle
()
{
modalTitle
()
{
if
(
this
.
entryModal
.
type
===
'
rename
'
)
return
__
(
'
Rename
'
);
if
(
this
.
entryModal
.
type
===
'
tree
'
)
{
if
(
this
.
entryModal
.
type
===
'
tree
'
)
{
return
__
(
'
Create new directory
'
);
return
__
(
'
Create new directory
'
);
}
else
if
(
this
.
entryModal
.
type
===
'
rename
'
)
{
return
this
.
entryModal
.
entry
.
type
===
'
tree
'
?
__
(
'
Rename folder
'
)
:
__
(
'
Rename file
'
);
}
}
return
__
(
'
Create new file
'
);
return
__
(
'
Create new file
'
);
},
},
buttonLabel
()
{
buttonLabel
()
{
if
(
this
.
entryModal
.
type
===
'
rename
'
)
return
__
(
'
Update
'
);
if
(
this
.
entryModal
.
type
===
'
tree
'
)
{
if
(
this
.
entryModal
.
type
===
'
tree
'
)
{
return
__
(
'
Create directory
'
);
return
__
(
'
Create directory
'
);
}
else
if
(
this
.
entryModal
.
type
===
'
rename
'
)
{
return
this
.
entryModal
.
entry
.
type
===
'
tree
'
?
__
(
'
Rename folder
'
)
:
__
(
'
Rename file
'
);
}
}
return
__
(
'
Create file
'
);
return
__
(
'
Create file
'
);
...
...
app/assets/javascripts/ide/stores/mutations.js
View file @
9712a6dd
...
@@ -153,10 +153,10 @@ export default {
...
@@ -153,10 +153,10 @@ export default {
const
regex
=
new
RegExp
(
`
${
prevPath
}
$`
);
const
regex
=
new
RegExp
(
`
${
prevPath
}
$`
);
Object
.
assign
(
state
.
entries
[
file
.
path
],
{
Object
.
assign
(
state
.
entries
[
file
.
path
],
{
rawPath
:
file
.
rawPath
.
replace
(
regex
,
file
.
name
),
rawPath
:
file
.
rawPath
.
replace
(
regex
,
file
.
path
),
permalink
:
file
.
permalink
.
replace
(
regex
,
file
.
name
),
permalink
:
file
.
permalink
.
replace
(
regex
,
file
.
path
),
commitsPath
:
file
.
commitsPath
.
replace
(
regex
,
file
.
name
),
commitsPath
:
file
.
commitsPath
.
replace
(
regex
,
file
.
path
),
blamePath
:
file
.
blamePath
.
replace
(
regex
,
file
.
name
),
blamePath
:
file
.
blamePath
.
replace
(
regex
,
file
.
path
),
});
});
}
}
},
},
...
...
locale/gitlab.pot
View file @
9712a6dd
...
@@ -4354,6 +4354,12 @@ msgstr ""
...
@@ -4354,6 +4354,12 @@ msgstr ""
msgid "Rename"
msgid "Rename"
msgstr ""
msgstr ""
msgid "Rename file"
msgstr ""
msgid "Rename folder"
msgstr ""
msgid "Reply to this email directly or %{view_it_on_gitlab}."
msgid "Reply to this email directly or %{view_it_on_gitlab}."
msgstr ""
msgstr ""
...
...
spec/javascripts/ide/stores/actions_spec.js
View file @
9712a6dd
...
@@ -8,6 +8,7 @@ import actions, {
...
@@ -8,6 +8,7 @@ import actions, {
updateTempFlagForEntry
,
updateTempFlagForEntry
,
setErrorMessage
,
setErrorMessage
,
deleteEntry
,
deleteEntry
,
renameEntry
,
}
from
'
~/ide/stores/actions
'
;
}
from
'
~/ide/stores/actions
'
;
import
store
from
'
~/ide/stores
'
;
import
store
from
'
~/ide/stores
'
;
import
*
as
types
from
'
~/ide/stores/mutation_types
'
;
import
*
as
types
from
'
~/ide/stores/mutation_types
'
;
...
@@ -473,4 +474,57 @@ describe('Multi-file store actions', () => {
...
@@ -473,4 +474,57 @@ describe('Multi-file store actions', () => {
);
);
});
});
});
});
describe
(
'
renameEntry
'
,
()
=>
{
it
(
'
renames entry
'
,
done
=>
{
store
.
state
.
entries
.
test
=
{
tree
:
[],
};
testAction
(
renameEntry
,
{
path
:
'
test
'
,
name
:
'
new-name
'
},
store
.
state
,
[
{
type
:
types
.
RENAME_ENTRY
,
payload
:
{
path
:
'
test
'
,
name
:
'
new-name
'
,
entryPath
:
null
},
},
],
[{
type
:
'
deleteEntry
'
,
payload
:
'
test
'
}],
done
,
);
});
it
(
'
renames all entries in tree
'
,
done
=>
{
store
.
state
.
entries
.
test
=
{
tree
:
[
{
path
:
'
tree-1
'
,
},
{
path
:
'
tree-2
'
,
},
],
};
testAction
(
renameEntry
,
{
path
:
'
test
'
,
name
:
'
new-name
'
},
store
.
state
,
[
{
type
:
types
.
RENAME_ENTRY
,
payload
:
{
path
:
'
test
'
,
name
:
'
new-name
'
,
entryPath
:
null
},
},
],
[
{
type
:
'
renameEntry
'
,
payload
:
{
path
:
'
test
'
,
name
:
'
new-name
'
,
entryPath
:
'
tree-1
'
}
},
{
type
:
'
renameEntry
'
,
payload
:
{
path
:
'
test
'
,
name
:
'
new-name
'
,
entryPath
:
'
tree-2
'
}
},
{
type
:
'
deleteEntry
'
,
payload
:
'
test
'
},
],
done
,
);
});
});
});
});
spec/javascripts/ide/stores/mutations_spec.js
View file @
9712a6dd
...
@@ -213,4 +213,101 @@ describe('Multi-file store mutations', () => {
...
@@ -213,4 +213,101 @@ describe('Multi-file store mutations', () => {
expect
(
localState
.
changedFiles
).
toEqual
([
localState
.
entries
.
filePath
]);
expect
(
localState
.
changedFiles
).
toEqual
([
localState
.
entries
.
filePath
]);
});
});
});
});
describe
(
'
UPDATE_FILE_AFTER_COMMIT
'
,
()
=>
{
it
(
'
updates URLs if prevPath is set
'
,
()
=>
{
const
f
=
{
...
file
(),
path
:
'
test
'
,
prevPath
:
'
testing-123
'
,
rawPath
:
`
${
gl
.
TEST_HOST
}
/testing-123`
,
permalink
:
`
${
gl
.
TEST_HOST
}
/testing-123`
,
commitsPath
:
`
${
gl
.
TEST_HOST
}
/testing-123`
,
blamePath
:
`
${
gl
.
TEST_HOST
}
/testing-123`
,
};
localState
.
entries
.
test
=
f
;
localState
.
changedFiles
.
push
(
f
);
mutations
.
UPDATE_FILE_AFTER_COMMIT
(
localState
,
{
file
:
f
,
lastCommit
:
{
commit
:
{}
}
});
expect
(
f
.
rawPath
).
toBe
(
`
${
gl
.
TEST_HOST
}
/test`
);
expect
(
f
.
permalink
).
toBe
(
`
${
gl
.
TEST_HOST
}
/test`
);
expect
(
f
.
commitsPath
).
toBe
(
`
${
gl
.
TEST_HOST
}
/test`
);
expect
(
f
.
blamePath
).
toBe
(
`
${
gl
.
TEST_HOST
}
/test`
);
});
});
describe
(
'
OPEN_NEW_ENTRY_MODAL
'
,
()
=>
{
it
(
'
sets entryModal
'
,
()
=>
{
localState
.
entries
.
testPath
=
{
...
file
(),
};
mutations
.
OPEN_NEW_ENTRY_MODAL
(
localState
,
{
type
:
'
test
'
,
path
:
'
testPath
'
});
expect
(
localState
.
entryModal
).
toEqual
({
type
:
'
test
'
,
path
:
'
testPath
'
,
entry
:
localState
.
entries
.
testPath
,
});
});
});
describe
(
'
RENAME_ENTRY
'
,
()
=>
{
beforeEach
(()
=>
{
localState
.
trees
=
{
'
gitlab-ce/master
'
:
{
tree
:
[]
},
};
localState
.
currentProjectId
=
'
gitlab-ce
'
;
localState
.
currentBranchId
=
'
master
'
;
localState
.
entries
.
oldPath
=
{
...
file
(),
type
:
'
blob
'
,
path
:
'
oldPath
'
,
url
:
`
${
gl
.
TEST_HOST
}
/oldPath`
,
};
});
it
(
'
creates new renamed entry
'
,
()
=>
{
mutations
.
RENAME_ENTRY
(
localState
,
{
path
:
'
oldPath
'
,
name
:
'
newPath
'
});
expect
(
localState
.
entries
.
newPath
).
toEqual
({
...
localState
.
entries
.
oldPath
,
id
:
'
newPath
'
,
name
:
'
newPath
'
,
key
:
'
newPath-blob-name
'
,
path
:
'
newPath
'
,
tempFile
:
true
,
prevPath
:
'
oldPath
'
,
tree
:
[],
parentPath
:
''
,
url
:
`
${
gl
.
TEST_HOST
}
/newPath`
,
moved
:
jasmine
.
anything
(),
});
});
it
(
'
adds new entry to changedFiles
'
,
()
=>
{
mutations
.
RENAME_ENTRY
(
localState
,
{
path
:
'
oldPath
'
,
name
:
'
newPath
'
});
expect
(
localState
.
changedFiles
.
length
).
toBe
(
1
);
expect
(
localState
.
changedFiles
[
0
].
path
).
toBe
(
'
newPath
'
);
});
it
(
'
sets oldEntry as moved
'
,
()
=>
{
mutations
.
RENAME_ENTRY
(
localState
,
{
path
:
'
oldPath
'
,
name
:
'
newPath
'
});
expect
(
localState
.
entries
.
oldPath
.
moved
).
toBe
(
true
);
});
it
(
'
adds to parents tree
'
,
()
=>
{
localState
.
entries
.
oldPath
.
parentPath
=
'
parentPath
'
;
localState
.
entries
.
parentPath
=
{
...
file
(),
};
mutations
.
RENAME_ENTRY
(
localState
,
{
path
:
'
oldPath
'
,
name
:
'
newPath
'
});
expect
(
localState
.
entries
.
parentPath
.
tree
.
length
).
toBe
(
1
);
});
});
});
});
spec/javascripts/ide/stores/utils_spec.js
View file @
9712a6dd
...
@@ -232,6 +232,17 @@ describe('Multi-file store utils', () => {
...
@@ -232,6 +232,17 @@ describe('Multi-file store utils', () => {
},
},
],
],
},
},
{
path
:
'
c
'
,
prevPath
:
'
x
'
,
type
:
'
tree
'
,
tree
:
[
{
path
:
'
c/index.js
'
,
type
:
'
blob
'
,
},
],
},
];
];
const
flattendFiles
=
utils
.
getCommitFiles
(
files
);
const
flattendFiles
=
utils
.
getCommitFiles
(
files
);
...
@@ -252,6 +263,11 @@ describe('Multi-file store utils', () => {
...
@@ -252,6 +263,11 @@ describe('Multi-file store utils', () => {
type
:
'
blob
'
,
type
:
'
blob
'
,
deleted
:
true
,
deleted
:
true
,
},
},
{
path
:
'
c/index.js
'
,
type
:
'
blob
'
,
deleted
:
true
,
},
]);
]);
});
});
});
});
...
...
spec/javascripts/vue_shared/components/gl_modal_spec.js
View file @
9712a6dd
...
@@ -29,7 +29,7 @@ describe('GlModal', () => {
...
@@ -29,7 +29,7 @@ describe('GlModal', () => {
describe
(
'
without id
'
,
()
=>
{
describe
(
'
without id
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
modalComponent
,
{
});
vm
=
mountComponent
(
modalComponent
,
{});
});
});
it
(
'
does not add an id attribute to the modal
'
,
()
=>
{
it
(
'
does not add an id attribute to the modal
'
,
()
=>
{
...
@@ -83,7 +83,7 @@ describe('GlModal', () => {
...
@@ -83,7 +83,7 @@ describe('GlModal', () => {
});
});
});
});
it
(
'
works with data-toggle="modal"
'
,
(
done
)
=>
{
it
(
'
works with data-toggle="modal"
'
,
done
=>
{
setFixtures
(
`
setFixtures
(
`
<button id="modal-button" data-toggle="modal" data-target="#my-modal"></button>
<button id="modal-button" data-toggle="modal" data-target="#my-modal"></button>
<div id="modal-container"></div>
<div id="modal-container"></div>
...
@@ -91,9 +91,13 @@ describe('GlModal', () => {
...
@@ -91,9 +91,13 @@ describe('GlModal', () => {
const
modalContainer
=
document
.
getElementById
(
'
modal-container
'
);
const
modalContainer
=
document
.
getElementById
(
'
modal-container
'
);
const
modalButton
=
document
.
getElementById
(
'
modal-button
'
);
const
modalButton
=
document
.
getElementById
(
'
modal-button
'
);
vm
=
mountComponent
(
modalComponent
,
{
vm
=
mountComponent
(
id
:
'
my-modal
'
,
modalComponent
,
},
modalContainer
);
{
id
:
'
my-modal
'
,
},
modalContainer
,
);
$
(
vm
.
$el
).
on
(
'
shown.bs.modal
'
,
()
=>
done
());
$
(
vm
.
$el
).
on
(
'
shown.bs.modal
'
,
()
=>
done
());
modalButton
.
click
();
modalButton
.
click
();
...
@@ -103,7 +107,7 @@ describe('GlModal', () => {
...
@@ -103,7 +107,7 @@ describe('GlModal', () => {
const
dummyEvent
=
'
not really an event
'
;
const
dummyEvent
=
'
not really an event
'
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
modalComponent
,
{
});
vm
=
mountComponent
(
modalComponent
,
{});
spyOn
(
vm
,
'
$emit
'
);
spyOn
(
vm
,
'
$emit
'
);
});
});
...
@@ -122,11 +126,27 @@ describe('GlModal', () => {
...
@@ -122,11 +126,27 @@ describe('GlModal', () => {
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
submit
'
,
dummyEvent
);
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
submit
'
,
dummyEvent
);
});
});
});
});
describe
(
'
opened
'
,
()
=>
{
it
(
'
emits a open event
'
,
()
=>
{
vm
.
opened
();
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
open
'
);
});
});
describe
(
'
closed
'
,
()
=>
{
it
(
'
emits a closed event
'
,
()
=>
{
vm
.
closed
();
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
closed
'
);
});
});
});
});
describe
(
'
slots
'
,
()
=>
{
describe
(
'
slots
'
,
()
=>
{
const
slotContent
=
'
this should go into the slot
'
;
const
slotContent
=
'
this should go into the slot
'
;
const
modalWithSlot
=
(
slotName
)
=>
{
const
modalWithSlot
=
slotName
=>
{
let
template
;
let
template
;
if
(
slotName
)
{
if
(
slotName
)
{
template
=
`
template
=
`
...
...
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