Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
also include Location header in these DELETE endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
karenetheridge committed Dec 3, 2020
1 parent edd92a6 commit 6f0d9a6
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/modules/Conch::Route::Build.md
Expand Up @@ -61,7 +61,7 @@ Supports the following optional query parameters:

- Requires system admin authorization or the admin role on the build
- Request: [request.json#/$defs/BuildLinksOrNull](../json-schema/request.json#/$defs/BuildLinksOrNull)
- Response: 204 NO CONTENT
- Response: `204 No Content`, plus Location header

### `GET /build/:build_id_or_name/user`

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/Conch::Route::Rack.md
Expand Up @@ -104,7 +104,7 @@ only the rack's phase, or all the rack's devices' phases as well.

- User requires the read/write role on the rack
- Request: [request.json#/$defs/RackLinksOrNull](../json-schema/request.json#/$defs/RackLinksOrNull)
- Response: 204 NO CONTENT
- Response: `204 No Content`, plus Location header

### `GET /rack/:rack_id_or_name/layout/:layout_id_or_rack_unit_start`

Expand Down
3 changes: 2 additions & 1 deletion lib/Conch/Controller/Build.pm
Expand Up @@ -280,7 +280,8 @@ sub remove_links ($c) {
->update({ links => '{}' });
}

$c->status(204);
my $build_id = $c->stash('build_id') // $c->stash('build_rs')->get_column('id')->single;
$c->status(204, '/build/'.$build_id);
}

=head2 get_users
Expand Down
3 changes: 2 additions & 1 deletion lib/Conch/Controller/Rack.pm
Expand Up @@ -604,7 +604,8 @@ sub remove_links ($c) {
->update({ links => '{}', updated => \'now()' });
}

$c->status(204);
my $rack_id = $c->stash('rack_id') // $c->stash('rack_rs')->get_column('id')->single;
$c->status(204, '/rack/'.$rack_id);
}

1;
Expand Down
2 changes: 1 addition & 1 deletion lib/Conch/Route/Build.pm
Expand Up @@ -221,7 +221,7 @@ Supports the following optional query parameters:
=item * Request: F<request.yaml#/$defs/BuildLinksOrNull>
=item * Response: 204 NO CONTENT
=item * Response: C<204 No Content>, plus Location header
=back
Expand Down
2 changes: 1 addition & 1 deletion lib/Conch/Route/Rack.pm
Expand Up @@ -267,7 +267,7 @@ only the rack's phase, or all the rack's devices' phases as well.
=item * Request: F<request.yaml#/$defs/RackLinksOrNull>
=item * Response: 204 NO CONTENT
=item * Response: C<204 No Content>, plus Location header
=back
Expand Down
9 changes: 6 additions & 3 deletions t/integration/crud/build.t
Expand Up @@ -192,10 +192,12 @@ $t->get_ok('/build/my first build')
->json_is($build);

$t->delete_ok('/build/my first build/links', json => { links => [ 'https://does-not-exist.com' ] })
->status_is(204);
->status_is(204)
->location_is('/build/'.$build->{id});

$t->delete_ok('/build/my first build/links', json => { links => ['https://alpha.com/1'] })
->status_is(204);
->status_is(204)
->location_is('/build/'.$build->{id});
$build->{links} = ['https://baz.com/3'];

$t->get_ok('/build/my first build')
Expand All @@ -204,7 +206,8 @@ $t->get_ok('/build/my first build')
->json_is($build);

$t->delete_ok('/build/my first build/links')
->status_is(204);
->status_is(204)
->location_is('/build/'.$build->{id});
$build->{links} = [];

$t->get_ok('/build/my first build')
Expand Down
9 changes: 6 additions & 3 deletions t/integration/crud/racks.t
Expand Up @@ -510,10 +510,12 @@ subtest 'rack links' => sub {
}));

$t->delete_ok('/rack/'.$rack->id.'/links', json => { links => [ 'https://does-not-exist.com' ] })
->status_is(204);
->status_is(204)
->location_is('/rack/'.$rack->id);

$t->delete_ok('/rack/'.$rack->id.'/links', json => { links => ['https://alpha.com/1'] })
->status_is(204);
->status_is(204)
->location_is('/rack/'.$rack->id);

$t->get_ok('/rack/'.$rack->id)
->status_is(200)
Expand All @@ -524,7 +526,8 @@ subtest 'rack links' => sub {
}));

$t->delete_ok('/rack/'.$rack->id.'/links')
->status_is(204);
->status_is(204)
->location_is('/rack/'.$rack->id);
$rack->{links} = [];

$t->get_ok('/rack/'.$rack->id)
Expand Down

0 comments on commit 6f0d9a6

Please sign in to comment.