diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-10-05 10:39:01 +0200 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-10-05 10:39:01 +0200 |
commit | 7307c8c748e3245d65a25c016e7d92c6c7ae2aa4 (patch) | |
tree | 97fa8ea6b7482fad71cecc5195c2a81e6cc866c8 /xt/lib/Bugzilla | |
parent | daa533e7c6d1c6ff2e8600c5178ac75bf7a2538c (diff) | |
download | bugzilla-7307c8c748e3245d65a25c016e7d92c6c7ae2aa4.tar.gz bugzilla-7307c8c748e3245d65a25c016e7d92c6c7ae2aa4.tar.xz |
Bug 26074 - Ability to limit search by number of Comments
r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'xt/lib/Bugzilla')
-rw-r--r-- | xt/lib/Bugzilla/Test/Search.pm | 9 | ||||
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/Constants.pm | 19 | ||||
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/FieldTest.pm | 5 | ||||
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/InjectionTest.pm | 6 |
4 files changed, 36 insertions, 3 deletions
diff --git a/xt/lib/Bugzilla/Test/Search.pm b/xt/lib/Bugzilla/Test/Search.pm index 02ff48a80..73bb86dfd 100644 --- a/xt/lib/Bugzilla/Test/Search.pm +++ b/xt/lib/Bugzilla/Test/Search.pm @@ -667,6 +667,13 @@ sub _create_one_bug { undef, $bug->id); } + # Bug 1 gets three comments, so that longdescs.count matches it + # uniquely. The third comment is added in the middle, so that the + # last comment contains all of the important data, like work_time. + if ($number == 1) { + $bug->add_comment("1-comment-" . random(100)); + } + my %update_params = %{ $self->_bug_update_values->{$number} }; my %reverse_map = reverse %{ Bugzilla::Bug->FIELD_MAP }; foreach my $db_name (keys %reverse_map) { @@ -712,7 +719,7 @@ sub _create_one_bug { $update_params{reporter_accessible} = $number == 1 ? 1 : 0; $update_params{cclist_accessible} = $number == 1 ? 1 : 0; $update_params{alias} = $update_alias; - + $bug->set_all(\%update_params); my $flags = $self->bug_create_value($number, 'set_flags')->{b}; $bug->set_flags([], $flags); diff --git a/xt/lib/Bugzilla/Test/Search/Constants.pm b/xt/lib/Bugzilla/Test/Search/Constants.pm index c0dfe30c8..de96ba1d2 100644 --- a/xt/lib/Bugzilla/Test/Search/Constants.pm +++ b/xt/lib/Bugzilla/Test/Search/Constants.pm @@ -309,6 +309,7 @@ use constant CHANGED_VALUE_BROKEN => ( estimated_time => { contains => [1] }, 'flagtypes.name' => { contains => [1] }, keywords => { contains => [1] }, + 'longdescs.count' => { search => 1 }, work_time => { contains => [1] }, FIELD_TYPE_MULTI_SELECT, { contains => [1] }, ); @@ -511,6 +512,7 @@ use constant CHANGED_BROKEN_NOT => ( # For changedfrom and changedto. use constant CHANGED_FROM_TO_BROKEN_NOT => ( + 'longdescs.count' => { search => 1 }, "bug_group" => { contains => [1] }, "cc" => { contains => [1] }, "cf_multi_select" => { contains => [1] }, @@ -737,6 +739,7 @@ use constant REGEX_OVERRIDE => { cclist_accessible => { value => '^1' }, reporter_accessible => { value => '^1' }, everconfirmed => { value => '^1' }, + 'longdescs.count' => { value => '^3' }, 'longdescs.isprivate' => { value => '^1' }, creation_ts => { value => '^2037-01-01' }, delta_ts => { value => '^2037-01-01' }, @@ -808,6 +811,7 @@ use constant NEGATIVE_MULTI_BOOLEAN_OVERRIDE => ( # For anyexact and anywordssubstr use constant ANY_OVERRIDE => ( + 'longdescs.count' => { contains => [1,2,3,4] }, 'work_time' => { value => '1.0,2.0' }, dependson => { value => '<1>,<3>', contains => [1,3] }, MULTI_BOOLEAN_OVERRIDE, @@ -944,6 +948,7 @@ use constant TESTS => { 'attachments.ispatch' => { value => 1, contains => [2,3,4] }, cclist_accessible => { value => 1, contains => [2,3,4,5] }, reporter_accessible => { value => 1, contains => [2,3,4,5] }, + 'longdescs.count' => { value => 3, contains => [2,3,4,5] }, 'longdescs.isprivate' => { value => 1, contains => [2,3,4,5] }, everconfirmed => { value => 1, contains => [2,3,4,5] }, creation_ts => { value => '2037-01-02', contains => [1,5] }, @@ -967,6 +972,7 @@ use constant TESTS => { 'attachments.isprivate' => { value => 0, contains => [2,3,4] }, cclist_accessible => { value => 0, contains => [2,3,4,5] }, reporter_accessible => { value => 0, contains => [2,3,4,5] }, + 'longdescs.count' => { value => 2, contains => [2,3,4,5] }, 'longdescs.isprivate' => { value => 0, contains => [2,3,4,5] }, everconfirmed => { value => 0, contains => [2,3,4,5] }, blocked => { contains => [1,2] }, @@ -991,6 +997,7 @@ use constant TESTS => { 'attachments.isprivate' => { value => 0, contains => [1] }, cclist_accessible => { value => 0, contains => [1] }, reporter_accessible => { value => 0, contains => [1] }, + 'longdescs.count' => { value => 2, contains => [1] }, 'longdescs.isprivate' => { value => 0, contains => [1] }, everconfirmed => { value => 0, contains => [1] }, 'flagtypes.name' => { value => 2, contains => [2,3,4] }, @@ -1006,6 +1013,7 @@ use constant TESTS => { 'attachments.isprivate' => { value => 1, contains => [1] }, cclist_accessible => { value => 1, contains => [1] }, reporter_accessible => { value => 1, contains => [1] }, + 'longdescs.count' => { value => 3, contains => [1] }, 'longdescs.isprivate' => { value => 1, contains => [1] }, everconfirmed => { value => 1, contains => [1] }, dependson => { value => '<3>', contains => [1,3] }, @@ -1074,6 +1082,7 @@ use constant TESTS => { override => { MULTI_BOOLEAN_OVERRIDE, dependson => { value => '<1> <3>', contains => [1,3] }, + 'longdescs.count' => { contains => [1,2,3,4] }, work_time => { value => '1.0 2.0' }, }, }, @@ -1109,6 +1118,7 @@ use constant TESTS => { blocked => { contains => [1,2] }, dependson => { contains => [1,3] }, longdesc => { contains => [1,5] }, + 'longdescs.count' => { contains => [1,5] }, } }, ], @@ -1195,6 +1205,15 @@ use constant INJECTION_BROKEN_FIELD => { FIELD_TYPE_BUG_ID, { db_skip => ['Pg'] }, FIELD_TYPE_DATETIME, { db_skip => ['Pg'] }, owner_idle_time => { search => 1 }, + 'longdescs.count' => { + search => 1, + db_skip => ['Pg'], + operator_ok => [qw(allwordssubstr anywordssubstr casesubstring + changedbefore changedafter greaterthan greaterthaneq + lessthan lessthaneq notregexp notsubstring + nowordssubstr regexp substring anywords + notequals nowords)], + }, keywords => { search => 1, operator_ok => [qw(allwordssubstr anywordssubstr casesubstring diff --git a/xt/lib/Bugzilla/Test/Search/FieldTest.pm b/xt/lib/Bugzilla/Test/Search/FieldTest.pm index 532936e91..fd3c7b6c7 100644 --- a/xt/lib/Bugzilla/Test/Search/FieldTest.pm +++ b/xt/lib/Bugzilla/Test/Search/FieldTest.pm @@ -332,6 +332,9 @@ sub _field_values_for_bug { # searches use the last comment. @values = reverse @values; } + elsif ($field eq 'longdescs.count') { + @values = scalar(@{ $self->bug($number)->comments }); + } elsif ($field eq 'bug_group') { @values = $self->_values_for($number, 'groups_in', 'name'); } @@ -515,7 +518,7 @@ sub do_tests { my $search_broken = $self->search_known_broken; my $search = $self->_test_search_object_creation(); - + my $sql; TODO: { local $TODO = $search_broken if $search_broken; diff --git a/xt/lib/Bugzilla/Test/Search/InjectionTest.pm b/xt/lib/Bugzilla/Test/Search/InjectionTest.pm index 1bd9fd82c..41f5fcdc2 100644 --- a/xt/lib/Bugzilla/Test/Search/InjectionTest.pm +++ b/xt/lib/Bugzilla/Test/Search/InjectionTest.pm @@ -54,7 +54,11 @@ sub sql_error_ok { return $_[0]->_known_broken->{sql_error} } # Injection tests only skip fields on certain dbs. sub field_not_yet_implemented { my ($self) = @_; - my $skip_for_dbs = $self->_known_broken->{db_skip}; + # We use the constant directly because we don't want operator_ok + # or field_ok to stop us. + my $broken = INJECTION_BROKEN_FIELD->{$self->field} + || INJECTION_BROKEN_FIELD->{$self->field_object->type}; + my $skip_for_dbs = $broken->{db_skip}; return undef if !$skip_for_dbs; my $dbh = Bugzilla->dbh; if (my ($skip) = grep { $dbh->isa("Bugzilla::DB::$_") } @$skip_for_dbs) { |