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
7896f605
Commit
7896f605
authored
Jul 20, 2020
by
Nathan Friend
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix v-model support in ref selector component
Updates the ref selector component to properly implement v-model.
parent
a6875e5f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
app/assets/javascripts/ref/components/ref_selector.vue
app/assets/javascripts/ref/components/ref_selector.vue
+12
-0
spec/frontend/ref/components/ref_selector_spec.js
spec/frontend/ref/components/ref_selector_spec.js
+34
-1
No files found.
app/assets/javascripts/ref/components/ref_selector.vue
View file @
7896f605
...
@@ -74,6 +74,18 @@ export default {
...
@@ -74,6 +74,18 @@ export default {
return
!
this
.
showBranchesSection
&&
!
this
.
showTagsSection
&&
!
this
.
showCommitsSection
;
return
!
this
.
showBranchesSection
&&
!
this
.
showTagsSection
&&
!
this
.
showCommitsSection
;
},
},
},
},
watch
:
{
// Keep the Vuex store synchronized if the parent
// component updates the selected ref through v-model
value
:
{
immediate
:
true
,
handler
()
{
if
(
this
.
value
!==
this
.
selectedRef
)
{
this
.
setSelectedRef
(
this
.
value
);
}
},
},
},
created
()
{
created
()
{
this
.
setProjectId
(
this
.
projectId
);
this
.
setProjectId
(
this
.
projectId
);
this
.
search
(
this
.
query
);
this
.
search
(
this
.
query
);
...
...
spec/frontend/ref/components/ref_selector_spec.js
View file @
7896f605
...
@@ -26,11 +26,12 @@ describe('Ref selector component', () => {
...
@@ -26,11 +26,12 @@ describe('Ref selector component', () => {
let
tagsApiCallSpy
;
let
tagsApiCallSpy
;
let
commitApiCallSpy
;
let
commitApiCallSpy
;
const
createComponent
=
()
=>
{
const
createComponent
=
(
props
=
{}
)
=>
{
wrapper
=
mount
(
RefSelector
,
{
wrapper
=
mount
(
RefSelector
,
{
propsData
:
{
propsData
:
{
projectId
,
projectId
,
value
:
''
,
value
:
''
,
...
props
,
},
},
listeners
:
{
listeners
:
{
// simulate a parent component v-model binding
// simulate a parent component v-model binding
...
@@ -163,6 +164,38 @@ describe('Ref selector component', () => {
...
@@ -163,6 +164,38 @@ describe('Ref selector component', () => {
});
});
describe
(
'
post-initialization behavior
'
,
()
=>
{
describe
(
'
post-initialization behavior
'
,
()
=>
{
describe
(
'
when a ref is pre-selected
'
,
()
=>
{
const
preselectedRef
=
fixtures
.
branches
[
0
].
name
;
beforeEach
(()
=>
{
createComponent
({
value
:
preselectedRef
});
return
waitForRequests
();
});
it
(
'
renders the pre-selected ref name
'
,
()
=>
{
expect
(
findButtonContent
().
text
()).
toBe
(
preselectedRef
);
});
});
describe
(
'
when the selected ref is updated by the parent component
'
,
()
=>
{
const
updatedRef
=
fixtures
.
branches
[
0
].
name
;
beforeEach
(()
=>
{
createComponent
();
return
waitForRequests
();
});
it
(
'
renders the updated ref name
'
,
()
=>
{
wrapper
.
setProps
({
value
:
updatedRef
});
return
localVue
.
nextTick
().
then
(()
=>
{
expect
(
findButtonContent
().
text
()).
toBe
(
updatedRef
);
});
});
});
describe
(
'
when the search query is updated
'
,
()
=>
{
describe
(
'
when the search query is updated
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
();
createComponent
();
...
...
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