diff options
author | Nick Thomas <nick@gitlab.com> | 2018-10-03 02:00:38 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-10-05 13:34:43 +0300 |
commit | 25bd49e4f57fe15f9d61dc9376a5b7dc35b30f64 (patch) | |
tree | faef4e9d73e9845413462013c868eace19a11abf /spec/javascripts | |
parent | ae014e189773f7299c12c1050334b3e8fe7b15d8 (diff) |
Backport project template API to CE
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/api_spec.js | 64 |
1 files changed, 19 insertions, 45 deletions
diff --git a/spec/javascripts/api_spec.js b/spec/javascripts/api_spec.js index 54cb6d84109..091edf13cfe 100644 --- a/spec/javascripts/api_spec.js +++ b/spec/javascripts/api_spec.js @@ -250,71 +250,45 @@ describe('Api', () => { }); }); - describe('licenseText', () => { - it('fetches a license text', done => { - const licenseKey = "driver's license"; - const data = { unused: 'option' }; - const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/licenses/${licenseKey}`; + 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'); - Api.licenseText(licenseKey, data, response => { + Api.issueTemplate(namespace, project, templateKey, templateType, (error, response) => { expect(response).toBe('test'); done(); }); }); }); - describe('gitignoreText', () => { - it('fetches a gitignore text', done => { - const gitignoreKey = 'ignore git'; - const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/gitignores/${gitignoreKey}`; - mock.onGet(expectedUrl).reply(200, 'test'); - - Api.gitignoreText(gitignoreKey, response => { - expect(response).toBe('test'); - done(); - }); - }); - }); + describe('projectTemplates', () => { + it('fetches a list of templates', done => { + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/gitlab-org%2Fgitlab-ce/templates/licenses`; - 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'); - Api.gitlabCiYml(gitlabCiYmlKey, response => { + Api.projectTemplates('gitlab-org/gitlab-ce', 'licenses', {}, response => { expect(response).toBe('test'); done(); }); }); }); - describe('dockerfileYml', () => { - it('fetches a Dockerfile', done => { - const dockerfileYmlKey = 'a giant whale'; - const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/dockerfiles/${dockerfileYmlKey}`; - mock.onGet(expectedUrl).reply(200, 'test'); - - Api.dockerfileYml(dockerfileYmlKey, response => { - expect(response).toBe('test'); - done(); - }); - }); - }); + describe('projectTemplate', () => { + it('fetches a single template', done => { + const data = { unused: 'option' }; + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/gitlab-org%2Fgitlab-ce/templates/licenses/test%20license`; - 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'); - Api.issueTemplate(namespace, project, templateKey, templateType, (error, response) => { + Api.projectTemplate('gitlab-org/gitlab-ce', 'licenses', 'test license', data, response => { expect(response).toBe('test'); done(); }); |