diff options
author | sunnavy <sunnavy@bestpractical.com> | 2022-01-07 21:44:58 +0300 |
---|---|---|
committer | sunnavy <sunnavy@bestpractical.com> | 2022-01-07 21:48:59 +0300 |
commit | fadcd86dafd1adfeaaacfe36d0e3175445653651 (patch) | |
tree | 9bf6a56b1a61ded06e32d57b3beffbb20040262b | |
parent | 9bc84cc90eb1b77d402b6d45426caf822aa05b36 (diff) |
Test articles custom field searches without specifying a custom field5.0/articles-limit-custom-field-object-type
-rw-r--r-- | t/articles/cfsearch.t | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/t/articles/cfsearch.t b/t/articles/cfsearch.t index 3bfa667eea..1c2858f991 100644 --- a/t/articles/cfsearch.t +++ b/t/articles/cfsearch.t @@ -2,7 +2,7 @@ use strict; use warnings; -use RT::Test tests => 11; +use RT::Test tests => undef; my $suffix = '-'. $$; @@ -91,3 +91,38 @@ $article2->AddCustomFieldValue(Field => $cf->Id, Value => 'Value2'); is $articles->Count, 1, 'found correct number of articles'; } +diag "Search any custom field"; + +# Makes sure to not search non-article custom fields +my $class_cf = RT::CustomField->new( RT->SystemUser ); +my ( $ret, $msg ) = $class_cf->Create( + Name => 'Class CF', + LookupType => 'RT::Class', + Type => 'Freeform', + MaxValues => 1, +); +ok $ret, $msg; + +( $ret, $msg ) = $class_cf->AddToObject($class); +ok $ret, $msg; + +( $ret, $msg ) = $class->AddCustomFieldValue( Field => $class_cf, Value => 'Class Foo' ); +ok $ret, $msg; + +{ + my $articles = RT::Articles->new($RT::SystemUser); + $articles->UnLimit(); + $articles->Limit( FIELD => "Class", SUBCLAUSE => 'ClassMatch', VALUE => $class->Id ); + $articles->LimitCustomField( VALUE => 'Value1' ); + is $articles->Count, 1, 'found correct number of articles'; +} + +{ + my $articles = RT::Articles->new($RT::SystemUser); + $articles->UnLimit(); + $articles->Limit( FIELD => "Class", SUBCLAUSE => 'ClassMatch', VALUE => $class->Id ); + $articles->LimitCustomField( VALUE => 'Class Foo' ); + is $articles->Count, 0, 'found correct number of articles'; +} + +done_testing; |