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
f9935aab
Commit
f9935aab
authored
Feb 14, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed repo_commit_section specs
parent
85ec068e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
47 deletions
+38
-47
app/assets/javascripts/ide/stores/modules/commit/actions.js
app/assets/javascripts/ide/stores/modules/commit/actions.js
+2
-4
spec/javascripts/repo/components/repo_commit_section_spec.js
spec/javascripts/repo/components/repo_commit_section_spec.js
+32
-43
spec/javascripts/repo/helpers.js
spec/javascripts/repo/helpers.js
+4
-0
No files found.
app/assets/javascripts/ide/stores/modules/commit/actions.js
View file @
f9935aab
...
...
@@ -41,7 +41,7 @@ export const checkCommitStatus = ({ rootState }) =>
export
const
updateFilesAfterCommit
=
(
{
commit
,
dispatch
,
state
,
rootState
,
rootGetters
},
{
data
,
branch
},
{
data
},
)
=>
{
const
selectedProject
=
rootState
.
projects
[
rootState
.
currentProjectId
];
const
lastCommit
=
{
...
...
@@ -82,9 +82,7 @@ export const updateFilesAfterCommit = (
commit
(
rootTypes
.
REMOVE_ALL_CHANGES_FILES
,
null
,
{
root
:
true
});
if
(
state
.
commitAction
===
consts
.
COMMIT_TO_NEW_BRANCH
)
{
const
fileUrl
=
rootGetters
.
activeFile
.
url
.
replace
(
rootState
.
currentBranchId
,
branch
);
router
.
push
(
`/project
${
fileUrl
}
`
);
router
.
push
(
`/project/
${
rootState
.
currentProjectId
}
/blob/branch/
${
rootGetters
.
activeFile
.
path
}
`
);
}
window
.
scrollTo
(
0
,
0
);
...
...
spec/javascripts/repo/components/repo_commit_section_spec.js
View file @
f9935aab
import
Vue
from
'
vue
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
store
from
'
~/ide/stores
'
;
import
service
from
'
~/ide/services
'
;
import
repoCommitSection
from
'
~/ide/components/repo_commit_section.vue
'
;
...
...
@@ -76,8 +75,6 @@ describe('RepoCommitSection', () => {
committedStateSvgPath
:
'
svg
'
,
}).
$mount
();
// Vue.nextTick();
expect
(
vm
.
$el
.
querySelector
(
'
.js-empty-state
'
).
textContent
.
trim
()).
toContain
(
'
No changes
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-empty-state img
'
).
getAttribute
(
'
src
'
)).
toBe
(
'
nochangessvg
'
);
});
...
...
@@ -98,62 +95,54 @@ describe('RepoCommitSection', () => {
expect
(
submitCommit
.
querySelector
(
'
.fa-spinner.fa-spin
'
)).
toBeNull
();
});
describe
(
'
when submitting
'
,
(
)
=>
{
let
changedFiles
;
it
(
'
updates commitMessage in store on input
'
,
(
done
)
=>
{
const
textarea
=
vm
.
$el
.
querySelector
(
'
textarea
'
)
;
beforeEach
(()
=>
{
vm
.
commitMessage
=
'
testing
'
;
changedFiles
=
JSON
.
parse
(
JSON
.
stringify
(
vm
.
$store
.
state
.
changedFiles
));
textarea
.
value
=
'
testing commit message
'
;
spyOn
(
service
,
'
commit
'
).
and
.
returnValue
(
Promise
.
resolve
({
data
:
{
short_id
:
'
1
'
,
stats
:
{},
},
}));
});
textarea
.
dispatchEvent
(
new
Event
(
'
input
'
));
getSetTimeoutPromise
()
.
then
(()
=>
{
expect
(
vm
.
$store
.
state
.
commit
.
commitMessage
).
toBe
(
'
testing commit message
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
allows you to submit
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
form .btn
'
).
disabled
).
toBeTruthy
();
describe
(
'
discard draft button
'
,
()
=>
{
it
(
'
disabled when commitMessage is empty
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.multi-file-commit-form .btn-default
'
).
getAttribute
(
'
disabled
'
)).
not
.
toBeNull
();
});
it
(
'
submits commit
'
,
(
done
)
=>
{
vm
.
makeCommit
()
;
it
(
'
resets commitMessage when clicking discard button
'
,
(
done
)
=>
{
vm
.
$store
.
state
.
commitMessage
=
'
testinig commit message
'
;
// Wait for the branch check to finish
getSetTimeoutPromise
()
.
then
(()
=>
Vue
.
nextTick
())
.
then
(()
=>
{
const
args
=
service
.
commit
.
calls
.
allArgs
()[
0
];
const
{
commit_message
,
actions
,
branch
:
payloadBranch
}
=
args
[
1
];
expect
(
commit_message
).
toBe
(
'
testing
'
);
expect
(
actions
.
length
).
toEqual
(
2
);
expect
(
payloadBranch
).
toEqual
(
'
master
'
);
expect
(
actions
[
0
].
action
).
toEqual
(
'
update
'
);
expect
(
actions
[
1
].
action
).
toEqual
(
'
update
'
);
expect
(
actions
[
0
].
content
).
toEqual
(
changedFiles
[
0
].
content
);
expect
(
actions
[
1
].
content
).
toEqual
(
changedFiles
[
1
].
content
);
expect
(
actions
[
0
].
file_path
).
toEqual
(
changedFiles
[
0
].
path
);
expect
(
actions
[
1
].
file_path
).
toEqual
(
changedFiles
[
1
].
path
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-empty-state
'
).
textContent
.
trim
()).
toContain
(
'
All changes are committed
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-empty-state img
'
).
getAttribute
(
'
src
'
)).
toBe
(
'
commitsvg
'
);
vm
.
$el
.
querySelector
(
'
.multi-file-commit-form .btn-default
'
).
click
();
})
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
expect
(
vm
.
$store
.
state
.
commit
.
commitMessage
).
not
.
toBe
(
'
testing commit message
'
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
redirects to MR creation page if start new MR checkbox checked
'
,
(
done
)
=>
{
spyOn
(
urlUtils
,
'
visitUrl
'
);
vm
.
startNewMR
=
true
;
describe
(
'
when submitting
'
,
()
=>
{
beforeEach
(()
=>
{
vm
.
$store
.
state
.
commitMessage
=
'
testing
'
;
});
vm
.
makeCommit
();
it
(
'
calls store
'
,
(
done
)
=>
{
spyOn
(
vm
,
'
commitChanges
'
);
vm
.
$el
.
querySelector
(
'
.multi-file-commit-form .btn-success
'
).
click
();
getSetTimeoutPromise
()
.
then
(()
=>
Vue
.
nextTick
())
Vue
.
nextTick
()
.
then
(()
=>
{
expect
(
urlUtils
.
visitUrl
).
toHaveBeenCalled
();
expect
(
vm
.
commitChanges
).
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
spec/javascripts/repo/helpers.js
View file @
f9935aab
import
{
decorateData
}
from
'
~/ide/stores/utils
'
;
import
state
from
'
~/ide/stores/state
'
;
import
commitState
from
'
~/ide/stores/modules/commit/state
'
;
export
const
resetStore
=
(
store
)
=>
{
store
.
replaceState
(
state
());
Object
.
assign
(
store
.
state
,
{
commit
:
commitState
(),
});
};
export
const
file
=
(
name
=
'
name
'
,
id
=
name
,
type
=
''
)
=>
decorateData
({
...
...
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