Fix my bad spelling: fufill -> fulfill

This commit is contained in:
Bradley M. Kuhn 2015-12-20 14:01:15 -08:00
parent aff5e66786
commit ccfa057cce
2 changed files with 65 additions and 38 deletions

View file

@ -526,7 +526,7 @@ sub addRequest($$) {
}
######################################################################
=begin fufillRequest
=begin fulfillRequest
Arguments:
@ -546,7 +546,7 @@ A hash reference, the following keys are considered:
=item requestType
requestType of the request to be fulfilled. die() will occur if this is
undefined. undef is returned if there is no unfufilled request of
undefined. undef is returned if there is no unfulfilled request of
requestType in the database for supporter identified by
C<$params->{supporterId}>
@ -557,7 +557,7 @@ A hash reference, the following keys are considered:
=item how
A scalar string describing how the request was fufilled. It can safely be
A scalar string describing how the request was fulfilled. It can safely be
undefined.
=back
@ -568,23 +568,23 @@ Returns the id value of the request entry.
=cut
sub fufillRequest($$) {
sub fulfillRequest($$) {
my($self, $params) = @_;
die "fufillRequest: undefined supporterId" unless defined $params->{supporterId};
die "fulfillRequest: undefined supporterId" unless defined $params->{supporterId};
my $supporterId = $params->{supporterId};
die "fufillRequest: supporterId, \"$supporterId\" not found in supporter database"
die "fulfillRequest: supporterId, \"$supporterId\" not found in supporter database"
unless $self->_verifyId($supporterId);
die "fufillRequest: undefined who" unless defined $params->{who};
die "fufillRequest: undefined requestType" unless defined $params->{requestType};
die "fulfillRequest: undefined who" unless defined $params->{who};
die "fulfillRequest: undefined requestType" unless defined $params->{requestType};
my $requestId = $self->getRequest($supporterId, $params->{requestType});
return undef if not defined $requestId;
my $fufillLookupSql = "SELECT * FROM fulfillment WHERE request_id = " .
my $fulfillLookupSql = "SELECT * FROM fulfillment WHERE request_id = " .
$self->dbh->quote($requestId, 'SQL_INTEGER');
my $fufillRecord = $self->dbh()->selectall_hashref($fufillLookupSql, "request_id");
if (not defined $fufillRecord and not defined $fufillRecord->{$requestId}) {
my $fulfillRecord = $self->dbh()->selectall_hashref($fulfillLookupSql, "request_id");
if (not defined $fulfillRecord and not defined $fulfillRecord->{$requestId}) {
$self->_beginWork;
my $sth->prepare("INSERT INTO fulfillment(request_id, who, how, date) " .
"VALUES(? , ? , ? , date('now');");
@ -592,9 +592,9 @@ sub fufillRequest($$) {
$sth->execute($requestId, $params->{who}, $params->{how});
$sth->finish;
$self->_commit;
$fufillRecord = $self->dbh()->selectall_hashref($fufillLookupSql, "request_id");
$fulfillRecord = $self->dbh()->selectall_hashref($fulfillLookupSql, "request_id");
}
return $fufillRecord->{$requestId};
return $fulfillRecord->{$requestId};
}
######################################################################
@ -873,3 +873,30 @@ License: AGPLv3-or-later
# Local variables:
# compile-command: "perl -c Supporters.pm"
# End:
sub Supporter_FullLookupUsingId($$) {
my($dbh, $id) = @_;
my $sth = $dbh->prepare('SELECT m.supporter_id ' .
'FROM email_address e, supporter_email_address_mapping m ' .
'WHERE e.email_address = ? and e.id = m.email_address_id');
$sth->execute($email);
}
###############################################################################
sub Supporter_LookupByEmail($$) {
my($dbh, $email) = @_;
my $sth = $dbh->prepare('SELECT m.supporter_id ' .
'FROM email_address e, supporter_email_address_mapping m ' .
'WHERE e.email_address = ? and e.id = m.email_address_id');
$sth->execute($email);
my $supporter = $sth->fetchrow_hashref();
if (defined $supporter) {
return Supporter_FullLookupUsingId($dbh, $supporter->{'m.supporter_id'});
} else {
return undef;
}

View file

@ -289,72 +289,72 @@ ok( (defined $tShirt0RequestId and looks_like_number($tShirt0RequestId) and $tSh
"addRequest: another successful call returns an integer id.");
=item fufillRequest
=item fulfillRequest
=cut
my $fufillRequestId;
my $fulfillRequestId;
dies_ok { $fufillRequestId = $sp->fufillRequest( { requestType => "t-shirt-small-only", who => 'joe',
dies_ok { $fulfillRequestId = $sp->fulfillRequest( { requestType => "t-shirt-small-only", who => 'joe',
how => "in-person delivery" }); }
"fufillRequest: dies if supporterId not specified";
"fulfillRequest: dies if supporterId not specified";
dies_ok { $fufillRequestId = $sp->fufillRequest( { supporterId => $drapperId + 1000,
dies_ok { $fulfillRequestId = $sp->fulfillRequest( { supporterId => $drapperId + 1000,
requestType => "t-shirt-small-only", who => 'joe',
how => "in-person delivery" }); }
"fufillRequest: dies if supporterId not found in database";
"fulfillRequest: dies if supporterId not found in database";
dies_ok { $fufillRequestId = $sp->fufillRequest( { supporterId => $drapperId, who => 'joe',
dies_ok { $fulfillRequestId = $sp->fulfillRequest( { supporterId => $drapperId, who => 'joe',
how => "in-person delivery" }); }
"fufillRequest: dies if requestType not specified";
"fulfillRequest: dies if requestType not specified";
dies_ok { $fufillRequestId = $sp->fufillRequest( { supporterId => $drapperId,
dies_ok { $fulfillRequestId = $sp->fulfillRequest( { supporterId => $drapperId,
requestType => "t-shirt-small-only",
how => "in-person delivery" }); }
"fufillRequest: who not specified";
"fulfillRequest: who not specified";
lives_ok { $fufillRequestId = $sp->fufillRequest( { supporterId => $drapperId,
lives_ok { $fulfillRequestId = $sp->fulfillRequest( { supporterId => $drapperId,
requestType => "t-shirt-small-only", who => 'joe',
how => "in-person delivery" }); }
"fufillRequest: succeeds for existing request";
"fulfillRequest: succeeds for existing request";
ok( (defined $fufillRequestId and looks_like_number($fufillRequestId) and $fufillRequestId > 0),
"fufillRequest: id returned on successful fufillRequest() is a number");
ok( (defined $fulfillRequestId and looks_like_number($fulfillRequestId) and $fulfillRequestId > 0),
"fulfillRequest: id returned on successful fulfillRequest() is a number");
lives_ok { $val = $sp->dbh()->selectall_hashref("SELECT id, date, who, how, request_id FROM fulfillment", 'id'); }
"fufillRequest: sql command in database for entry succeeds.";
is_deeply($val, { $fufillRequestId => { id => $fufillRequestId, date => $today,
"fulfillRequest: sql command in database for entry succeeds.";
is_deeply($val, { $fulfillRequestId => { id => $fulfillRequestId, date => $today,
how => 'in-person delivery', who => 'joe',
request_id => $tshirtSmallRequestId } },
"fufillRequest: databse etnry from successful return is correct");
"fulfillRequest: databse etnry from successful return is correct");
ok((defined $val and (keys(%$val) == 0)),
"_getOrCreateRequestConfiguration: no request_configuration record added for failed attempts");
my $badFR;
lives_ok { $badFR = $sp->fufillRequest( { supporterId => $drapperId, who => 'john',
lives_ok { $badFR = $sp->fulfillRequest( { supporterId => $drapperId, who => 'john',
requestType => "does-not-exist",
how => "in-person delivery" }); }
"fufillRequest: attempt to fulfill a request never made does not die...";
"fulfillRequest: attempt to fulfill a request never made does not die...";
ok( (not defined $badFR),
"fufillRequest: ... but, rather, returns undef.");
"fulfillRequest: ... but, rather, returns undef.");
is($sp->getRequestType("does-not-exist"), undef,
"fufillRequest: requestType not created when fufillRequest fails.");
"fulfillRequest: requestType not created when fulfillRequest fails.");
my $val2;
lives_ok { $val2 = $sp->fufillRequest( { supporterId => $drapperId,
lives_ok { $val2 = $sp->fulfillRequest( { supporterId => $drapperId,
requestType => "t-shirt-small-only", who => 'peggy',
how => "left in his office." }); }
"fufillRequest: attempt to fulfill an already-fulfill request does not die ...";
"fulfillRequest: attempt to fulfill an already-fulfill request does not die ...";
is_deeply($val2, $val,
"fufillRequest: ... but, rather, returns the same values from the previous fufillRequest() call.");
"fulfillRequest: ... but, rather, returns the same values from the previous fulfillRequest() call.");
=item getRequest
@ -377,7 +377,7 @@ lives_ok { $tt = $sp->getRequest({ supporterId => $drapperId, requestType => 't-
"getRequest: succeeds with valid parameters.";
is($tt->{requestType}, 't-shirt-small-only', "getRequest: requestType is correct.");
is($tt->{fufillDate}, $today, "getRequest: fufilled request is today.");
is($tt->{fulfillDate}, $today, "getRequest: fulfilled request is today.");
is($tt->{requestDate}, $today, "getRequest: request date is today.");
is($tt->{requestConfiguration}, 'Small', "getRequest: configuration is correct.");
is($tt->{notes}, 'he probably needs a larger size but this shirt has none',