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
a3a847f8
Commit
a3a847f8
authored
Jan 29, 2019
by
Fatih Acet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review comments and fix commented spec
parent
c352e7e1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
42 deletions
+47
-42
app/assets/javascripts/issue_show/components/app.vue
app/assets/javascripts/issue_show/components/app.vue
+14
-10
app/assets/javascripts/issue_show/stores/index.js
app/assets/javascripts/issue_show/stores/index.js
+3
-6
app/assets/javascripts/task_list.js
app/assets/javascripts/task_list.js
+4
-5
spec/javascripts/issue_show/components/app_spec.js
spec/javascripts/issue_show/components/app_spec.js
+22
-17
spec/javascripts/task_list_spec.js
spec/javascripts/task_list_spec.js
+4
-4
No files found.
app/assets/javascripts/issue_show/components/app.vue
View file @
a3a847f8
<
script
>
<
script
>
import
Visibility
from
'
visibilityjs
'
;
import
Visibility
from
'
visibilityjs
'
;
import
{
s__
,
sprintf
}
from
'
~/locale
'
;
import
{
__
,
s__
,
sprintf
}
from
'
~/locale
'
;
import
createFlash
from
'
~/flash
'
;
import
{
visitUrl
}
from
'
../../lib/utils/url_utility
'
;
import
{
visitUrl
}
from
'
../../lib/utils/url_utility
'
;
import
Poll
from
'
../../lib/utils/poll
'
;
import
Poll
from
'
../../lib/utils/poll
'
;
import
eventHub
from
'
../event_hub
'
;
import
eventHub
from
'
../event_hub
'
;
...
@@ -11,7 +12,6 @@ import descriptionComponent from './description.vue';
...
@@ -11,7 +12,6 @@ import descriptionComponent from './description.vue';
import
editedComponent
from
'
./edited.vue
'
;
import
editedComponent
from
'
./edited.vue
'
;
import
formComponent
from
'
./form.vue
'
;
import
formComponent
from
'
./form.vue
'
;
import
recaptchaModalImplementor
from
'
../../vue_shared/mixins/recaptcha_modal_implementor
'
;
import
recaptchaModalImplementor
from
'
../../vue_shared/mixins/recaptcha_modal_implementor
'
;
import
{
__
}
from
'
~/locale
'
;
export
default
{
export
default
{
components
:
{
components
:
{
...
@@ -168,7 +168,7 @@ export default {
...
@@ -168,7 +168,7 @@ export default {
return
descriptionChanged
||
titleChanged
;
return
descriptionChanged
||
titleChanged
;
},
},
defaultErrorMessage
()
{
defaultErrorMessage
()
{
return
sprintf
(
s__
(
'
Error updating
%{issuableType}.
'
),
{
issuableType
:
this
.
issuableType
});
return
sprintf
(
s__
(
'
Error updating
%{issuableType}
'
),
{
issuableType
:
this
.
issuableType
});
},
},
},
},
created
()
{
created
()
{
...
@@ -224,7 +224,7 @@ export default {
...
@@ -224,7 +224,7 @@ export default {
this
.
store
.
updateState
(
data
);
this
.
store
.
updateState
(
data
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
window
.
Flash
(
this
.
defaultErrorMessage
);
create
Flash
(
this
.
defaultErrorMessage
);
});
});
},
},
...
@@ -258,18 +258,20 @@ export default {
...
@@ -258,18 +258,20 @@ export default {
.
then
(()
=>
{
.
then
(()
=>
{
eventHub
.
$emit
(
'
close.form
'
);
eventHub
.
$emit
(
'
close.form
'
);
})
})
.
catch
(
error
=>
{
.
catch
((
error
=
{})
=>
{
if
(
error
&&
error
.
name
===
'
SpamError
'
)
{
const
{
name
,
response
=
{}
}
=
error
;
if
(
name
===
'
SpamError
'
)
{
this
.
openRecaptcha
();
this
.
openRecaptcha
();
}
else
{
}
else
{
let
errMsg
=
this
.
defaultErrorMessage
;
let
errMsg
=
this
.
defaultErrorMessage
;
if
(
error
&&
error
.
response
&&
error
.
response
.
data
&&
error
.
response
.
data
.
errors
)
{
if
(
response
.
data
&&
response
.
data
.
errors
)
{
errMsg
+=
error
.
response
.
data
.
errors
.
join
(
'
'
)
;
errMsg
+=
`.
${
response
.
data
.
errors
.
join
(
'
'
)}
`
;
}
}
eventHub
.
$emit
(
'
close.form
'
);
eventHub
.
$emit
(
'
close.form
'
);
window
.
Flash
(
errMsg
);
create
Flash
(
errMsg
);
}
}
});
});
},
},
...
@@ -294,7 +296,9 @@ export default {
...
@@ -294,7 +296,9 @@ export default {
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
eventHub
.
$emit
(
'
close.form
'
);
eventHub
.
$emit
(
'
close.form
'
);
window
.
Flash
(
`Error deleting
${
this
.
issuableType
}
`
);
createFlash
(
sprintf
(
s__
(
'
Error deleting %{issuableType}
'
),
{
issuableType
:
this
.
issuableType
}),
);
});
});
},
},
},
},
...
...
app/assets/javascripts/issue_show/stores/index.js
View file @
a3a847f8
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
export
default
class
Store
{
export
default
class
Store
{
constructor
(
initialState
)
{
constructor
(
initialState
)
{
this
.
state
=
initialState
;
this
.
state
=
initialState
;
...
@@ -15,14 +17,9 @@ export default class Store {
...
@@ -15,14 +17,9 @@ export default class Store {
this
.
formState
.
lockedWarningVisible
=
true
;
this
.
formState
.
lockedWarningVisible
=
true
;
}
}
Object
.
assign
(
this
.
state
,
convertObjectPropsToCamelCase
(
data
));
this
.
state
.
titleHtml
=
data
.
title
;
this
.
state
.
titleHtml
=
data
.
title
;
this
.
state
.
titleText
=
data
.
title_text
;
this
.
state
.
descriptionHtml
=
data
.
description
;
this
.
state
.
descriptionHtml
=
data
.
description
;
this
.
state
.
descriptionText
=
data
.
description_text
;
this
.
state
.
taskStatus
=
data
.
task_status
;
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
;
this
.
state
.
lock_version
=
data
.
lock_version
;
}
}
...
...
app/assets/javascripts/task_list.js
View file @
a3a847f8
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
'
deckar01-task_list
'
;
import
'
deckar01-task_list
'
;
import
{
__
}
from
'
~/locale
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
Flash
from
'
./flash
'
;
import
Flash
from
'
./flash
'
;
...
@@ -21,7 +22,7 @@ export default class TaskList {
...
@@ -21,7 +22,7 @@ export default class TaskList {
errorMessages
=
e
.
response
.
data
.
errors
.
join
(
'
'
);
errorMessages
=
e
.
response
.
data
.
errors
.
join
(
'
'
);
}
}
return
new
Flash
(
errorMessages
||
'
Update failed
'
,
'
alert
'
);
return
new
Flash
(
errorMessages
||
__
(
'
Update failed
'
)
,
'
alert
'
);
};
};
this
.
init
();
this
.
init
();
...
@@ -34,10 +35,8 @@ export default class TaskList {
...
@@ -34,10 +35,8 @@ export default class TaskList {
$
(
document
).
on
(
'
tasklist:changed
'
,
this
.
taskListContainerSelector
,
this
.
updateHandler
);
$
(
document
).
on
(
'
tasklist:changed
'
,
this
.
taskListContainerSelector
,
this
.
updateHandler
);
}
}
getTaskListTarget
(
e
=
{})
{
getTaskListTarget
(
e
)
{
const
$currentTarget
=
$
(
e
.
currentTarget
);
return
e
&&
e
.
currentTarget
?
$
(
e
.
currentTarget
)
:
$
(
this
.
taskListContainerSelector
);
return
$currentTarget
.
taskList
?
$currentTarget
:
$
(
this
.
taskListContainerSelector
);
}
}
disableTaskListItems
(
e
)
{
disableTaskListItems
(
e
)
{
...
...
spec/javascripts/issue_show/components/app_spec.js
View file @
a3a847f8
...
@@ -18,9 +18,13 @@ describe('Issuable output', () => {
...
@@ -18,9 +18,13 @@ describe('Issuable output', () => {
let
realtimeRequestCount
=
0
;
let
realtimeRequestCount
=
0
;
let
vm
;
let
vm
;
document
.
body
.
innerHTML
=
'
<span id="task_status"></span>
'
;
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
setFixtures
(
`
<div>
<div class="flash-container"></div>
<span id="task_status"></span>
</div>
`
);
spyOn
(
eventHub
,
'
$emit
'
);
spyOn
(
eventHub
,
'
$emit
'
);
const
IssuableDescriptionComponent
=
Vue
.
extend
(
issuableApp
);
const
IssuableDescriptionComponent
=
Vue
.
extend
(
issuableApp
);
...
@@ -258,18 +262,15 @@ describe('Issuable output', () => {
...
@@ -258,18 +262,15 @@ describe('Issuable output', () => {
});
});
describe
(
'
error when updating
'
,
()
=>
{
describe
(
'
error when updating
'
,
()
=>
{
beforeEach
(()
=>
{
spyOn
(
window
,
'
Flash
'
).
and
.
callThrough
();
});
it
(
'
closes form on error
'
,
done
=>
{
it
(
'
closes form on error
'
,
done
=>
{
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
Promise
.
resolve
());
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(()
=>
Promise
.
resolve
());
vm
.
updateIssuable
();
vm
.
updateIssuable
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
close.form
'
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
close.form
'
);
expect
(
document
.
querySelector
(
'
.flash-container .flash-text
'
).
innerText
.
trim
()).
toBe
(
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
'
Error updating issue
'
);
`Error updating issue`
,
);
done
();
done
();
});
});
...
@@ -284,8 +285,9 @@ describe('Issuable output', () => {
...
@@ -284,8 +285,9 @@ describe('Issuable output', () => {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
close.form
'
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
close.form
'
);
expect
(
document
.
querySelector
(
'
.flash-container .flash-text
'
).
innerText
.
trim
()).
toBe
(
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
'
Error updating merge request
'
);
`Error updating merge request`
,
);
done
();
done
();
});
});
...
@@ -295,12 +297,14 @@ describe('Issuable output', () => {
...
@@ -295,12 +297,14 @@ describe('Issuable output', () => {
it
(
'
shows error mesage from backend if exists
'
,
done
=>
{
it
(
'
shows error mesage from backend if exists
'
,
done
=>
{
const
msg
=
'
Custom error message from backend
'
;
const
msg
=
'
Custom error message from backend
'
;
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(
spyOn
(
vm
.
service
,
'
updateIssuable
'
).
and
.
callFake
(
()
=>
Promise
.
reject
({
response
:
{
data
:
{
errors
:
msg
}
}
}),
// eslint-disable-line prefer-promise-reject-errors
()
=>
Promise
.
reject
({
response
:
{
data
:
{
errors
:
[
msg
]
}
}
}),
// eslint-disable-line prefer-promise-reject-errors
);
);
vm
.
updateIssuable
();
vm
.
updateIssuable
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
msg
);
expect
(
document
.
querySelector
(
'
.flash-container .flash-text
'
).
innerText
.
trim
()).
toBe
(
`
${
vm
.
defaultErrorMessage
}
.
${
msg
}
`
,
);
done
();
done
();
});
});
...
@@ -399,7 +403,6 @@ describe('Issuable output', () => {
...
@@ -399,7 +403,6 @@ describe('Issuable output', () => {
});
});
it
(
'
closes form on error
'
,
done
=>
{
it
(
'
closes form on error
'
,
done
=>
{
spyOn
(
window
,
'
Flash
'
).
and
.
callThrough
();
spyOn
(
vm
.
service
,
'
deleteIssuable
'
).
and
.
callFake
(
spyOn
(
vm
.
service
,
'
deleteIssuable
'
).
and
.
callFake
(
()
=>
()
=>
new
Promise
((
resolve
,
reject
)
=>
{
new
Promise
((
resolve
,
reject
)
=>
{
...
@@ -411,8 +414,9 @@ describe('Issuable output', () => {
...
@@ -411,8 +414,9 @@ describe('Issuable output', () => {
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
close.form
'
);
expect
(
eventHub
.
$emit
).
toHaveBeenCalledWith
(
'
close.form
'
);
expect
(
document
.
querySelector
(
'
.flash-container .flash-text
'
).
innerText
.
trim
()).
toBe
(
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
'
Error deleting issue
'
);
'
Error deleting issue
'
,
);
done
();
done
();
});
});
...
@@ -472,12 +476,13 @@ describe('Issuable output', () => {
...
@@ -472,12 +476,13 @@ describe('Issuable output', () => {
it
(
'
should show error message if store update fails
'
,
done
=>
{
it
(
'
should show error message if store update fails
'
,
done
=>
{
spyOn
(
vm
.
service
,
'
getData
'
).
and
.
returnValue
(
Promise
.
reject
());
spyOn
(
vm
.
service
,
'
getData
'
).
and
.
returnValue
(
Promise
.
reject
());
spyOn
(
window
,
'
Flash
'
);
vm
.
issuableType
=
'
merge request
'
;
vm
.
issuableType
=
'
merge request
'
;
vm
.
updateStoreState
()
vm
.
updateStoreState
()
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
`Error updating
${
vm
.
issuableType
}
`
);
expect
(
document
.
querySelector
(
'
.flash-container .flash-text
'
).
innerText
.
trim
()).
toBe
(
`Error updating
${
vm
.
issuableType
}
`
,
);
})
})
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
...
...
spec/javascripts/task_list_spec.js
View file @
a3a847f8
...
@@ -50,11 +50,11 @@ describe('TaskList', () => {
...
@@ -50,11 +50,11 @@ describe('TaskList', () => {
expect
(
$target
).
toEqual
(
currentTarget
);
expect
(
$target
).
toEqual
(
currentTarget
);
});
});
//
it('should return element of the taskListContainerSelector', () => {
it
(
'
should return element of the taskListContainerSelector
'
,
()
=>
{
//
const $target = taskList.getTaskListTarget();
const
$target
=
taskList
.
getTaskListTarget
();
//
expect($target).toEqual($(taskList.taskListContainerSelector));
expect
(
$target
).
toEqual
(
$
(
taskList
.
taskListContainerSelector
));
//
});
});
});
});
describe
(
'
disableTaskListItems
'
,
()
=>
{
describe
(
'
disableTaskListItems
'
,
()
=>
{
...
...
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