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
76152c0f
Commit
76152c0f
authored
Nov 10, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added missing specs
parent
dfe0ad2d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
212 additions
and
1 deletion
+212
-1
app/assets/javascripts/repo/stores/actions.js
app/assets/javascripts/repo/stores/actions.js
+1
-1
spec/javascripts/repo/stores/actions_spec.js
spec/javascripts/repo/stores/actions_spec.js
+211
-0
No files found.
app/assets/javascripts/repo/stores/actions.js
View file @
76152c0f
...
...
@@ -84,7 +84,7 @@ export const commitChanges = ({ commit, state, dispatch, getters }, { payload, n
flash
(
`Your changes have been committed. Commit
${
data
.
short_id
}
with
${
data
.
stats
.
additions
}
additions,
${
data
.
stats
.
deletions
}
deletions.`
,
'
notice
'
);
if
(
newMr
)
{
redirectToUrl
(
`
${
state
.
endpoints
.
newMergeRequestUrl
}${
branch
}
`
);
dispatch
(
'
redirectToUrl
'
,
`
${
state
.
endpoints
.
newMergeRequestUrl
}${
branch
}
`
);
}
else
{
commit
(
types
.
SET_COMMIT_REF
,
data
.
id
);
...
...
spec/javascripts/repo/stores/actions_spec.js
View file @
76152c0f
import
Vue
from
'
vue
'
;
import
store
from
'
~/repo/stores
'
;
import
service
from
'
~/repo/services
'
;
import
{
resetStore
,
file
}
from
'
../helpers
'
;
...
...
@@ -69,7 +70,72 @@ describe('Multi-file store actions', () => {
});
describe
(
'
toggleEditMode
'
,
()
=>
{
it
(
'
toggles edit mode
'
,
(
done
)
=>
{
store
.
state
.
editMode
=
true
;
store
.
dispatch
(
'
toggleEditMode
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
editMode
).
toBeFalsy
();
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
sets preview mode
'
,
(
done
)
=>
{
store
.
state
.
currentBlobView
=
'
repo-editor
'
;
store
.
state
.
editMode
=
true
;
store
.
dispatch
(
'
toggleEditMode
'
)
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
expect
(
store
.
state
.
currentBlobView
).
toBe
(
'
repo-preview
'
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
opens discard popup if there are changed files
'
,
(
done
)
=>
{
store
.
state
.
editMode
=
true
;
store
.
state
.
openFiles
.
push
(
file
());
store
.
state
.
openFiles
[
0
].
changed
=
true
;
store
.
dispatch
(
'
toggleEditMode
'
)
.
then
(()
=>
{
expect
(
store
.
state
.
discardPopupOpen
).
toBeTruthy
();
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
can force closed if there are changed files
'
,
(
done
)
=>
{
store
.
state
.
editMode
=
true
;
store
.
state
.
openFiles
.
push
(
file
());
store
.
state
.
openFiles
[
0
].
changed
=
true
;
store
.
dispatch
(
'
toggleEditMode
'
,
true
)
.
then
(()
=>
{
expect
(
store
.
state
.
discardPopupOpen
).
toBeFalsy
();
expect
(
store
.
state
.
editMode
).
toBeFalsy
();
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
discards file changes
'
,
(
done
)
=>
{
const
f
=
file
();
store
.
state
.
editMode
=
true
;
store
.
state
.
tree
.
push
(
f
);
store
.
state
.
openFiles
.
push
(
f
);
f
.
changed
=
true
;
store
.
dispatch
(
'
toggleEditMode
'
,
true
)
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
expect
(
f
.
changed
).
toBeFalsy
();
done
();
}).
catch
(
done
.
fail
);
});
});
describe
(
'
toggleBlobView
'
,
()
=>
{
...
...
@@ -147,7 +213,152 @@ describe('Multi-file store actions', () => {
});
describe
(
'
commitChanges
'
,
()
=>
{
let
payload
;
beforeEach
(()
=>
{
spyOn
(
window
,
'
scrollTo
'
);
document
.
body
.
innerHTML
+=
'
<div class="flash-container"></div>
'
;
store
.
state
.
project
.
id
=
123
;
payload
=
{
branch
:
'
master
'
,
};
});
afterEach
(()
=>
{
document
.
querySelector
(
'
.flash-container
'
).
remove
();
});
describe
(
'
success
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'
commit
'
).
and
.
returnValue
(
Promise
.
resolve
({
id
:
'
123456
'
,
short_id
:
'
123
'
,
message
:
'
test message
'
,
committed_date
:
'
date
'
,
stats
:
{
additions
:
'
1
'
,
deletions
:
'
2
'
,
},
}));
});
it
(
'
calls service
'
,
(
done
)
=>
{
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
expect
(
service
.
commit
).
toHaveBeenCalledWith
(
123
,
payload
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
shows flash notice
'
,
(
done
)
=>
{
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
const
alert
=
document
.
querySelector
(
'
.flash-container
'
);
expect
(
alert
.
querySelector
(
'
.flash-notice
'
)).
not
.
toBeNull
();
expect
(
alert
.
textContent
.
trim
()).
toBe
(
'
Your changes have been committed. Commit 123 with 1 additions, 2 deletions.
'
,
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
adds commit data to changed files
'
,
(
done
)
=>
{
const
changedFile
=
file
();
const
f
=
file
();
changedFile
.
changed
=
true
;
store
.
state
.
openFiles
.
push
(
changedFile
,
f
);
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
expect
(
changedFile
.
lastCommit
.
message
).
toBe
(
'
test message
'
);
expect
(
f
.
lastCommit
.
message
).
not
.
toBe
(
'
test message
'
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
toggles edit mode
'
,
(
done
)
=>
{
store
.
state
.
editMode
=
true
;
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
expect
(
store
.
state
.
editMode
).
toBeFalsy
();
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
closes all files
'
,
(
done
)
=>
{
store
.
state
.
openFiles
.
push
(
file
());
store
.
state
.
openFiles
[
0
].
opened
=
true
;
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
expect
(
store
.
state
.
openFiles
.
length
).
toBe
(
0
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
scrolls to top of page
'
,
(
done
)
=>
{
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
expect
(
window
.
scrollTo
).
toHaveBeenCalledWith
(
0
,
0
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
updates commit ref
'
,
(
done
)
=>
{
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
expect
(
store
.
state
.
currentRef
).
toBe
(
'
123456
'
);
done
();
}).
catch
(
done
.
fail
);
});
it
(
'
redirects to new merge request page
'
,
(
done
)
=>
{
spyOn
(
gl
.
utils
,
'
visitUrl
'
);
store
.
state
.
endpoints
.
newMergeRequestUrl
=
'
newMergeRequestUrl?branch=
'
;
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
true
})
.
then
(()
=>
{
expect
(
gl
.
utils
.
visitUrl
).
toHaveBeenCalledWith
(
'
newMergeRequestUrl?branch=master
'
);
done
();
}).
catch
(
done
.
fail
);
});
});
describe
(
'
failed
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
service
,
'
commit
'
).
and
.
returnValue
(
Promise
.
resolve
({
message
:
'
failed message
'
,
}));
});
it
(
'
shows failed message
'
,
(
done
)
=>
{
store
.
dispatch
(
'
commitChanges
'
,
{
payload
,
newMr
:
false
})
.
then
(()
=>
{
const
alert
=
document
.
querySelector
(
'
.flash-container
'
);
expect
(
alert
.
textContent
.
trim
()).
toBe
(
'
failed message
'
,
);
done
();
}).
catch
(
done
.
fail
);
});
});
});
describe
(
'
createTempEntry
'
,
()
=>
{
...
...
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