[jifty-devel] I would like some feedback on my changes
Jason May
jason.a.may at gmail.com
Tue Nov 13 10:26:18 EST 2007
This is my first time applying test-driven development to anything,
and since I am committing this code, I would like some feedback first.
Thanks.
Index: AUTHORS
===================================================================
--- AUTHORS (revision 4422)
+++ AUTHORS (working copy)
@@ -33,3 +33,4 @@
Shawn M Moore <sartak at gmail.com>
Edward Funnekotter <efunneko at gmail.com>
Cornelius Lin <c9s at aiink.com>
+Jason May <jason.a.may at gmail.com>
Index: t/TestApp/t/19-group_by.t
===================================================================
--- t/TestApp/t/19-group_by.t (revision 0)
+++ t/TestApp/t/19-group_by.t (revision 0)
@@ -0,0 +1,39 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A test harness for User model.
+
+=cut
+
+use lib 't/lib';
+use Jifty::SubTest;
+
+use Jifty::Test skip_all => 'Not fully implemented yet';
+Jifty::Test->web;
+
+# Make sure we can load the model collection
+use_ok('TestApp::Model::UserCollection');
+
+# Grab a system user
+my $system_user = TestApp::CurrentUser->superuser;
+
+my $o = TestApp::Model::User->new(current_user => $system_user);
+$o->create(name => $$, score => $$, email => $$);
+$o->create(name => $$, score => $$+50, email => $$);
+$o->create(name => $$+1, score => $$+100, email => $$);
+$o->create(name => $$+1, score => $$+200, email => $$);
+
+my $c = TestApp::Model::UserCollection->new(current_user => $system_user);
+$c->unlimit;
+$c->column(column => 'name');
+$c->column(column => 'high_score', function => 'max(score)');
+$c->group_by(column => 'name');
+
+ok($c->build_select_query() =~ /group by/i,
+ 'GROUP BY clause successfully placed in the query');
+
+my $f = $c->first;
+ok($f, 'GROUP BY query syntax is functional');
Index: t/TestApp/lib/TestApp/Model/User.pm
===================================================================
--- t/TestApp/lib/TestApp/Model/User.pm (revision 4422)
+++ t/TestApp/lib/TestApp/Model/User.pm (working copy)
@@ -16,6 +16,8 @@
column 'email' =>
type is 'text',
is mandatory;
+column 'score' =>
+ type is 'integer';
column 'really_tasty' =>
type is 'boolean',
is immutable,
More information about the jifty-devel
mailing list