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 = {
...
@@ -461,11 +461,12 @@ const Api = {
},
},
issueTemplate
(
namespacePath
,
projectPath
,
key
,
type
,
callback
)
{
issueTemplate
(
namespacePath
,
projectPath
,
key
,
type
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
issuableTemplatePath
)
const
url
=
this
.
buildIssueTemplateUrl
(
.
replace
(
'
:key
'
,
encodeURIComponent
(
key
))
Api
.
issuableTemplatePath
,
.
replace
(
'
:type
'
,
type
)
type
,
.
replace
(
'
:project_path
'
,
projectPath
)
projectPath
,
.
replace
(
'
:namespace_path
'
,
namespacePath
);
namespacePath
,
).
replace
(
'
:key
'
,
encodeURIComponent
(
key
));
return
axios
return
axios
.
get
(
url
)
.
get
(
url
)
.
then
(({
data
})
=>
callback
(
null
,
data
))
.
then
(({
data
})
=>
callback
(
null
,
data
))
...
@@ -473,16 +474,25 @@ const Api = {
...
@@ -473,16 +474,25 @@ const Api = {
},
},
issueTemplates
(
namespacePath
,
projectPath
,
type
,
callback
)
{
issueTemplates
(
namespacePath
,
projectPath
,
type
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
issuableTemplatesPath
)
const
url
=
this
.
buildIssueTemplateUrl
(
.
replace
(
'
:type
'
,
type
)
Api
.
issuableTemplatesPath
,
.
replace
(
'
:project_path
'
,
projectPath
)
type
,
.
replace
(
'
:namespace_path
'
,
namespacePath
);
projectPath
,
namespacePath
,
);
return
axios
return
axios
.
get
(
url
)
.
get
(
url
)
.
then
(({
data
})
=>
callback
(
null
,
data
))
.
then
(({
data
})
=>
callback
(
null
,
data
))
.
catch
(
callback
);
.
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
)
{
users
(
query
,
options
)
{
const
url
=
Api
.
buildUrl
(
this
.
usersPath
);
const
url
=
Api
.
buildUrl
(
this
.
usersPath
);
return
axios
.
get
(
url
,
{
return
axios
.
get
(
url
,
{
...
...
app/assets/javascripts/static_site_editor/components/edit_meta_modal.vue
View file @
31fddefc
...
@@ -66,7 +66,8 @@ export default {
...
@@ -66,7 +66,8 @@ export default {
this
.
$refs
.
modal
.
hide
();
this
.
$refs
.
modal
.
hide
();
},
},
initTemplates
()
{
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
if
(
err
)
return
;
// Error handled by global AJAX error handler
this
.
mergeRequestTemplates
=
templates
;
this
.
mergeRequestTemplates
=
templates
;
});
});
...
...
spec/frontend/api_spec.js
View file @
31fddefc
...
@@ -553,14 +553,15 @@ describe('Api', () => {
...
@@ -553,14 +553,15 @@ describe('Api', () => {
});
});
describe
(
'
issueTemplate
'
,
()
=>
{
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
=>
{
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
'
);
mock
.
onGet
(
expectedUrl
).
reply
(
httpStatus
.
OK
,
'
test
'
);
Api
.
issueTemplate
(
namespace
,
project
,
templateKey
,
templateType
,
(
error
,
response
)
=>
{
Api
.
issueTemplate
(
namespace
,
project
,
templateKey
,
templateType
,
(
error
,
response
)
=>
{
...
@@ -568,14 +569,25 @@ describe('Api', () => {
...
@@ -568,14 +569,25 @@ describe('Api', () => {
done
();
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
'
,
()
=>
{
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
=>
{
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
=
[
const
expectedData
=
[
{
key
:
'
Template1
'
,
name
:
'
Template 1
'
,
content
:
'
This is template 1!
'
},
{
key
:
'
Template1
'
,
name
:
'
Template 1
'
,
content
:
'
This is template 1!
'
},
];
];
...
@@ -590,6 +602,16 @@ describe('Api', () => {
...
@@ -590,6 +602,16 @@ describe('Api', () => {
done
();
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
'
,
()
=>
{
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', () => {
...
@@ -36,8 +36,9 @@ describe('~/static_site_editor/components/edit_meta_modal.vue', () => {
const
buildMockAxios
=
()
=>
{
const
buildMockAxios
=
()
=>
{
mockAxios
=
new
MockAdapter
(
axios
);
mockAxios
=
new
MockAdapter
(
axios
);
const
templatesMergeRequestsPath
=
`templates/merge_request`
;
mockAxios
mockAxios
.
onGet
(
`
${
namespace
}
/
${
project
}
/
templates/merge_request
`
)
.
onGet
(
`
${
namespace
}
/
${
project
}
/
${
templatesMergeRequestsPath
}
`
)
.
reply
(
200
,
mergeRequestTemplates
);
.
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