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
093e43a0
Commit
093e43a0
authored
Jun 26, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✅
store specs
parent
93e5d8c7
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
2 deletions
+109
-2
app/assets/javascripts/ide/stores/actions/project.js
app/assets/javascripts/ide/stores/actions/project.js
+2
-1
spec/javascripts/ide/stores/actions/project_spec.js
spec/javascripts/ide/stores/actions/project_spec.js
+85
-1
spec/javascripts/ide/stores/actions_spec.js
spec/javascripts/ide/stores/actions_spec.js
+14
-0
spec/javascripts/ide/stores/mutations_spec.js
spec/javascripts/ide/stores/mutations_spec.js
+8
-0
No files found.
app/assets/javascripts/ide/stores/actions/project.js
View file @
093e43a0
...
...
@@ -4,6 +4,7 @@ import { __, sprintf } from '~/locale';
import
service
from
'
../../services
'
;
import
api
from
'
../../../api
'
;
import
*
as
types
from
'
../mutation_types
'
;
import
{
refreshCurrentPage
}
from
'
../../../lib/utils/url_utility
'
;
export
const
getProjectData
=
({
commit
,
state
},
{
namespace
,
projectId
,
force
=
false
}
=
{})
=>
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -97,7 +98,7 @@ export const createNewBranchFromDefault = ({ state, getters }, branch) =>
branch
,
})
.
then
(()
=>
{
window
.
location
.
reload
();
refreshCurrentPage
();
// this forces the loading icon to spin whilst the page is reloading
return
new
Promise
(()
=>
{});
...
...
spec/javascripts/ide/stores/actions/project_spec.js
View file @
093e43a0
import
{
refreshLastCommitData
}
from
'
~/ide/stores/actions
'
;
import
{
refreshLastCommitData
,
showBranchNotFoundError
,
createNewBranchFromDefault
,
}
from
'
~/ide/stores/actions
'
;
import
store
from
'
~/ide/stores
'
;
import
projectActions
from
'
~/ide/stores/actions/project
'
;
import
service
from
'
~/ide/services
'
;
import
api
from
'
~/api
'
;
import
{
resetStore
}
from
'
../../helpers
'
;
import
testAction
from
'
../../../helpers/vuex_action_helper
'
;
...
...
@@ -80,4 +86,82 @@ describe('IDE store project actions', () => {
);
});
});
describe
(
'
showBranchNotFoundError
'
,
()
=>
{
it
(
'
dispatches setErrorMessage
'
,
done
=>
{
testAction
(
showBranchNotFoundError
,
'
master
'
,
null
,
[],
[
{
type
:
'
setErrorMessage
'
,
payload
:
{
text
:
"
Branch <strong>master</strong> was not found in this project's repository.
"
,
action
:
'
createNewBranchFromDefault
'
,
actionText
:
'
Create branch
'
,
actionPayload
:
'
master
'
,
},
},
],
done
,
);
});
});
describe
(
'
createNewBranchFromDefault
'
,
()
=>
{
it
(
'
calls API
'
,
done
=>
{
spyOn
(
api
,
'
createBranch
'
).
and
.
returnValue
(
Promise
.
resolve
());
spyOnDependency
(
projectActions
,
'
refreshCurrentPage
'
);
createNewBranchFromDefault
(
{
state
:
{
currentProjectId
:
'
project-path
'
,
},
getters
:
{
currentProject
:
{
default_branch
:
'
master
'
,
},
},
},
'
new-branch-name
'
,
);
setTimeout
(()
=>
{
expect
(
api
.
createBranch
).
toHaveBeenCalledWith
(
'
project-path
'
,
{
ref
:
'
master
'
,
branch
:
'
new-branch-name
'
,
});
done
();
});
});
it
(
'
reloads window
'
,
done
=>
{
spyOn
(
api
,
'
createBranch
'
).
and
.
returnValue
(
Promise
.
resolve
());
const
refreshSpy
=
spyOnDependency
(
projectActions
,
'
refreshCurrentPage
'
);
createNewBranchFromDefault
(
{
state
:
{
currentProjectId
:
'
project-path
'
,
},
getters
:
{
currentProject
:
{
default_branch
:
'
master
'
,
},
},
},
'
new-branch-name
'
,
);
setTimeout
(()
=>
{
expect
(
refreshSpy
).
toHaveBeenCalled
();
done
();
});
});
});
});
spec/javascripts/ide/stores/actions_spec.js
View file @
093e43a0
...
...
@@ -6,6 +6,7 @@ import actions, {
setEmptyStateSvgs
,
updateActivityBarView
,
updateTempFlagForEntry
,
setErrorMessage
,
}
from
'
~/ide/stores/actions
'
;
import
store
from
'
~/ide/stores
'
;
import
*
as
types
from
'
~/ide/stores/mutation_types
'
;
...
...
@@ -443,4 +444,17 @@ describe('Multi-file store actions', () => {
);
});
});
describe
(
'
setErrorMessage
'
,
()
=>
{
it
(
'
commis error messsage
'
,
done
=>
{
testAction
(
setErrorMessage
,
'
error
'
,
null
,
[{
type
:
types
.
SET_ERROR_MESSAGE
,
payload
:
'
error
'
}],
[],
done
,
);
});
});
});
spec/javascripts/ide/stores/mutations_spec.js
View file @
093e43a0
...
...
@@ -148,4 +148,12 @@ describe('Multi-file store mutations', () => {
expect
(
localState
.
unusedSeal
).
toBe
(
false
);
});
});
describe
(
'
SET_ERROR_MESSAGE
'
,
()
=>
{
it
(
'
updates error message
'
,
()
=>
{
mutations
.
SET_ERROR_MESSAGE
(
localState
,
'
error
'
);
expect
(
localState
.
errorMessage
).
toBe
(
'
error
'
);
});
});
});
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