Skip to content

Commit

Permalink
Tidy all.
Browse files Browse the repository at this point in the history
  • Loading branch information
Talina06 committed Jul 1, 2014
1 parent 86c6d28 commit 6e135f2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/MetaCPAN/Server/Controller/Stargazer.pm
Expand Up @@ -14,8 +14,8 @@ sub find : Path('') : Args(2) {
eval {
my $stargazer = $self->model($c)->raw->get(
{
user => $user,
module => $module
user => $user,
module => $module
}
);
$c->stash( $stargazer->{_source} || $stargazer->{fields} );
Expand Down
23 changes: 10 additions & 13 deletions lib/MetaCPAN/Server/Controller/User/Stargazer.pm
Expand Up @@ -24,24 +24,22 @@ sub index : Path : ActionClass('REST') {

sub index_POST {
my ( $self, $c ) = @_;
my $pause = $c->stash->{pause};
my $req = $c->req;
my $star = $c->model('CPAN::Stargazer')->put(
my $pause = $c->stash->{pause};
my $req = $c->req;
my $star = $c->model('CPAN::Stargazer')->put(
{
user => $c->user->id,
author => $req->data->{author},
release => $req->data->{release},
module => $req->data->{module},
author => $req->data->{author},
user => $c->user->id,
author => $req->data->{author},
release => $req->data->{release},
module => $req->data->{module},
author => $req->data->{author},
},
{ refresh => 1 }
);
$self->status_created(
$c,
location => $c->uri_for(
join(
'/', '/stargazer', $star->user, $star->module
)
join( '/', '/stargazer', $star->user, $star->module )
),
entity => $star->meta->get_data($star)
);
Expand All @@ -53,8 +51,7 @@ sub index_DELETE {
->get( { user => $c->user->id, module => $module } );
if ($star) {
$star->delete( { refresh => 1 } );
$self->status_ok( $c,
entity => $star->meta->get_data($star) );
$self->status_ok( $c, entity => $star->meta->get_data($star) );
}
else {
$self->status_not_found( $c, message => 'Entity could not be found' );
Expand Down
20 changes: 12 additions & 8 deletions t/server/controller/user/stargazer.t
Expand Up @@ -16,9 +16,9 @@ test_psgi app, sub {
POST '/user/stargazer?access_token=testing',
Content => encode_json(
{
module => 'Moose::Cookbook',
release => 'Moose-2.1209',
author => 'DOY'
module => 'Moose::Cookbook',
release => 'Moose-2.1209',
author => 'DOY'
}
)
),
Expand All @@ -30,8 +30,12 @@ test_psgi app, sub {
is( $res->code, 200, 'found' );
my $json = decode_json( $res->content );
is( $json->{user}, $user->{id}, 'user is ' . $user->{id} );
ok( $res = $cb->( DELETE "/user/stargazer/Moose::Cookbook?access_token=testing" ),
"DELETE /user/stargazer/MO/Moose::Cookbook" );
ok(
$res = $cb->(
DELETE "/user/stargazer/Moose::Cookbook?access_token=testing"
),
"DELETE /user/stargazer/MO/Moose::Cookbook"
);
is( $res->code, 200, 'status ok' );
ok( $res = $cb->( GET "$location?access_token=testing" ),
"GET $location" );
Expand All @@ -46,9 +50,9 @@ test_psgi app, sub {
POST '/user/stargazer?access_token=bot',
Content => encode_json(
{
module => 'Moose::Cookbook',
release => 'Moose-2.1209',
author => 'DOY'
module => 'Moose::Cookbook',
release => 'Moose-2.1209',
author => 'DOY'
}
)
),
Expand Down

0 comments on commit 6e135f2

Please sign in to comment.