root/veekun/trunk/t/shoutbox.t

Revision 406, 1.2 kB (checked in by eevee, 10 months ago)

Database refactoring. Renamed columns and tables to be more consistent and more readable. (#58)

Line 
1use strict;
2use warnings;
3
4use HTTP::Request::Common;
5use Test::More 'no_plan';
6
7BEGIN { $ENV{CATALYST_DEBUG} = 0; }
8BEGIN { $ENV{VEEKUN_USE_TEMP_DB} = 1; }
9BEGIN { use_ok 'Catalyst::Test', 'Vee' }
10BEGIN { use_ok 'Vee::Controller::Shoutbox' }
11
12# TODO put this stuff in Veekun::Test somewhere, create_fake_user
13# FIXME I can't seem to get this to create a cookie and stay cookied!
14#my $password = random_string( '.' x (6 + int rand 6) );
15#my $user = Vee->model('DBIC::Users')->create( {
16#    name => 'testuser',
17#    password => sha1_hex($password),
18#} );
19
20
21my $posted_res = request( POST '/shoutbox/post' => {
22    name    => 'Tester',
23    content => 'Test message',
24} );
25ok $posted_res->is_redirect, 'Shoutbox post results in redirect';
26
27my $shout = Vee->model('DBIC::Shoutbox')->search( undef, {
28    order_by => 'id DESC',
29} )->first;
30
31ok defined $shout, 'Shoutbox table contains a shout';
32is $shout->name, 'Tester', 'Shout name is correct';
33is $shout->content, 'Test message', 'Shout message is correct';
34ok !defined $shout->user_id, 'Shout user is NULL';
35ok abs($shout->time - time) < 3, 'Shout time is reasonably close to now';
36
37
38
39my $shoutbox = request('/shoutbox');
40ok $shoutbox->is_success, 'Shoutbox history request';
Note: See TracBrowser for help on using the browser.