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
31fddefc
Commit
31fddefc
authored
Nov 09, 2020
by
Chad Woolley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address review feedback
Improve tests and address other feedback
parent
e2fb7374
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
22 deletions
+56
-22
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+19
-9
app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue
...scripts/static_site_editor/components/edit_meta_modal.vue
+2
-1
spec/frontend/api_spec.js
spec/frontend/api_spec.js
+33
-11
spec/frontend/static_site_editor/components/edit_meta_modal_spec.js
...end/static_site_editor/components/edit_meta_modal_spec.js
+2
-1
No files found.
app/assets/javascripts/api.js
View file @
31fddefc
...
...
@@ -461,11 +461,12 @@ const Api = {
},
issueTemplate
(
namespacePath
,
projectPath
,
key
,
type
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
issuableTemplatePath
)
.
replace
(
'
:key
'
,
encodeURIComponent
(
key
))
.
replace
(
'
:type
'
,
type
)
.
replace
(
'
:project_path
'
,
projectPath
)
.
replace
(
'
:namespace_path
'
,
namespacePath
);
const
url
=
this
.
buildIssueTemplateUrl
(
Api
.
issuableTemplatePath
,
type
,
projectPath
,
namespacePath
,
).
replace
(
'
:key
'
,
encodeURIComponent
(
key
));
return
axios
.
get
(
url
)
.
then
(({
data
})
=>
callback
(
null
,
data
))
...
...
@@ -473,16 +474,25 @@ const Api = {
},
issueTemplates
(
namespacePath
,
projectPath
,
type
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
issuableTemplatesPath
)
.
replace
(
'
:type
'
,
type
)
.
replace
(
'
:project_path
'
,
projectPath
)
.
replace
(
'
:namespace_path
'
,
namespacePath
);
const
url
=
this
.
buildIssueTemplateUrl
(
Api
.
issuableTemplatesPath
,
type
,
projectPath
,
namespacePath
,
);
return
axios
.
get
(
url
)
.
then
(({
data
})
=>
callback
(
null
,
data
))
.
catch
(
callback
);
},
buildIssueTemplateUrl
(
path
,
type
,
projectPath
,
namespacePath
)
{
return
Api
.
buildUrl
(
path
)
.
replace
(
'
:type
'
,
type
)
.
replace
(
'
:project_path
'
,
projectPath
)
.
replace
(
'
:namespace_path
'
,
namespacePath
);
},
users
(
query
,
options
)
{
const
url
=
Api
.
buildUrl
(
this
.
usersPath
);
return
axios
.
get
(
url
,
{
...
...
app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue
View file @
31fddefc
...
...
@@ -66,7 +66,8 @@ export default {
this
.
$refs
.
modal
.
hide
();
},
initTemplates
()
{
Api
.
issueTemplates
(
this
.
namespace
,
this
.
project
,
ISSUABLE_TYPE
,
(
err
,
templates
)
=>
{
const
{
namespace
,
project
}
=
this
;
Api
.
issueTemplates
(
namespace
,
project
,
ISSUABLE_TYPE
,
(
err
,
templates
)
=>
{
if
(
err
)
return
;
// Error handled by global AJAX error handler
this
.
mergeRequestTemplates
=
templates
;
});
...
...
spec/frontend/api_spec.js
View file @
31fddefc
...
...
@@ -553,14 +553,15 @@ describe('Api', () => {
});
describe
(
'
issueTemplate
'
,
()
=>
{
const
namespace
=
'
some namespace
'
;
const
project
=
'
some project
'
;
const
templateKey
=
'
template #%?.key
'
;
const
templateType
=
'
template type
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/
${
namespace
}
/
${
project
}
/templates/
${
templateType
}
/
${
encodeURIComponent
(
templateKey
,
)}
`
;
it
(
'
fetches an issue template
'
,
done
=>
{
const
namespace
=
'
some namespace
'
;
const
project
=
'
some project
'
;
const
templateKey
=
'
template #%?.key
'
;
const
templateType
=
'
template type
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/
${
namespace
}
/
${
project
}
/templates/
${
templateType
}
/
${
encodeURIComponent
(
templateKey
,
)}
`
;
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
'
test
'
);
Api
.
issueTemplate
(
namespace
,
project
,
templateKey
,
templateType
,
(
error
,
response
)
=>
{
...
...
@@ -568,14 +569,25 @@ describe('Api', () => {
done
();
});
});
describe
(
'
when an error occurs while fetching an issue template
'
,
()
=>
{
it
(
'
rejects the Promise
'
,
()
=>
{
mock
.
onGet
(
expectedUrl
).
replyOnce
(
httpStatus
.
INTERNAL_SERVER_ERROR
);
Api
.
issueTemplate
(
namespace
,
project
,
templateKey
,
templateType
,
()
=>
{
expect
(
mock
.
history
.
get
).
toHaveLength
(
1
);
});
});
});
});
describe
(
'
issueTemplates
'
,
()
=>
{
const
namespace
=
'
some namespace
'
;
const
project
=
'
some project
'
;
const
templateType
=
'
template type
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/
${
namespace
}
/
${
project
}
/templates/
${
templateType
}
`
;
it
(
'
fetches all templates by type
'
,
done
=>
{
const
namespace
=
'
some namespace
'
;
const
project
=
'
some project
'
;
const
templateType
=
'
template type
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/
${
namespace
}
/
${
project
}
/templates/
${
templateType
}
`
;
const
expectedData
=
[
{
key
:
'
Template1
'
,
name
:
'
Template 1
'
,
content
:
'
This is template 1!
'
},
];
...
...
@@ -590,6 +602,16 @@ describe('Api', () => {
done
();
});
});
describe
(
'
when an error occurs while fetching issue templates
'
,
()
=>
{
it
(
'
rejects the Promise
'
,
()
=>
{
mock
.
onGet
(
expectedUrl
).
replyOnce
(
httpStatus
.
INTERNAL_SERVER_ERROR
);
Api
.
issueTemplates
(
namespace
,
project
,
templateType
,
()
=>
{
expect
(
mock
.
history
.
get
).
toHaveLength
(
1
);
});
});
});
});
describe
(
'
projectTemplates
'
,
()
=>
{
...
...
spec/frontend/static_site_editor/components/edit_meta_modal_spec.js
View file @
31fddefc
...
...
@@ -36,8 +36,9 @@ describe('~/static_site_editor/components/edit_meta_modal.vue', () => {
const
buildMockAxios
=
()
=>
{
mockAxios
=
new
MockAdapter
(
axios
);
const
templatesMergeRequestsPath
=
`templates/merge_request`
;
mockAxios
.
onGet
(
`
${
namespace
}
/
${
project
}
/
templates/merge_request
`
)
.
onGet
(
`
${
namespace
}
/
${
project
}
/
${
templatesMergeRequestsPath
}
`
)
.
reply
(
200
,
mergeRequestTemplates
);
};
...
...
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