diff options
author | franck cuny <franck@lumberjaph.net> | 2011-02-13 16:20:14 +0100 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2011-02-13 16:20:14 +0100 |
commit | 932c7e9f0ddd47db4d8384dba9a692ffdb046b0c (patch) | |
tree | 898fd14726300d335cdaa11d38b2de868d3eb29d /t/003_hook_route.t | |
parent | inside the hook, we check if we can add more than one task for this (diff) | |
download | jitterbug-932c7e9f0ddd47db4d8384dba9a692ffdb046b0c.tar.gz |
add more tests
Diffstat (limited to '')
-rw-r--r-- | t/003_hook_route.t | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/t/003_hook_route.t b/t/003_hook_route.t index 8327755..11c7af4 100644 --- a/t/003_hook_route.t +++ b/t/003_hook_route.t @@ -1,4 +1,4 @@ -use Test::More tests => 11; +use Test::More tests => 13; use strict; use warnings; @@ -119,6 +119,48 @@ my $response; is $schema->resultset('Task')->search()->count(), 1, 'one task created since this branch is authorized for this project'; } +{ + $schema->resultset('Project')->search()->delete(); + $schema->resultset('Task')->search()->delete(); + + # this branch is forbiden for another project + setting jitterbug => { options => { stack_tasks => 0 } }; + for ( 1 .. 2 ) { + $content->{commits}->[0]->{id} = $_; + $response = dancer_response( + POST => '/hook/', + { + headers => + [ 'Content-Type' => 'application/x-www-form-urlencoded' ], + body => _generate_post_request($content), + } + ); + } + is $schema->resultset('Task')->search()->count(), 1, + 'can\'t stack tasks for this project'; +} + +{ + $schema->resultset('Project')->search()->delete(); + $schema->resultset('Task')->search()->delete(); + + # this branch is forbiden for another project + setting jitterbug => { options => { stack_tasks => 1 } }; + for ( 1 .. 2 ) { + $content->{commits}->[0]->{id} = $_; + $response = dancer_response( + POST => '/hook/', + { + headers => + [ 'Content-Type' => 'application/x-www-form-urlencoded' ], + body => _generate_post_request($content), + } + ); + } + is $schema->resultset('Task')->search()->count(), 2, + 'can stack tasks for this project'; +} + sub _generate_post_request { my $content = shift; my $payload = "payload=" . JSON::encode_json($content); |