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
071e3d7d
Commit
071e3d7d
authored
Oct 03, 2018
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove now-unused methods in api.js and add tests
parent
08dd4408
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
84 deletions
+19
-84
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+0
-36
app/assets/javascripts/blob/template_selector.js
app/assets/javascripts/blob/template_selector.js
+0
-3
spec/javascripts/api_spec.js
spec/javascripts/api_spec.js
+19
-45
No files found.
app/assets/javascripts/api.js
View file @
071e3d7d
...
@@ -15,12 +15,7 @@ const Api = {
...
@@ -15,12 +15,7 @@ const Api = {
mergeRequestChangesPath
:
'
/api/:version/projects/:id/merge_requests/:mrid/changes
'
,
mergeRequestChangesPath
:
'
/api/:version/projects/:id/merge_requests/:mrid/changes
'
,
mergeRequestVersionsPath
:
'
/api/:version/projects/:id/merge_requests/:mrid/versions
'
,
mergeRequestVersionsPath
:
'
/api/:version/projects/:id/merge_requests/:mrid/versions
'
,
groupLabelsPath
:
'
/groups/:namespace_path/-/labels
'
,
groupLabelsPath
:
'
/groups/:namespace_path/-/labels
'
,
templatesPath
:
'
/api/:version/templates/:key
'
,
licensePath
:
'
/api/:version/templates/licenses/:key
'
,
gitignorePath
:
'
/api/:version/templates/gitignores/:key
'
,
gitlabCiYmlPath
:
'
/api/:version/templates/gitlab_ci_ymls/:key
'
,
ldapGroupsPath
:
'
/api/:version/ldap/:provider/groups.json
'
,
ldapGroupsPath
:
'
/api/:version/ldap/:provider/groups.json
'
,
dockerfilePath
:
'
/api/:version/templates/dockerfiles/:key
'
,
issuableTemplatePath
:
'
/:namespace_path/:project_path/templates/:type/:key
'
,
issuableTemplatePath
:
'
/:namespace_path/:project_path/templates/:type/:key
'
,
projectTemplatePath
:
'
/api/:version/projects/:id/templates/:type/:key
'
,
projectTemplatePath
:
'
/api/:version/projects/:id/templates/:type/:key
'
,
projectTemplatesPath
:
'
/api/:version/projects/:id/templates/:type
'
,
projectTemplatesPath
:
'
/api/:version/projects/:id/templates/:type
'
,
...
@@ -200,31 +195,6 @@ const Api = {
...
@@ -200,31 +195,6 @@ const Api = {
return
axios
.
get
(
url
);
return
axios
.
get
(
url
);
},
},
// Return text for a specific license
licenseText
(
key
,
data
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
licensePath
).
replace
(
'
:key
'
,
key
);
return
axios
.
get
(
url
,
{
params
:
data
,
})
.
then
(
res
=>
callback
(
res
.
data
));
},
gitignoreText
(
key
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
gitignorePath
).
replace
(
'
:key
'
,
key
);
return
axios
.
get
(
url
).
then
(({
data
})
=>
callback
(
data
));
},
gitlabCiYml
(
key
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
gitlabCiYmlPath
).
replace
(
'
:key
'
,
key
);
return
axios
.
get
(
url
).
then
(({
data
})
=>
callback
(
data
));
},
dockerfileYml
(
key
,
callback
)
{
const
url
=
Api
.
buildUrl
(
Api
.
dockerfilePath
).
replace
(
'
:key
'
,
key
);
return
axios
.
get
(
url
).
then
(({
data
})
=>
callback
(
data
));
},
projectTemplate
(
id
,
type
,
key
,
options
,
callback
)
{
projectTemplate
(
id
,
type
,
key
,
options
,
callback
)
{
const
url
=
Api
.
buildUrl
(
this
.
projectTemplatePath
)
const
url
=
Api
.
buildUrl
(
this
.
projectTemplatePath
)
.
replace
(
'
:id
'
,
encodeURIComponent
(
id
))
.
replace
(
'
:id
'
,
encodeURIComponent
(
id
))
...
@@ -305,12 +275,6 @@ const Api = {
...
@@ -305,12 +275,6 @@ const Api = {
});
});
},
},
templates
(
key
,
params
=
{})
{
const
url
=
Api
.
buildUrl
(
this
.
templatesPath
).
replace
(
'
:key
'
,
key
);
return
axios
.
get
(
url
,
{
params
});
},
approverUsers
(
search
,
options
,
callback
=
$
.
noop
)
{
approverUsers
(
search
,
options
,
callback
=
$
.
noop
)
{
const
url
=
Api
.
buildUrl
(
'
/autocomplete/users.json
'
);
const
url
=
Api
.
buildUrl
(
'
/autocomplete/users.json
'
);
return
axios
return
axios
...
...
app/assets/javascripts/blob/template_selector.js
View file @
071e3d7d
...
@@ -66,9 +66,6 @@ export default class TemplateSelector {
...
@@ -66,9 +66,6 @@ export default class TemplateSelector {
// be added by all subclasses.
// be added by all subclasses.
}
}
// To be implemented on the extending class
// e.g. Api.gitlabCiYml(query.name, file => this.setEditorContent(file));
setEditorContent
(
file
,
{
skipFocus
}
=
{})
{
setEditorContent
(
file
,
{
skipFocus
}
=
{})
{
if
(
!
file
)
return
;
if
(
!
file
)
return
;
...
...
spec/javascripts/api_spec.js
View file @
071e3d7d
...
@@ -250,71 +250,45 @@ describe('Api', () => {
...
@@ -250,71 +250,45 @@ describe('Api', () => {
});
});
});
});
describe
(
'
licenseText
'
,
()
=>
{
describe
(
'
issueTemplate
'
,
()
=>
{
it
(
'
fetches a license text
'
,
done
=>
{
it
(
'
fetches an issue template
'
,
done
=>
{
const
licenseKey
=
"
driver's license
"
;
const
namespace
=
'
some namespace
'
;
const
data
=
{
unused
:
'
option
'
};
const
project
=
'
some project
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/templates/licenses/
${
licenseKey
}
`
;
const
templateKey
=
'
template #%?.key
'
;
const
templateType
=
'
template type
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/
${
namespace
}
/
${
project
}
/templates/
${
templateType
}
/
${
encodeURIComponent
(
templateKey
,
)}
`
;
mock
.
onGet
(
expectedUrl
).
reply
(
200
,
'
test
'
);
mock
.
onGet
(
expectedUrl
).
reply
(
200
,
'
test
'
);
Api
.
licenseText
(
licenseKey
,
data
,
response
=>
{
Api
.
issueTemplate
(
namespace
,
project
,
templateKey
,
templateType
,
(
error
,
response
)
=>
{
expect
(
response
).
toBe
(
'
test
'
);
expect
(
response
).
toBe
(
'
test
'
);
done
();
done
();
});
});
});
});
});
});
describe
(
'
gitignoreText
'
,
()
=>
{
describe
(
'
projectTemplates
'
,
()
=>
{
it
(
'
fetches a gitignore text
'
,
done
=>
{
it
(
'
fetches a list of templates
'
,
done
=>
{
const
gitignoreKey
=
'
ignore git
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/gitlab-org%2Fgitlab-ce/templates/licenses`
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/templates/gitignores/
${
gitignoreKey
}
`
;
mock
.
onGet
(
expectedUrl
).
reply
(
200
,
'
test
'
);
Api
.
gitignoreText
(
gitignoreKey
,
response
=>
{
expect
(
response
).
toBe
(
'
test
'
);
done
();
});
});
});
describe
(
'
gitlabCiYml
'
,
()
=>
{
it
(
'
fetches a .gitlab-ci.yml
'
,
done
=>
{
const
gitlabCiYmlKey
=
'
Y CI ML
'
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/templates/gitlab_ci_ymls/
${
gitlabCiYmlKey
}
`
;
mock
.
onGet
(
expectedUrl
).
reply
(
200
,
'
test
'
);
mock
.
onGet
(
expectedUrl
).
reply
(
200
,
'
test
'
);
Api
.
gitlabCiYml
(
gitlabCiYmlKey
,
response
=>
{
Api
.
projectTemplates
(
'
gitlab-org/gitlab-ce
'
,
'
licenses
'
,
{}
,
response
=>
{
expect
(
response
).
toBe
(
'
test
'
);
expect
(
response
).
toBe
(
'
test
'
);
done
();
done
();
});
});
});
});
});
});
describe
(
'
dockerfileYml
'
,
()
=>
{
describe
(
'
projectTemplate
'
,
()
=>
{
it
(
'
fetches a Dockerfile
'
,
done
=>
{
it
(
'
fetches a single template
'
,
done
=>
{
const
dockerfileYmlKey
=
'
a giant whale
'
;
const
data
=
{
unused
:
'
option
'
};
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/templates/dockerfiles/
${
dockerfileYmlKey
}
`
;
const
expectedUrl
=
`
${
dummyUrlRoot
}
/api/
${
dummyApiVersion
}
/projects/gitlab-org%2Fgitlab-ce/templates/licenses/test%20license`
;
mock
.
onGet
(
expectedUrl
).
reply
(
200
,
'
test
'
);
Api
.
dockerfileYml
(
dockerfileYmlKey
,
response
=>
{
expect
(
response
).
toBe
(
'
test
'
);
done
();
});
});
});
describe
(
'
issueTemplate
'
,
()
=>
{
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
(
200
,
'
test
'
);
mock
.
onGet
(
expectedUrl
).
reply
(
200
,
'
test
'
);
Api
.
issueTemplate
(
namespace
,
project
,
templateKey
,
templateType
,
(
error
,
response
)
=>
{
Api
.
projectTemplate
(
'
gitlab-org/gitlab-ce
'
,
'
licenses
'
,
'
test license
'
,
data
,
response
=>
{
expect
(
response
).
toBe
(
'
test
'
);
expect
(
response
).
toBe
(
'
test
'
);
done
();
done
();
});
});
...
...
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