forked from readmeio/rdme
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow customers to define the slug in the metadata (readmeio#375)
* fix: allow customers to define the slug in the metadata * chore: replacing a real looking category id in a test with a fake one Co-authored-by: Jon Ursenbach <[email protected]>
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
category: CATEGORY_ID | ||
title: This is the document title | ||
slug: marc-actually-wrote-a-test | ||
--- | ||
|
||
Body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,40 @@ describe('rdme docs', () => { | |
}); | ||
}); | ||
}); | ||
|
||
describe('slug metadata', () => { | ||
it('should use provided slug', () => { | ||
const slug = 'new-doc-slug'; | ||
const doc = frontMatter(fs.readFileSync(path.join(fixturesDir, `/slug-docs/${slug}.md`))); | ||
const hash = hashFileContents(fs.readFileSync(path.join(fixturesDir, `/slug-docs/${slug}.md`))); | ||
|
||
const getMock = getNockWithVersionHeader(version) | ||
.get(`/api/v1/docs/${doc.data.slug}`) | ||
.basicAuth({ user: key }) | ||
.reply(404, { | ||
error: 'DOC_NOTFOUND', | ||
message: `The doc with the slug '${slug}' couldn't be found`, | ||
suggestion: '...a suggestion to resolve the issue...', | ||
help: 'If you need help, email [email protected] and mention log "fake-metrics-uuid".', | ||
}); | ||
|
||
const postMock = getNockWithVersionHeader(version) | ||
.post(`/api/v1/docs`, { slug, body: doc.content, ...doc.data, lastUpdatedHash: hash }) | ||
.basicAuth({ user: key }) | ||
.reply(201, { slug: doc.data.slug, body: doc.content, ...doc.data, lastUpdatedHash: hash }); | ||
|
||
const versionMock = nock(config.host) | ||
.get(`/api/v1/version/${version}`) | ||
.basicAuth({ user: key }) | ||
.reply(200, { version }); | ||
|
||
return docs.run({ folder: './__tests__/__fixtures__/slug-docs', key, version }).then(() => { | ||
getMock.done(); | ||
postMock.done(); | ||
versionMock.done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('rdme docs:edit', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters