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
45eabf92
Commit
45eabf92
authored
Dec 21, 2018
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept lockVersion as a prop and add to store
parent
8bcd508b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
6 deletions
+31
-6
app/assets/javascripts/issue_show/components/app.vue
app/assets/javascripts/issue_show/components/app.vue
+6
-0
app/assets/javascripts/issue_show/stores/index.js
app/assets/javascripts/issue_show/stores/index.js
+2
-0
spec/helpers/issuables_helper_spec.rb
spec/helpers/issuables_helper_spec.rb
+1
-0
spec/javascripts/issue_show/components/app_spec.js
spec/javascripts/issue_show/components/app_spec.js
+20
-6
spec/javascripts/issue_show/mock_data.js
spec/javascripts/issue_show/mock_data.js
+2
-0
No files found.
app/assets/javascripts/issue_show/components/app.vue
View file @
45eabf92
...
...
@@ -130,6 +130,10 @@ export default {
required
:
false
,
default
:
true
,
},
lockVersion
:
{
type
:
Number
,
required
:
true
,
},
},
data
()
{
const
store
=
new
Store
({
...
...
@@ -141,6 +145,7 @@ export default {
updatedByName
:
this
.
updatedByName
,
updatedByPath
:
this
.
updatedByPath
,
taskStatus
:
this
.
initialTaskStatus
,
lock_version
:
this
.
lockVersion
,
});
return
{
...
...
@@ -214,6 +219,7 @@ export default {
this
.
store
.
setFormState
({
title
:
this
.
state
.
titleText
,
description
:
this
.
state
.
descriptionText
,
lock_version
:
this
.
state
.
lock_version
,
lockedWarningVisible
:
false
,
updateLoading
:
false
,
});
...
...
app/assets/javascripts/issue_show/stores/index.js
View file @
45eabf92
...
...
@@ -6,6 +6,7 @@ export default class Store {
description
:
''
,
lockedWarningVisible
:
false
,
updateLoading
:
false
,
lock_version
:
0
,
};
}
...
...
@@ -22,6 +23,7 @@ export default class Store {
this
.
state
.
updatedAt
=
data
.
updated_at
;
this
.
state
.
updatedByName
=
data
.
updated_by_name
;
this
.
state
.
updatedByPath
=
data
.
updated_by_path
;
this
.
state
.
lock_version
=
data
.
lock_version
;
}
stateShouldUpdate
(
data
)
{
...
...
spec/helpers/issuables_helper_spec.rb
View file @
45eabf92
...
...
@@ -190,6 +190,7 @@ describe IssuablesHelper do
markdownDocsPath:
'/help/user/markdown'
,
markdownVersion:
CacheMarkdownField
::
CACHE_COMMONMARK_VERSION
,
issuableTemplates:
[],
lockVersion:
issue
.
lock_version
,
projectPath:
@project
.
path
,
projectNamespace:
@project
.
namespace
.
path
,
initialTitleHtml:
issue
.
title
,
...
...
spec/javascripts/issue_show/components/app_spec.js
View file @
45eabf92
...
...
@@ -43,6 +43,7 @@ describe('Issuable output', () => {
initialTitleText
:
''
,
initialDescriptionHtml
:
'
test
'
,
initialDescriptionText
:
'
test
'
,
lockVersion
:
1
,
markdownPreviewPath
:
'
/
'
,
markdownDocsPath
:
'
/
'
,
projectNamespace
:
'
/
'
,
...
...
@@ -78,6 +79,7 @@ describe('Issuable output', () => {
expect
(
formatText
(
editedText
.
innerText
)).
toMatch
(
/Edited
[\s\S]
+
?
by Some User/
);
expect
(
editedText
.
querySelector
(
'
.author-link
'
).
href
).
toMatch
(
/
\/
some_user$/
);
expect
(
editedText
.
querySelector
(
'
time
'
)).
toBeTruthy
();
expect
(
vm
.
state
.
lock_version
).
toEqual
(
1
);
})
.
then
(()
=>
{
vm
.
poll
.
makeRequest
();
...
...
@@ -95,6 +97,7 @@ describe('Issuable output', () => {
expect
(
editedText
.
querySelector
(
'
.author-link
'
).
href
).
toMatch
(
/
\/
other_user$/
);
expect
(
editedText
.
querySelector
(
'
time
'
)).
toBeTruthy
();
expect
(
vm
.
state
.
lock_version
).
toEqual
(
2
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
...
...
@@ -255,15 +258,10 @@ describe('Issuable output', () => {
describe
(
'
error when updating
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
window
,
'
Flash
'
).
and
.
callThrough
();
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(
()
=>
new
Promise
((
resolve
,
reject
)
=>
{
reject
();
}),
);
});
it
(
'
closes form on error
'
,
done
=>
{
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
Promise
.
resolve
());
vm
.
updateIssuable
();
setTimeout
(()
=>
{
...
...
@@ -276,6 +274,7 @@ describe('Issuable output', () => {
});
it
(
'
returns the correct error message for issuableType
'
,
done
=>
{
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
Promise
.
reject
());
vm
.
issuableType
=
'
merge request
'
;
Vue
.
nextTick
(()
=>
{
...
...
@@ -290,6 +289,20 @@ describe('Issuable output', () => {
});
});
});
it
(
'
shows error mesage from backend if exists
'
,
done
=>
{
const
msg
=
'
Custom error message from backend
'
;
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
Promise
.
reject
({
response
:
{
data
:
{
errors
:
msg
}
}
}),
// eslint-disable-line prefer-promise-reject-errors
);
vm
.
updateIssuable
();
setTimeout
(()
=>
{
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
msg
);
done
();
});
});
});
});
...
...
@@ -420,6 +433,7 @@ describe('Issuable output', () => {
.
then
(
vm
.
$nextTick
)
.
then
(()
=>
{
expect
(
vm
.
formState
.
lockedWarningVisible
).
toEqual
(
true
);
expect
(
vm
.
formState
.
lock_version
).
toEqual
(
1
);
expect
(
vm
.
$el
.
querySelector
(
'
.alert
'
)).
not
.
toBeNull
();
})
.
then
(
done
)
...
...
spec/javascripts/issue_show/mock_data.js
View file @
45eabf92
...
...
@@ -8,6 +8,7 @@ export default {
updated_at
:
'
2015-05-15T12:31:04.428Z
'
,
updated_by_name
:
'
Some User
'
,
updated_by_path
:
'
/some_user
'
,
lock_version
:
1
,
},
secondRequest
:
{
title
:
'
<p>2</p>
'
,
...
...
@@ -18,5 +19,6 @@ export default {
updated_at
:
'
2016-05-15T12:31:04.428Z
'
,
updated_by_name
:
'
Other User
'
,
updated_by_path
:
'
/other_user
'
,
lock_version
:
2
,
},
};
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