[Rt-commit] rt branch, 5.0/articles-unique-only-within-own-class, updated. rt-5.0.1-5-g56ac13ff5b
Steve Burr
steve at bestpractical.com
Tue May 18 14:54:01 EDT 2021
The branch, 5.0/articles-unique-only-within-own-class has been updated
via 56ac13ff5b55c11349d891d89353ce6cb80f6928 (commit)
via 4b98e51eeafcabb202f143cd8a1c19e63cff402e (commit)
from 211daa251735722dd84d5f7f14383169a55e31eb (commit)
Summary of changes:
lib/RT/Article.pm | 6 ++----
t/articles/article.t | 23 ++++++++++++++++++++++-
2 files changed, 24 insertions(+), 5 deletions(-)
- Log -----------------------------------------------------------------
commit 4b98e51eeafcabb202f143cd8a1c19e63cff402e
Author: Steven Burr <steve at bestpractical.com>
Date: Tue May 18 14:00:26 2021 -0400
Allow resetting to the same name
diff --git a/lib/RT/Article.pm b/lib/RT/Article.pm
index a8f3719c56..5e99391bc3 100644
--- a/lib/RT/Article.pm
+++ b/lib/RT/Article.pm
@@ -252,15 +252,14 @@ sub ValidateName {
$articles->Limit( FIELD => 'Name', OPERATOR => '=', VALUE => $name ); # cannot use LimitName() as it hardcodes 'LIKE'
$articles->Limit( FIELD => 'Class', OPERATOR => '=', VALUE => $class_id );
while ( my $article = $articles->Next ) {
- if ( $article->id && ( !$self->id || ($article->id))) {
+ if ( $article->id && ( !$self->id || ($article->id != $self->id )) ) {
return (undef);
}
}
} else {
my $temp = RT::Article->new($RT::SystemUser);
$temp->LoadByCols( Name => $name );
- if ( $temp->id &&
- (!$self->id || ($temp->id != $self->id ))) {
+ if ( $temp->id && ( !$self->id || ($temp->id != $self->id )) ) {
return (undef);
}
}
@@ -624,7 +623,6 @@ Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
=cut
-
=head2 Summary
Returns the current value of Summary.
commit 56ac13ff5b55c11349d891d89353ce6cb80f6928
Author: Steven Burr <steve at bestpractical.com>
Date: Tue May 18 14:53:29 2021 -0400
Add tests for per-class article uniqueness
diff --git a/t/articles/article.t b/t/articles/article.t
index 5c7fe06766..84aecaef08 100644
--- a/t/articles/article.t
+++ b/t/articles/article.t
@@ -2,7 +2,7 @@
use strict;
use warnings;
-use RT::Test tests => 67;
+use RT::Test tests => 72;
use_ok 'RT::Articles';
use_ok 'RT::Classes';
@@ -62,6 +62,27 @@ ok ($id, $msg);
+my $class1 = RT::Class->new($RT::SystemUser);
+($id, $msg) = $class1->Create(Name => "ScopedClassTest1-$$");
+ok ($id, $msg);
+
+my $class2 = RT::Class->new($RT::SystemUser);
+($id, $msg) = $class2->Create(Name => "ScopedClassTest2-$$");
+ok ($id, $msg);
+
+my $a4 = RT::Article->new($RT::SystemUser);
+($id, $msg) = $a4->Create(Class => $class1->id, Name => "ScopedClassTest$$" );
+ok ($id, $msg);
+
+my $a5 = RT::Article->new($RT::SystemUser);
+($id, $msg) = $a5->Create(Class => $class1->id, Name => "ScopedClassTest$$" );
+ok (!$id, $msg);
+
+my $a6 = RT::Article->new($RT::SystemUser);
+($id, $msg) = $a4->Create(Class => $class2->id, Name => "ScopedClassTest$$" );
+ok ($id, $msg);
+
+
my $newart = RT::Article->new($RT::SystemUser);
-----------------------------------------------------------------------
More information about the rt-commit
mailing list