[Rt-commit] r2634 - in rt/branches/3.4-RELEASE/lib: RT t/regression
tla at bestpractical.com
tla at bestpractical.com
Fri Apr 15 17:21:26 EDT 2005
Author: tla
Date: Fri Apr 15 17:21:25 2005
New Revision: 2634
Modified:
rt/branches/3.4-RELEASE/lib/RT/SavedSearch.pm
rt/branches/3.4-RELEASE/lib/t/regression/20savedsearch.t
Log:
Added ability to update name as well as search parameters.
Modified: rt/branches/3.4-RELEASE/lib/RT/SavedSearch.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/SavedSearch.pm (original)
+++ rt/branches/3.4-RELEASE/lib/RT/SavedSearch.pm Fri Apr 15 17:21:25 2005
@@ -170,23 +170,27 @@
=head2 Update
-Updates the parameters of an existing search. Takes a hashref with
-the new parameters.
+Updates the parameters of an existing search. Takes the arguments
+"Name" and "SearchParams"; SearchParams should be a hashref containing
+the new parameters of the search. If Name is not specified, the name
+will not be changed.
=cut
sub Update {
my $self = shift;
- my $params = shift;
+ my %args = ('Name' => '',
+ 'SearchParams' => {},
+ @_);
return(0, $self->loc("No search loaded")) unless $self->Id;
return(0, $self->loc("Could not load search attribute"))
unless $self->{'Attribute'}->Id;
- my ($status, $msg) = $self->{'Attribute'}->SetSubValues(%{$params});
- if ($status) {
- # Update all the accessor variables.
- return ($status, $self->loc("Search update: [_1]", $msg));
+ my ($status, $msg) = $self->{'Attribute'}->SetSubValues(%{$args{'SearchParams'}});
+ if ($status && $args{'Name'}) {
+ ($status, $msg) = $self->{'Attribute'}->SetDescription($args{'Name'});
}
+ return ($status, $self->loc("Search update: [_1]", $msg));
}
=head2 Delete
Modified: rt/branches/3.4-RELEASE/lib/t/regression/20savedsearch.t
==============================================================================
--- rt/branches/3.4-RELEASE/lib/t/regression/20savedsearch.t (original)
+++ rt/branches/3.4-RELEASE/lib/t/regression/20savedsearch.t Fri Apr 15 17:21:25 2005
@@ -147,8 +147,8 @@
isnt($loadedsearch4->Id, $othersearch->Id, "Did not load othersearch");
# Try to update an existing search.
-$loadedsearch1->Update({'Format' => $format,
- 'Query' => "Queue = '" . $queue->Name . "'" });
+$loadedsearch1->Update( SearchParams => {'Format' => $format,
+ 'Query' => "Queue = '" . $queue->Name . "'" } );
like($loadedsearch1->GetParameter('Query'), qr/Queue/,
"Updated mysearch parameter");
is($loadedsearch1->Type, 'Ticket', "mysearch is still for tickets");
More information about the Rt-commit
mailing list