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
4a4caa01
Commit
4a4caa01
authored
Mar 21, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spec fixes
parent
ba63bda9
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
91 deletions
+52
-91
app/assets/javascripts/ide/stores/actions/file.js
app/assets/javascripts/ide/stores/actions/file.js
+4
-1
spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js
...cripts/ide/components/commit_sidebar/stage_button_spec.js
+3
-3
spec/javascripts/ide/components/commit_sidebar/unstage_button_spec.js
...ipts/ide/components/commit_sidebar/unstage_button_spec.js
+2
-2
spec/javascripts/ide/components/repo_commit_section_spec.js
spec/javascripts/ide/components/repo_commit_section_spec.js
+4
-0
spec/javascripts/ide/stores/actions_spec.js
spec/javascripts/ide/stores/actions_spec.js
+7
-30
spec/javascripts/ide/stores/modules/commit/actions_spec.js
spec/javascripts/ide/stores/modules/commit/actions_spec.js
+15
-18
spec/javascripts/ide/stores/modules/commit/getters_spec.js
spec/javascripts/ide/stores/modules/commit/getters_spec.js
+5
-5
spec/javascripts/ide/stores/mutations/file_spec.js
spec/javascripts/ide/stores/mutations/file_spec.js
+12
-32
No files found.
app/assets/javascripts/ide/stores/actions/file.js
View file @
4a4caa01
...
...
@@ -142,7 +142,10 @@ export const discardFileChanges = ({ state, commit }, path) => {
commit
(
types
.
TOGGLE_FILE_OPEN
,
path
);
}
eventHub
.
$emit
(
`editor.update.model.content.
${
file
.
path
}
`
,
file
.
raw
);
eventHub
.
$emit
(
`editor.update.model.content.
${
path
}
`
,
{
content
:
file
.
raw
,
changed
:
false
,
});
};
export
const
stageChange
=
({
commit
},
path
)
=>
{
...
...
spec/javascripts/ide/components/commit_sidebar/stage_button_spec.js
View file @
4a4caa01
...
...
@@ -13,7 +13,7 @@ describe('IDE stage file button', () => {
f
=
file
();
vm
=
createComponentWithStore
(
Component
,
store
,
{
file
:
f
,
path
:
f
.
path
,
});
spyOn
(
vm
,
'
stageChange
'
);
...
...
@@ -35,12 +35,12 @@ describe('IDE stage file button', () => {
it
(
'
calls store with stage button
'
,
()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.btn
'
)[
0
].
click
();
expect
(
vm
.
stageChange
).
toHaveBeenCalledWith
(
f
);
expect
(
vm
.
stageChange
).
toHaveBeenCalledWith
(
f
.
path
);
});
it
(
'
calls store with discard button
'
,
()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.btn
'
)[
1
].
click
();
expect
(
vm
.
discardFileChanges
).
toHaveBeenCalledWith
(
f
);
expect
(
vm
.
discardFileChanges
).
toHaveBeenCalledWith
(
f
.
path
);
});
});
spec/javascripts/ide/components/commit_sidebar/unstage_button_spec.js
View file @
4a4caa01
...
...
@@ -13,7 +13,7 @@ describe('IDE unstage file button', () => {
f
=
file
();
vm
=
createComponentWithStore
(
Component
,
store
,
{
file
:
f
,
path
:
f
.
path
,
});
spyOn
(
vm
,
'
unstageChange
'
);
...
...
@@ -34,6 +34,6 @@ describe('IDE unstage file button', () => {
it
(
'
calls store with unnstage button
'
,
()
=>
{
vm
.
$el
.
querySelector
(
'
.btn
'
).
click
();
expect
(
vm
.
unstageChange
).
toHaveBeenCalledWith
(
f
);
expect
(
vm
.
unstageChange
).
toHaveBeenCalledWith
(
f
.
path
);
});
});
spec/javascripts/ide/components/repo_commit_section_spec.js
View file @
4a4caa01
...
...
@@ -52,6 +52,10 @@ describe('RepoCommitSection', () => {
}),
);
vm
.
$store
.
state
.
changedFiles
.
forEach
(
f
=>
{
vm
.
$store
.
state
.
entries
[
f
.
path
]
=
f
;
});
return
vm
.
$mount
();
}
...
...
spec/javascripts/ide/stores/actions_spec.js
View file @
4a4caa01
...
...
@@ -298,28 +298,15 @@ describe('Multi-file store actions', () => {
store
.
state
.
changedFiles
.
push
(
f
);
store
.
state
.
changedFiles
.
push
(
file
(
'
new
'
));
store
.
dispatch
(
'
stageAllChanges
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
stagedFiles
.
length
).
toBe
(
2
);
expect
(
store
.
state
.
stagedFiles
[
0
]).
toEqual
(
f
);
done
();
})
.
catch
(
done
.
fail
);
store
.
state
.
changedFiles
.
forEach
(
localFile
=>
{
store
.
state
.
entries
[
localFile
.
path
]
=
localFile
;
});
it
(
'
sets all files from changedFiles as staged after adding to stagedFiles
'
,
done
=>
{
store
.
state
.
changedFiles
.
push
(
file
());
store
.
state
.
changedFiles
.
push
(
file
(
'
new
'
));
store
.
dispatch
(
'
stageAllChanges
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
changedFiles
.
length
).
toBe
(
2
);
store
.
state
.
changedFiles
.
forEach
(
f
=>
{
expect
(
f
.
staged
).
toBeTruthy
();
});
expect
(
store
.
state
.
stagedFiles
.
length
).
toBe
(
2
);
expect
(
store
.
state
.
stagedFiles
[
0
]).
toEqual
(
f
);
done
();
})
...
...
@@ -340,20 +327,10 @@ describe('Multi-file store actions', () => {
store
.
state
.
changedFiles
.
push
({
...
f
,
});
});
it
(
'
sets staged to false in changedFiles when unstaging
'
,
done
=>
{
store
.
state
.
stagedFiles
.
push
(
f
);
store
.
dispatch
(
'
unstageAllChanges
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
stagedFiles
.
length
).
toBe
(
0
);
expect
(
store
.
state
.
changedFiles
[
0
].
staged
).
toBeFalsy
();
done
();
})
.
catch
(
done
.
fail
);
store
.
state
.
changedFiles
.
forEach
(
localFile
=>
{
store
.
state
.
entries
[
localFile
.
path
]
=
localFile
;
}
);
});
it
(
'
removes all files from stagedFiles after unstaging
'
,
done
=>
{
...
...
spec/javascripts/ide/stores/modules/commit/actions_spec.js
View file @
4a4caa01
...
...
@@ -212,14 +212,14 @@ describe('IDE commit module actions', () => {
},
},
};
store
.
state
.
chan
gedFiles
.
push
(
f
,
{
store
.
state
.
sta
gedFiles
.
push
(
f
,
{
...
file
(
'
changedFile2
'
),
changed
:
true
,
});
store
.
state
.
openFiles
=
store
.
state
.
chan
gedFiles
;
store
.
state
.
openFiles
=
store
.
state
.
sta
gedFiles
;
store
.
state
.
changedFiles
.
forEach
(
chan
gedFile
=>
{
store
.
state
.
entries
[
changedFile
.
path
]
=
chan
gedFile
;
store
.
state
.
stagedFiles
.
forEach
(
sta
gedFile
=>
{
store
.
state
.
entries
[
stagedFile
.
path
]
=
sta
gedFile
;
});
});
...
...
@@ -253,19 +253,6 @@ describe('IDE commit module actions', () => {
.
catch
(
done
.
fail
);
});
it
(
'
removes all changed files
'
,
done
=>
{
store
.
dispatch
(
'
commit/updateFilesAfterCommit
'
,
{
data
,
branch
,
})
.
then
(()
=>
{
expect
(
store
.
state
.
changedFiles
.
length
).
toBe
(
0
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
sets files commit data
'
,
done
=>
{
store
.
dispatch
(
'
commit/updateFilesAfterCommit
'
,
{
...
...
@@ -301,7 +288,7 @@ describe('IDE commit module actions', () => {
.
then
(()
=>
{
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
`editor.update.model.content.
${
f
.
path
}
`
,
f
.
content
,
{
content
:
f
.
content
,
changed
:
false
}
,
);
})
.
then
(
done
)
...
...
@@ -485,6 +472,16 @@ describe('IDE commit module actions', () => {
})
.
catch
(
done
.
fail
);
});
it
(
'
removes all staged files
'
,
done
=>
{
store
.
dispatch
(
'
commit/commitChanges
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
stagedFiles
.
length
).
toBe
(
0
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
failed
'
,
()
=>
{
...
...
spec/javascripts/ide/stores/modules/commit/getters_spec.js
View file @
4a4caa01
...
...
@@ -34,17 +34,17 @@ describe('IDE commit module getters', () => {
discardDraftButtonDisabled
:
false
,
};
const
rootState
=
{
chan
gedFiles
:
[
'
a
'
],
sta
gedFiles
:
[
'
a
'
],
};
it
(
'
returns false when discardDraftButtonDisabled is false &
chan
gedFiles is not empty
'
,
()
=>
{
it
(
'
returns false when discardDraftButtonDisabled is false &
sta
gedFiles is not empty
'
,
()
=>
{
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
).
toBeFalsy
();
});
it
(
'
returns true when discardDraftButtonDisabled is false &
chan
gedFiles is empty
'
,
()
=>
{
rootState
.
chan
gedFiles
.
length
=
0
;
it
(
'
returns true when discardDraftButtonDisabled is false &
sta
gedFiles is empty
'
,
()
=>
{
rootState
.
sta
gedFiles
.
length
=
0
;
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
...
...
@@ -61,7 +61,7 @@ describe('IDE commit module getters', () => {
it
(
'
returns true when discardDraftButtonDisabled is false & changedFiles is not empty
'
,
()
=>
{
localGetters
.
discardDraftButtonDisabled
=
false
;
rootState
.
chan
gedFiles
.
length
=
0
;
rootState
.
sta
gedFiles
.
length
=
0
;
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
...
...
spec/javascripts/ide/stores/mutations/file_spec.js
View file @
4a4caa01
...
...
@@ -8,7 +8,10 @@ describe('Multi-file store file mutations', () => {
beforeEach
(()
=>
{
localState
=
state
();
localFile
=
file
();
localFile
=
{
...
file
(),
type
:
'
blob
'
,
};
localState
.
entries
[
localFile
.
path
]
=
localFile
;
});
...
...
@@ -146,37 +149,18 @@ describe('Multi-file store file mutations', () => {
describe
(
'
STAGE_CHANGE
'
,
()
=>
{
it
(
'
adds file into stagedFiles array
'
,
()
=>
{
const
f
=
file
();
mutations
.
STAGE_CHANGE
(
localState
,
f
);
mutations
.
STAGE_CHANGE
(
localState
,
localFile
.
path
);
expect
(
localState
.
stagedFiles
.
length
).
toBe
(
1
);
expect
(
localState
.
stagedFiles
[
0
]).
toEqual
(
f
);
});
it
(
'
updates changedFiles file to staged
'
,
()
=>
{
const
f
=
{
...
file
(),
type
:
'
blob
'
,
staged
:
false
,
};
localState
.
changedFiles
.
push
(
f
);
mutations
.
STAGE_CHANGE
(
localState
,
f
);
expect
(
localState
.
changedFiles
[
0
].
staged
).
toBeTruthy
();
expect
(
localState
.
stagedFiles
[
0
]).
toEqual
(
localFile
);
});
it
(
'
updates stagedFile if it is already staged
'
,
()
=>
{
const
f
=
file
();
f
.
type
=
'
blob
'
;
mutations
.
STAGE_CHANGE
(
localState
,
f
);
mutations
.
STAGE_CHANGE
(
localState
,
localFile
.
path
);
f
.
raw
=
'
testing 123
'
;
localFile
.
raw
=
'
testing 123
'
;
mutations
.
STAGE_CHANGE
(
localState
,
f
);
mutations
.
STAGE_CHANGE
(
localState
,
localFile
.
path
);
expect
(
localState
.
stagedFiles
.
length
).
toBe
(
1
);
expect
(
localState
.
stagedFiles
[
0
].
raw
).
toEqual
(
'
testing 123
'
);
...
...
@@ -195,18 +179,14 @@ describe('Multi-file store file mutations', () => {
localState
.
stagedFiles
.
push
(
f
);
localState
.
changedFiles
.
push
(
f
);
localState
.
entries
[
f
.
path
]
=
f
;
});
it
(
'
removes from stagedFiles array
'
,
()
=>
{
mutations
.
UNSTAGE_CHANGE
(
localState
,
f
);
mutations
.
UNSTAGE_CHANGE
(
localState
,
f
.
path
);
expect
(
localState
.
stagedFiles
.
length
).
toBe
(
0
);
});
it
(
'
updates changedFiles array file to unstaged
'
,
()
=>
{
mutations
.
UNSTAGE_CHANGE
(
localState
,
f
);
expect
(
localState
.
changedFiles
[
0
].
staged
).
toBeFalsy
();
expect
(
localState
.
changedFiles
.
length
).
toBe
(
1
);
});
});
...
...
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