summaryrefslogtreecommitdiffstats
path: root/xt/lib/Bugzilla/Test/Search/FieldTest.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-18 11:12:27 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-18 11:12:27 +0200
commitaef5cb18c3f2f6e1a438faed08e944af9db4847c (patch)
treeb62a393b0ac38cfc1a4766aad80348f46792039d /xt/lib/Bugzilla/Test/Search/FieldTest.pm
parent7b5e8372bf4306cf99eddb474bd8b7754510a683 (diff)
downloadbugzilla-aef5cb18c3f2f6e1a438faed08e944af9db4847c.tar.gz
bugzilla-aef5cb18c3f2f6e1a438faed08e944af9db4847c.tar.xz
Bug 579695: Make xt/search.t do substring tests using a more consistent
substring length, thus fixing an intermittent failure that would show up when searching the cf_multi_select field. r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'xt/lib/Bugzilla/Test/Search/FieldTest.pm')
-rw-r--r--xt/lib/Bugzilla/Test/Search/FieldTest.pm18
1 files changed, 16 insertions, 2 deletions
diff --git a/xt/lib/Bugzilla/Test/Search/FieldTest.pm b/xt/lib/Bugzilla/Test/Search/FieldTest.pm
index f8186c5b3..b5f6d2334 100644
--- a/xt/lib/Bugzilla/Test/Search/FieldTest.pm
+++ b/xt/lib/Bugzilla/Test/Search/FieldTest.pm
@@ -461,13 +461,27 @@ sub _translate_value_for_bug {
sub _substr_value {
my ($self, $value) = @_;
my $field = $self->field;
+ my $type = $self->field_object->type;
my $substr_size = SUBSTR_SIZE;
if (exists FIELD_SUBSTR_SIZE->{$field}) {
$substr_size = FIELD_SUBSTR_SIZE->{$field};
}
-
+ elsif (exists FIELD_SUBSTR_SIZE->{$type}) {
+ $substr_size = FIELD_SUBSTR_SIZE->{$type};
+ }
if ($substr_size > 0) {
- return substr($value, 0, $substr_size);
+ # The field name is included in every field value, and if it's
+ # long, it might take up the whole substring, and we don't want that.
+ if (!grep { $_ eq $field or $_ eq $type } SUBSTR_NO_FIELD_ADD) {
+ $substr_size += length($field);
+ }
+ my $string = substr($value, 0, $substr_size);
+ # Make percentage_complete substrings strings match integers uniquely,
+ # by searching for the full decimal number.
+ if ($field eq 'percentage_complete' and length($string) < $substr_size) {
+ $string .= ".000";
+ }
+ return $string;
}
return substr($value, $substr_size);
}