Change status codes
This commit is contained in:
parent
1e6a65d4e9
commit
e71d883dfd
5 changed files with 7 additions and 9 deletions
|
@ -4,7 +4,6 @@ import {
|
|||
Ctx,
|
||||
FetchViewResponse,
|
||||
ViewResponse,
|
||||
ViewV2,
|
||||
} from "@budibase/types"
|
||||
|
||||
export async function fetch(ctx: Ctx<void, FetchViewResponse>) {
|
||||
|
@ -34,10 +33,11 @@ export async function find(ctx: Ctx<void, ViewResponse>) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function save(ctx: Ctx<CreateViewRequest, ViewResponse>) {
|
||||
export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) {
|
||||
const view = ctx.request.body
|
||||
|
||||
const result = await sdk.views.save(view)
|
||||
const result = await sdk.views.create(view)
|
||||
ctx.status = 201
|
||||
ctx.body = {
|
||||
data: {
|
||||
...view,
|
||||
|
|
|
@ -133,9 +133,7 @@ describe("/v2/views", () => {
|
|||
.send(newView)
|
||||
.set(config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
expect(res.status).toBe(200)
|
||||
expect(res.body.data._id).toBeDefined()
|
||||
.expect(201)
|
||||
|
||||
expect(res.body).toEqual({
|
||||
data: {
|
||||
|
|
|
@ -21,7 +21,7 @@ router
|
|||
.post(
|
||||
"/api/v2/views",
|
||||
authorized(permissions.BUILDER),
|
||||
viewController.v2.save
|
||||
viewController.v2.create
|
||||
)
|
||||
.delete(
|
||||
`/api/v2/views/:viewId`,
|
||||
|
|
|
@ -47,7 +47,7 @@ export async function get(viewId: string): Promise<ViewV2 | undefined> {
|
|||
}
|
||||
}
|
||||
|
||||
export async function save(view: ViewV2): Promise<ViewV2> {
|
||||
export async function create(view: ViewV2): Promise<ViewV2> {
|
||||
const db = context.getAppDB()
|
||||
|
||||
const response = await db.put(
|
||||
|
|
|
@ -23,7 +23,7 @@ export class ViewV2API extends TestAPI {
|
|||
.send(view)
|
||||
.set(this.config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(200)
|
||||
.expect(201)
|
||||
return result.body.data as ViewV2
|
||||
}
|
||||
get = (viewId: string): supertest.Test => {
|
||||
|
|
Loading…
Reference in a new issue