[Jifty-commit] r4958 - in jifty/branches/jquery/t/TestApp-JiftyJS: lib/TestApp/JiftyJS/Model

Jifty commits jifty-commit at lists.jifty.org
Tue Jan 29 05:27:46 EST 2008


Author: gugod
Date: Tue Jan 29 05:27:41 2008
New Revision: 4958

Added:
   jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Model/Offer.pm
   jifty/branches/jquery/t/TestApp-JiftyJS/t/00-model-Offer.t
   jifty/branches/jquery/t/TestApp-JiftyJS/t/6-offer-actions.t

Log:
Add a test to ensure when a Checkbox is unchecked, after
the form is submitted, the result should also be unchecked.

This test was failure against the code several revisions before.


Added: jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Model/Offer.pm
==============================================================================
--- (empty file)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/lib/TestApp/JiftyJS/Model/Offer.pm	Tue Jan 29 05:27:41 2008
@@ -0,0 +1,22 @@
+use strict;
+use warnings;
+
+package TestApp::JiftyJS::Model::Offer;
+use Jifty::DBI::Schema;
+
+use TestApp::JiftyJS::Record schema {
+    column name =>
+        type is "varchar(255)";
+
+    column is_job =>
+        type is "boolean",
+        label is _("Job Offer ?");
+
+};
+
+sub current_user_can {
+    1;
+}
+
+1;
+

Added: jifty/branches/jquery/t/TestApp-JiftyJS/t/00-model-Offer.t
==============================================================================
--- (empty file)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/t/00-model-Offer.t	Tue Jan 29 05:27:41 2008
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the Offer model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('TestApp::JiftyJS::Model::Offer');
+
+# Grab a system user
+my $system_user = TestApp::JiftyJS::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = TestApp::JiftyJS::Model::Offer->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "Offer create returned success");
+ok($o->id, "New Offer has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "Offer create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection =  TestApp::JiftyJS::Model::OfferCollection->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");
+

Added: jifty/branches/jquery/t/TestApp-JiftyJS/t/6-offer-actions.t
==============================================================================
--- (empty file)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/t/6-offer-actions.t	Tue Jan 29 05:27:41 2008
@@ -0,0 +1,63 @@
+# This test is for testing Jifty.update() javascript function.
+
+use strict;
+use warnings;
+use lib 't/lib';
+use Jifty::SubTest;
+use Jifty::Test;;
+use Jifty::Test::WWW::Selenium;
+use utf8;
+
+
+$/ = undef;
+my @commands = split /\n\n/, <DATA>;
+
+plan tests => 2+ at commands;
+
+my $server = Jifty::Test->make_server;
+my $sel    = Jifty::Test::WWW::Selenium->rc_ok($server);
+my $URL    = $server->started_ok;
+
+for (@commands) {
+    my ($cmd, $arg1, $arg2) = (split(/\n\s*/, $_, 3), "", "");
+
+    if ($cmd eq 'verify_text') {
+        $arg2 =~ s/\s*$//;
+        $arg2 =~ s/^\s*//;
+
+        my $txt = $sel->get_text($arg1);
+        is($txt, $arg2);
+    }
+    else {
+        $cmd .= "_ok";
+        $sel->$cmd($arg1, $arg2);
+    }
+}
+$sel->stop;
+
+__DATA__
+open
+    /__jifty/admin/model/Offer
+
+type
+    xpath=//div[contains(@class, "jifty_admin create item")]//input[contains(@type, "text")]
+    Not A Job Offer
+
+click
+    xpath=//div[contains(@class,"submit_button")]/input
+
+pause
+    1000
+
+wait_for_text_present
+    Not A Job Offer
+
+wait_for_element_present
+    xpath=//span[contains(@class, "text argument-name value")]
+
+wait_for_element_present
+    xpath=//input[@type="checkbox"][@disabled="disabled"]
+
+get_text
+    xpath=//span[contains(@class, "text argument-name value")]
+    Not A Job Offer


More information about the Jifty-commit mailing list