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
Hide 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) => {
...
@@ -142,7 +142,10 @@ export const discardFileChanges = ({ state, commit }, path) => {
commit
(
types
.
TOGGLE_FILE_OPEN
,
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
)
=>
{
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', () => {
...
@@ -13,7 +13,7 @@ describe('IDE stage file button', () => {
f
=
file
();
f
=
file
();
vm
=
createComponentWithStore
(
Component
,
store
,
{
vm
=
createComponentWithStore
(
Component
,
store
,
{
file
:
f
,
path
:
f
.
path
,
});
});
spyOn
(
vm
,
'
stageChange
'
);
spyOn
(
vm
,
'
stageChange
'
);
...
@@ -35,12 +35,12 @@ describe('IDE stage file button', () => {
...
@@ -35,12 +35,12 @@ describe('IDE stage file button', () => {
it
(
'
calls store with stage button
'
,
()
=>
{
it
(
'
calls store with stage button
'
,
()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.btn
'
)[
0
].
click
();
vm
.
$el
.
querySelectorAll
(
'
.btn
'
)[
0
].
click
();
expect
(
vm
.
stageChange
).
toHaveBeenCalledWith
(
f
);
expect
(
vm
.
stageChange
).
toHaveBeenCalledWith
(
f
.
path
);
});
});
it
(
'
calls store with discard button
'
,
()
=>
{
it
(
'
calls store with discard button
'
,
()
=>
{
vm
.
$el
.
querySelectorAll
(
'
.btn
'
)[
1
].
click
();
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', () => {
...
@@ -13,7 +13,7 @@ describe('IDE unstage file button', () => {
f
=
file
();
f
=
file
();
vm
=
createComponentWithStore
(
Component
,
store
,
{
vm
=
createComponentWithStore
(
Component
,
store
,
{
file
:
f
,
path
:
f
.
path
,
});
});
spyOn
(
vm
,
'
unstageChange
'
);
spyOn
(
vm
,
'
unstageChange
'
);
...
@@ -34,6 +34,6 @@ describe('IDE unstage file button', () => {
...
@@ -34,6 +34,6 @@ describe('IDE unstage file button', () => {
it
(
'
calls store with unnstage button
'
,
()
=>
{
it
(
'
calls store with unnstage button
'
,
()
=>
{
vm
.
$el
.
querySelector
(
'
.btn
'
).
click
();
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', () => {
...
@@ -52,6 +52,10 @@ describe('RepoCommitSection', () => {
}),
}),
);
);
vm
.
$store
.
state
.
changedFiles
.
forEach
(
f
=>
{
vm
.
$store
.
state
.
entries
[
f
.
path
]
=
f
;
});
return
vm
.
$mount
();
return
vm
.
$mount
();
}
}
...
...
spec/javascripts/ide/stores/actions_spec.js
View file @
4a4caa01
...
@@ -298,6 +298,10 @@ describe('Multi-file store actions', () => {
...
@@ -298,6 +298,10 @@ describe('Multi-file store actions', () => {
store
.
state
.
changedFiles
.
push
(
f
);
store
.
state
.
changedFiles
.
push
(
f
);
store
.
state
.
changedFiles
.
push
(
file
(
'
new
'
));
store
.
state
.
changedFiles
.
push
(
file
(
'
new
'
));
store
.
state
.
changedFiles
.
forEach
(
localFile
=>
{
store
.
state
.
entries
[
localFile
.
path
]
=
localFile
;
});
store
store
.
dispatch
(
'
stageAllChanges
'
)
.
dispatch
(
'
stageAllChanges
'
)
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -308,23 +312,6 @@ describe('Multi-file store actions', () => {
...
@@ -308,23 +312,6 @@ describe('Multi-file store actions', () => {
})
})
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
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
();
});
done
();
})
.
catch
(
done
.
fail
);
});
});
});
describe
(
'
unstageAllChanges
'
,
()
=>
{
describe
(
'
unstageAllChanges
'
,
()
=>
{
...
@@ -340,20 +327,10 @@ describe('Multi-file store actions', () => {
...
@@ -340,20 +327,10 @@ describe('Multi-file store actions', () => {
store
.
state
.
changedFiles
.
push
({
store
.
state
.
changedFiles
.
push
({
...
f
,
...
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
();
store
.
state
.
changedFiles
.
forEach
(
localFile
=>
{
})
store
.
state
.
entries
[
localFile
.
path
]
=
localFile
;
.
catch
(
done
.
fail
);
}
);
});
});
it
(
'
removes all files from stagedFiles after unstaging
'
,
done
=>
{
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', () => {
...
@@ -212,14 +212,14 @@ describe('IDE commit module actions', () => {
},
},
},
},
};
};
store
.
state
.
chan
gedFiles
.
push
(
f
,
{
store
.
state
.
sta
gedFiles
.
push
(
f
,
{
...
file
(
'
changedFile2
'
),
...
file
(
'
changedFile2
'
),
changed
:
true
,
changed
:
true
,
});
});
store
.
state
.
openFiles
=
store
.
state
.
chan
gedFiles
;
store
.
state
.
openFiles
=
store
.
state
.
sta
gedFiles
;
store
.
state
.
changedFiles
.
forEach
(
chan
gedFile
=>
{
store
.
state
.
stagedFiles
.
forEach
(
sta
gedFile
=>
{
store
.
state
.
entries
[
changedFile
.
path
]
=
chan
gedFile
;
store
.
state
.
entries
[
stagedFile
.
path
]
=
sta
gedFile
;
});
});
});
});
...
@@ -253,19 +253,6 @@ describe('IDE commit module actions', () => {
...
@@ -253,19 +253,6 @@ describe('IDE commit module actions', () => {
.
catch
(
done
.
fail
);
.
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
=>
{
it
(
'
sets files commit data
'
,
done
=>
{
store
store
.
dispatch
(
'
commit/updateFilesAfterCommit
'
,
{
.
dispatch
(
'
commit/updateFilesAfterCommit
'
,
{
...
@@ -301,7 +288,7 @@ describe('IDE commit module actions', () => {
...
@@ -301,7 +288,7 @@ describe('IDE commit module actions', () => {
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
`editor.update.model.content.
${
f
.
path
}
`
,
`editor.update.model.content.
${
f
.
path
}
`
,
f
.
content
,
{
content
:
f
.
content
,
changed
:
false
}
,
);
);
})
})
.
then
(
done
)
.
then
(
done
)
...
@@ -485,6 +472,16 @@ describe('IDE commit module actions', () => {
...
@@ -485,6 +472,16 @@ describe('IDE commit module actions', () => {
})
})
.
catch
(
done
.
fail
);
.
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
'
,
()
=>
{
describe
(
'
failed
'
,
()
=>
{
...
...
spec/javascripts/ide/stores/modules/commit/getters_spec.js
View file @
4a4caa01
...
@@ -34,17 +34,17 @@ describe('IDE commit module getters', () => {
...
@@ -34,17 +34,17 @@ describe('IDE commit module getters', () => {
discardDraftButtonDisabled
:
false
,
discardDraftButtonDisabled
:
false
,
};
};
const
rootState
=
{
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
(
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
).
toBeFalsy
();
).
toBeFalsy
();
});
});
it
(
'
returns true when discardDraftButtonDisabled is false &
chan
gedFiles is empty
'
,
()
=>
{
it
(
'
returns true when discardDraftButtonDisabled is false &
sta
gedFiles is empty
'
,
()
=>
{
rootState
.
chan
gedFiles
.
length
=
0
;
rootState
.
sta
gedFiles
.
length
=
0
;
expect
(
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
...
@@ -61,7 +61,7 @@ describe('IDE commit module getters', () => {
...
@@ -61,7 +61,7 @@ describe('IDE commit module getters', () => {
it
(
'
returns true when discardDraftButtonDisabled is false & changedFiles is not empty
'
,
()
=>
{
it
(
'
returns true when discardDraftButtonDisabled is false & changedFiles is not empty
'
,
()
=>
{
localGetters
.
discardDraftButtonDisabled
=
false
;
localGetters
.
discardDraftButtonDisabled
=
false
;
rootState
.
chan
gedFiles
.
length
=
0
;
rootState
.
sta
gedFiles
.
length
=
0
;
expect
(
expect
(
getters
.
commitButtonDisabled
(
state
,
localGetters
,
rootState
),
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', () => {
...
@@ -8,7 +8,10 @@ describe('Multi-file store file mutations', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
localState
=
state
();
localState
=
state
();
localFile
=
file
();
localFile
=
{
...
file
(),
type
:
'
blob
'
,
};
localState
.
entries
[
localFile
.
path
]
=
localFile
;
localState
.
entries
[
localFile
.
path
]
=
localFile
;
});
});
...
@@ -146,37 +149,18 @@ describe('Multi-file store file mutations', () => {
...
@@ -146,37 +149,18 @@ describe('Multi-file store file mutations', () => {
describe
(
'
STAGE_CHANGE
'
,
()
=>
{
describe
(
'
STAGE_CHANGE
'
,
()
=>
{
it
(
'
adds file into stagedFiles array
'
,
()
=>
{
it
(
'
adds file into stagedFiles array
'
,
()
=>
{
const
f
=
file
();
mutations
.
STAGE_CHANGE
(
localState
,
localFile
.
path
);
mutations
.
STAGE_CHANGE
(
localState
,
f
);
expect
(
localState
.
stagedFiles
.
length
).
toBe
(
1
);
expect
(
localState
.
stagedFiles
.
length
).
toBe
(
1
);
expect
(
localState
.
stagedFiles
[
0
]).
toEqual
(
f
);
expect
(
localState
.
stagedFiles
[
0
]).
toEqual
(
localFile
);
});
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
();
});
});
it
(
'
updates stagedFile if it is already staged
'
,
()
=>
{
it
(
'
updates stagedFile if it is already staged
'
,
()
=>
{
const
f
=
file
();
mutations
.
STAGE_CHANGE
(
localState
,
localFile
.
path
);
f
.
type
=
'
blob
'
;
mutations
.
STAGE_CHANGE
(
localState
,
f
)
;
localFile
.
raw
=
'
testing 123
'
;
f
.
raw
=
'
testing 123
'
;
mutations
.
STAGE_CHANGE
(
localState
,
localFile
.
path
);
mutations
.
STAGE_CHANGE
(
localState
,
f
);
expect
(
localState
.
stagedFiles
.
length
).
toBe
(
1
);
expect
(
localState
.
stagedFiles
.
length
).
toBe
(
1
);
expect
(
localState
.
stagedFiles
[
0
].
raw
).
toEqual
(
'
testing 123
'
);
expect
(
localState
.
stagedFiles
[
0
].
raw
).
toEqual
(
'
testing 123
'
);
...
@@ -195,18 +179,14 @@ describe('Multi-file store file mutations', () => {
...
@@ -195,18 +179,14 @@ describe('Multi-file store file mutations', () => {
localState
.
stagedFiles
.
push
(
f
);
localState
.
stagedFiles
.
push
(
f
);
localState
.
changedFiles
.
push
(
f
);
localState
.
changedFiles
.
push
(
f
);
localState
.
entries
[
f
.
path
]
=
f
;
});
});
it
(
'
removes from stagedFiles array
'
,
()
=>
{
it
(
'
removes from stagedFiles array
'
,
()
=>
{
mutations
.
UNSTAGE_CHANGE
(
localState
,
f
);
mutations
.
UNSTAGE_CHANGE
(
localState
,
f
.
path
);
expect
(
localState
.
stagedFiles
.
length
).
toBe
(
0
);
expect
(
localState
.
stagedFiles
.
length
).
toBe
(
0
);
});
expect
(
localState
.
changedFiles
.
length
).
toBe
(
1
);
it
(
'
updates changedFiles array file to unstaged
'
,
()
=>
{
mutations
.
UNSTAGE_CHANGE
(
localState
,
f
);
expect
(
localState
.
changedFiles
[
0
].
staged
).
toBeFalsy
();
});
});
});
});
...
...
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