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
3abceda6
Commit
3abceda6
authored
Aug 02, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Improve repo_commit_section_spec
parent
4402eefa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
app/assets/javascripts/repo/repo_commit_section.vue
app/assets/javascripts/repo/repo_commit_section.vue
+1
-1
spec/javascripts/repo/repo_commit_section_spec.js
spec/javascripts/repo/repo_commit_section_spec.js
+17
-6
No files found.
app/assets/javascripts/repo/repo_commit_section.vue
View file @
3abceda6
...
@@ -77,7 +77,7 @@ export default RepoCommitSection;
...
@@ -77,7 +77,7 @@ export default RepoCommitSection;
</div>
</div>
<!-- Button Drop Down
<!-- Button Drop Down
-->
-->
<div
class=
"form-group"
>
<div
class=
"form-group
target-branch
"
>
<label
class=
"col-md-4 control-label"
for=
"target-branch"
>
Target branch
</label>
<label
class=
"col-md-4 control-label"
for=
"target-branch"
>
Target branch
</label>
<div
class=
"col-md-4"
>
<div
class=
"col-md-4"
>
<span
class=
"help-block"
>
{{
targetBranch
}}
</span>
<span
class=
"help-block"
>
{{
targetBranch
}}
</span>
...
...
spec/javascripts/repo/repo_commit_section_spec.js
View file @
3abceda6
...
@@ -5,21 +5,21 @@ import RepoHelper from '~/repo/repo_helper';
...
@@ -5,21 +5,21 @@ import RepoHelper from '~/repo/repo_helper';
import
Api
from
'
~/api
'
;
import
Api
from
'
~/api
'
;
fdescribe
(
'
RepoCommitSection
'
,
()
=>
{
fdescribe
(
'
RepoCommitSection
'
,
()
=>
{
const
branch
=
'
master
'
;
const
openedFiles
=
[{
const
openedFiles
=
[{
id
:
0
,
id
:
0
,
changed
:
true
,
changed
:
true
,
url
:
'
master/url0
'
,
url
:
`
${
branch
}
/url0`
,
newContent
:
'
a
'
,
newContent
:
'
a
'
,
},
{
},
{
id
:
1
,
id
:
1
,
changed
:
true
,
changed
:
true
,
url
:
'
master/url1
'
,
url
:
`
${
branch
}
/url1`
,
newContent
:
'
b
'
,
newContent
:
'
b
'
,
},
{
},
{
id
:
2
,
id
:
2
,
changed
:
false
,
changed
:
false
,
}];
}];
const
branch
=
'
master
'
;
function
createComponent
()
{
function
createComponent
()
{
const
RepoCommitSection
=
Vue
.
extend
(
repoCommitSection
);
const
RepoCommitSection
=
Vue
.
extend
(
repoCommitSection
);
...
@@ -29,13 +29,16 @@ fdescribe('RepoCommitSection', () => {
...
@@ -29,13 +29,16 @@ fdescribe('RepoCommitSection', () => {
it
(
'
renders a commit section
'
,
()
=>
{
it
(
'
renders a commit section
'
,
()
=>
{
RepoStore
.
isCommitable
=
true
;
RepoStore
.
isCommitable
=
true
;
RepoStore
.
targetBranch
=
branch
;
RepoStore
.
openedFiles
=
openedFiles
;
RepoStore
.
openedFiles
=
openedFiles
;
spyOn
(
RepoHelper
,
'
getBranch
'
).
and
.
returnValue
(
branch
);
spyOn
(
RepoHelper
,
'
getBranch
'
).
and
.
returnValue
(
branch
);
const
vm
=
createComponent
();
const
vm
=
createComponent
();
const
changedFiles
=
[...
vm
.
$el
.
querySelectorAll
(
'
.changed-files > li
'
)];
const
changedFiles
=
[...
vm
.
$el
.
querySelectorAll
(
'
.changed-files > li
'
)];
const
commitMessage
=
vm
.
$el
.
querySelector
(
'
#commit-message
'
);
const
commitMessage
=
vm
.
$el
.
querySelector
(
'
#commit-message
'
);
const
submitCommit
=
vm
.
$el
.
querySelector
(
'
.submit-commit
'
);
const
submitCommit
=
vm
.
$el
.
querySelector
(
'
.submit-commit
'
);
const
targetBranch
=
vm
.
$el
.
querySelector
(
'
.target-branch
'
);
expect
(
vm
.
$el
.
querySelector
(
'
:scope > form
'
)).
toBeTruthy
();
expect
(
vm
.
$el
.
querySelector
(
'
:scope > form
'
)).
toBeTruthy
();
expect
(
vm
.
$el
.
querySelector
(
'
.staged-files
'
).
textContent
).
toEqual
(
'
Staged files (2)
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.staged-files
'
).
textContent
).
toEqual
(
'
Staged files (2)
'
);
...
@@ -51,7 +54,10 @@ fdescribe('RepoCommitSection', () => {
...
@@ -51,7 +54,10 @@ fdescribe('RepoCommitSection', () => {
expect
(
commitMessage
.
name
).
toEqual
(
'
commit-message
'
);
expect
(
commitMessage
.
name
).
toEqual
(
'
commit-message
'
);
expect
(
submitCommit
.
type
).
toEqual
(
'
submit
'
);
expect
(
submitCommit
.
type
).
toEqual
(
'
submit
'
);
expect
(
submitCommit
.
disabled
).
toBeTruthy
();
expect
(
submitCommit
.
disabled
).
toBeTruthy
();
expect
(
submitCommit
.
querySelector
(
'
.fa-spinner.fa-spin
'
)).
toBeFalsy
();
expect
(
vm
.
$el
.
querySelector
(
'
.commit-summary
'
).
textContent
).
toEqual
(
'
Commit 2 files
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.commit-summary
'
).
textContent
).
toEqual
(
'
Commit 2 files
'
);
expect
(
targetBranch
.
querySelector
(
'
:scope > label
'
).
textContent
).
toEqual
(
'
Target branch
'
);
expect
(
targetBranch
.
querySelector
(
'
.help-block
'
).
textContent
).
toEqual
(
branch
);
});
});
it
(
'
does not render if not isCommitable
'
,
()
=>
{
it
(
'
does not render if not isCommitable
'
,
()
=>
{
...
@@ -82,6 +88,8 @@ fdescribe('RepoCommitSection', () => {
...
@@ -82,6 +88,8 @@ fdescribe('RepoCommitSection', () => {
RepoStore
.
openedFiles
=
openedFiles
;
RepoStore
.
openedFiles
=
openedFiles
;
RepoStore
.
projectId
=
projectId
;
RepoStore
.
projectId
=
projectId
;
spyOn
(
RepoHelper
,
'
getBranch
'
).
and
.
returnValue
(
branch
);
const
vm
=
createComponent
();
const
vm
=
createComponent
();
const
commitMessageEl
=
vm
.
$el
.
querySelector
(
'
#commit-message
'
);
const
commitMessageEl
=
vm
.
$el
.
querySelector
(
'
#commit-message
'
);
const
submitCommit
=
vm
.
$el
.
querySelector
(
'
.submit-commit
'
);
const
submitCommit
=
vm
.
$el
.
querySelector
(
'
.submit-commit
'
);
...
@@ -102,15 +110,18 @@ fdescribe('RepoCommitSection', () => {
...
@@ -102,15 +110,18 @@ fdescribe('RepoCommitSection', () => {
expect
(
submitCommit
.
querySelector
(
'
.fa-spinner.fa-spin
'
)).
toBeTruthy
();
expect
(
submitCommit
.
querySelector
(
'
.fa-spinner.fa-spin
'
)).
toBeTruthy
();
const
args
=
Api
.
commitMultiple
.
calls
.
allArgs
()[
0
];
const
args
=
Api
.
commitMultiple
.
calls
.
allArgs
()[
0
];
const
{
commit_message
,
actions
}
=
args
[
1
];
const
{
commit_message
,
actions
,
branch
:
payloadBranch
}
=
args
[
1
];
expect
(
args
[
0
]).
toBe
(
projectId
);
expect
(
args
[
0
]).
toBe
(
projectId
);
expect
(
commit_message
).
toBe
(
commitMessage
);
expect
(
commit_message
).
toBe
(
commitMessage
);
expect
(
actions
.
length
).
toEqual
(
2
);
expect
(
actions
.
length
).
toEqual
(
2
);
expect
(
payloadBranch
).
toEqual
(
branch
);
expect
(
actions
[
0
].
action
).
toEqual
(
'
update
'
);
expect
(
actions
[
0
].
action
).
toEqual
(
'
update
'
);
expect
(
actions
[
1
].
action
).
toEqual
(
'
update
'
);
expect
(
actions
[
1
].
action
).
toEqual
(
'
update
'
);
expect
(
actions
[
0
].
content
).
toEqual
(
'
a
'
);
expect
(
actions
[
0
].
content
).
toEqual
(
openedFiles
[
0
].
newContent
);
expect
(
actions
[
1
].
content
).
toEqual
(
'
b
'
);
expect
(
actions
[
1
].
content
).
toEqual
(
openedFiles
[
1
].
newContent
);
expect
(
actions
[
0
].
file_path
).
toEqual
(
RepoHelper
.
getFilePathFromFullPath
(
openedFiles
[
0
].
url
,
branch
));
expect
(
actions
[
1
].
file_path
).
toEqual
(
RepoHelper
.
getFilePathFromFullPath
(
openedFiles
[
1
].
url
,
branch
));
done
();
done
();
});
});
...
...
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