[Rt-commit] rt branch, 5.0/require-article-name, created. rt-5.0.0-11-g7c2352d91b

Aaron Trevena ast at bestpractical.com
Thu Sep 10 14:06:57 EDT 2020


The branch, 5.0/require-article-name has been created
        at  7c2352d91b2c55f2029b9a885f652ae8ebce6ca9 (commit)

- Log -----------------------------------------------------------------
commit 5b3f55eedf5bf5077e24374be9f0beebb10b67b1
Author: Aaron Trevena <ast at bestpractical.com>
Date:   Thu Sep 3 15:57:37 2020 +0100

    Require Name field when creating or editing Article
    
    Articles with empty name fields cause a problem with re-submission
    and duplicate content when creating a ticket with that article.
    
    Make Name a required field when creating or editing articles.

diff --git a/lib/RT/Article.pm b/lib/RT/Article.pm
index af1e628784..443e44dbf0 100644
--- a/lib/RT/Article.pm
+++ b/lib/RT/Article.pm
@@ -114,6 +114,9 @@ sub Create {
         return ( 0, $self->loc("Permission Denied") );
     }
 
+    return ( undef, $self->loc('Name is required') )
+        unless ($args{Name} =~ /\S/);
+
     return ( undef, $self->loc('Name in use') )
       unless $self->ValidateName( $args{'Name'} );
 

commit 7c2352d91b2c55f2029b9a885f652ae8ebce6ca9
Author: Aaron Trevena <ast at bestpractical.com>
Date:   Thu Sep 10 12:17:40 2020 +0100

    Update tests to provide required name field for articles

diff --git a/t/articles/article.t b/t/articles/article.t
index 5c7fe06766..4af62be303 100644
--- a/t/articles/article.t
+++ b/t/articles/article.t
@@ -27,7 +27,7 @@ ok (UNIVERSAL::isa($article, 'RT::Record'));
 ok (UNIVERSAL::isa($article, 'DBIx::SearchBuilder::Record') , "It's a searchbuilder record!");
 
 
-($id, $msg) = $article->Create( Class => $CLASS, Summary => $CLASS);
+($id, $msg) = $article->Create( Class => $CLASS, Summary => $CLASS, Name => 'test 1');
 ok ($id, $msg);
 $article->Load($id);
 is ($article->Summary, $CLASS, "The summary is set correct");
@@ -86,11 +86,11 @@ ok ($a2->Disabled, "the article is disabled");
 #$RT::Handle->SimpleQuery("DELETE FROM Links");
 
 my $article_a = RT::Article->new($RT::SystemUser);
-($id, $msg) = $article_a->Create( Class => $CLASS, Summary => "ArticleTestlink1".$$);
+($id, $msg) = $article_a->Create( Class => $CLASS, Summary => "ArticleTestlink1".$$, Name => 'test 2');
 ok($id,$msg);
 
 my $article_b = RT::Article->new($RT::SystemUser);
-($id, $msg) = $article_b->Create( Class => $CLASS, Summary => "ArticleTestlink2".$$);
+($id, $msg) = $article_b->Create( Class => $CLASS, Summary => "ArticleTestlink2".$$, Name => 'test 3');
 ok($id,$msg);
 
 # Create a link between two articles
@@ -195,7 +195,7 @@ ok ($id, $msg);
 
 
 my $art = RT::Article->new($RT::SystemUser);
-($id, $msg) = $art->Create (Class => $CLASS);
+($id, $msg) = $art->Create (Class => $CLASS, Name => 'test 4');
 ok ($id,$msg);
 
 ok($art->URI);
@@ -205,7 +205,7 @@ ok($art->__Value('URI') eq $art->URI, "The uri in the db is set correctly");
 
 
  $art = RT::Article->new($RT::SystemUser);
-($id, $msg) = $art->Create (Class => $CLASS);
+($id, $msg) = $art->Create (Class => $CLASS, Name => 'test 5');
 ok ($id,$msg);
 
 ok($art->URIObj);
diff --git a/t/articles/interface.t b/t/articles/interface.t
index 3f914d74a0..5822fc75e5 100644
--- a/t/articles/interface.t
+++ b/t/articles/interface.t
@@ -198,7 +198,7 @@ $m->form_number(3);
 $m->set_visible([option => $answerCF->Name]);
 $m->click();
 $m->title_like(qr/Create a new article/, "got edit page from extraction");
-$m->submit_form(form_name => 'EditArticle');
+$m->submit_form(form_name => 'EditArticle', fields => { Name => 'more testing' });
 $m->title_like(qr/Modify article/);
 $m->follow_link_ok( { text => 'Display' }, '-> Display' );
 $m->content_like(qr/Africa/, "Article content exist");
diff --git a/t/web/command_line_link_to_articles.t b/t/web/command_line_link_to_articles.t
index 9a49145fdd..f6ad735be5 100644
--- a/t/web/command_line_link_to_articles.t
+++ b/t/web/command_line_link_to_articles.t
@@ -9,7 +9,7 @@ ok( $class_id, $msg );
 
 my $article = RT::Article->new( RT->SystemUser );
 ( my $article_id, $msg ) =
-  $article->Create( Class => 'foo', Summary => 'article summary' );
+  $article->Create( Class => 'foo', Summary => 'article summary', Name => 'Test' );
 ok( $article_id, $msg );
 
 my ( $baseurl, $m ) = RT::Test->started_ok;
diff --git a/t/web/search_linkdisplay.t b/t/web/search_linkdisplay.t
index 8d18f547ad..794369e38d 100644
--- a/t/web/search_linkdisplay.t
+++ b/t/web/search_linkdisplay.t
@@ -31,7 +31,7 @@ my $class = RT::Class->new( RT->SystemUser );
 ok ($id, $msg);
 
 my $article = RT::Article->new( RT->SystemUser );
-($id, $msg) = $article->Create( Class => $class->Name, Summary => 'Test Article' );
+($id, $msg) = $article->Create( Class => $class->Name, Summary => 'Test Article', Name => 'Test' );
 ok ($id, $msg);
 $article->Load($id);
 

-----------------------------------------------------------------------


More information about the rt-commit mailing list