Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
242 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use inc::Module::Install; | ||
|
||
name 'TestApp'; | ||
version '0.01'; | ||
requires 'Jifty' => '0.90409'; | ||
|
||
WriteAll; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env perl | ||
use warnings; | ||
use strict; | ||
use UNIVERSAL::require; | ||
|
||
BEGIN { | ||
Jifty::Util->require or die $UNIVERSAL::require::ERROR; | ||
my $root = Jifty::Util->app_root(quiet => 1); | ||
unshift @INC, "$root/lib" if ($root); | ||
} | ||
|
||
use Jifty; | ||
use Jifty::Script; | ||
|
||
local $SIG{INT} = sub { warn "Stopped\n"; exit; }; | ||
Jifty::Script->dispatch(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
--- | ||
framework: | ||
AdminMode: 1 | ||
ApplicationClass: TestApp | ||
ApplicationName: TestApp | ||
ApplicationUUID: AB1AAC7A-2F31-11DE-94B8-5EDD63EE90E3 | ||
ConfigFileVersion: 4 | ||
Database: | ||
AutoUpgrade: 1 | ||
CheckSchema: 1 | ||
Database: testapp | ||
Driver: SQLite | ||
Host: localhost | ||
Password: '' | ||
RecordBaseClass: Jifty::DBI::Record::Cachable | ||
User: '' | ||
Version: 0.0.1 | ||
DevelMode: 1 | ||
L10N: | ||
PoDir: share/po | ||
LogLevel: INFO | ||
Mailer: Sendmail | ||
MailerArgs: [] | ||
|
||
Plugins: | ||
- | ||
AdminUI: {} | ||
|
||
- | ||
CompressedCSSandJS: {} | ||
|
||
- | ||
ErrorTemplates: {} | ||
|
||
- | ||
Halo: {} | ||
|
||
- | ||
LetMe: {} | ||
|
||
- | ||
OnlineDocs: {} | ||
|
||
- | ||
REST: {} | ||
|
||
- | ||
SkeletonApp: {} | ||
|
||
PubSub: | ||
Backend: Memcached | ||
Enable: ~ | ||
SkipAccessControl: 0 | ||
TemplateClass: TestApp::View | ||
View: | ||
Handlers: | ||
- Jifty::View::Static::Handler | ||
- Jifty::View::Declare::Handler | ||
- Jifty::View::Mason::Handler | ||
Web: | ||
BaseURL: http://localhost | ||
DataDir: var/mason | ||
Globals: [] | ||
|
||
MasonConfig: | ||
autoflush: 0 | ||
default_escape_flags: h | ||
error_format: text | ||
error_mode: fatal | ||
Port: 8888 | ||
ServeStaticFiles: 1 | ||
StaticRoot: share/web/static | ||
TemplateRoot: share/web/templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use strict; | ||
use warnings; | ||
|
||
package TestApp::Model::Labels; | ||
use Jifty::DBI::Schema; | ||
|
||
use TestApp::Record schema { | ||
|
||
column name => | ||
type is 'varchar'; | ||
|
||
column hit => | ||
type is 'integer'; | ||
|
||
column posts => | ||
refers_to 'TestApp::Model::PostsCollection'; | ||
|
||
}; | ||
|
||
# Your model-specific methods go here. | ||
|
||
1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use strict; | ||
use warnings; | ||
|
||
package TestApp::Model::Posts; | ||
use Jifty::DBI::Schema; | ||
|
||
use TestApp::Record schema { | ||
|
||
}; | ||
|
||
# Your model-specific methods go here. | ||
|
||
1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env perl | ||
use warnings; | ||
use strict; | ||
|
||
=head1 DESCRIPTION | ||
A basic test harness for the Labels model. | ||
=cut | ||
|
||
use Jifty::Test tests => 11; | ||
|
||
# Make sure we can load the model | ||
use_ok('TestApp::Model::Labels'); | ||
|
||
# Grab a system user | ||
my $system_user = TestApp::CurrentUser->superuser; | ||
ok($system_user, "Found a system user"); | ||
|
||
# Try testing a create | ||
my $o = TestApp::Model::Labels->new(current_user => $system_user); | ||
my ($id) = $o->create(); | ||
ok($id, "Labels create returned success"); | ||
ok($o->id, "New Labels has valid id set"); | ||
is($o->id, $id, "Create returned the right id"); | ||
|
||
# And another | ||
$o->create(); | ||
ok($o->id, "Labels create returned another value"); | ||
isnt($o->id, $id, "And it is different from the previous one"); | ||
|
||
# Searches in general | ||
my $collection = TestApp::Model::LabelsCollection->new(current_user => $system_user); | ||
$collection->unlimit; | ||
is($collection->count, 2, "Finds two records"); | ||
|
||
# Searches in specific | ||
$collection->limit(column => 'id', value => $o->id); | ||
is($collection->count, 1, "Finds one record with specific id"); | ||
|
||
# Delete one of them | ||
$o->delete; | ||
$collection->redo_search; | ||
is($collection->count, 0, "Deleted row is gone"); | ||
|
||
# And the other one is still there | ||
$collection->unlimit; | ||
is($collection->count, 1, "Still one left"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env perl | ||
use warnings; | ||
use strict; | ||
|
||
=head1 DESCRIPTION | ||
A basic test harness for the Posts model. | ||
=cut | ||
|
||
use Jifty::Test tests => 11; | ||
|
||
# Make sure we can load the model | ||
use_ok('TestApp::Model::Posts'); | ||
|
||
# Grab a system user | ||
my $system_user = TestApp::CurrentUser->superuser; | ||
ok($system_user, "Found a system user"); | ||
|
||
# Try testing a create | ||
my $o = TestApp::Model::Posts->new(current_user => $system_user); | ||
my ($id) = $o->create(); | ||
ok($id, "Posts create returned success"); | ||
ok($o->id, "New Posts has valid id set"); | ||
is($o->id, $id, "Create returned the right id"); | ||
|
||
# And another | ||
$o->create(); | ||
ok($o->id, "Posts create returned another value"); | ||
isnt($o->id, $id, "And it is different from the previous one"); | ||
|
||
# Searches in general | ||
my $collection = TestApp::Model::PostsCollection->new(current_user => $system_user); | ||
$collection->unlimit; | ||
is($collection->count, 2, "Finds two records"); | ||
|
||
# Searches in specific | ||
$collection->limit(column => 'id', value => $o->id); | ||
is($collection->count, 1, "Finds one record with specific id"); | ||
|
||
# Delete one of them | ||
$o->delete; | ||
$collection->redo_search; | ||
is($collection->count, 0, "Deleted row is gone"); | ||
|
||
# And the other one is still there | ||
$collection->unlimit; | ||
is($collection->count, 1, "Still one left"); | ||
|