[Rt-commit] rt branch, 5.0-trunk, updated. rt-5.0.1-33-gf93fc25bdc

? sunnavy sunnavy at bestpractical.com
Wed Mar 10 14:29:05 EST 2021


The branch, 5.0-trunk has been updated
       via  f93fc25bdca2eea86a5c9e23b9f0e28c3848d20a (commit)
       via  87b08830655c0357f6253566c886a191fa3af3c4 (commit)
       via  89b0038b4818dcb9516d1691f1b0e164e254fd74 (commit)
      from  fabfbf54509adf046b1ef83a1940040387b4e3c0 (commit)

Summary of changes:
 lib/RT/Article.pm                     |  6 ++++--
 t/articles/article.t                  | 10 +++++-----
 t/articles/interface.t                |  2 +-
 t/web/command_line_link_to_articles.t |  2 +-
 t/web/search_linkdisplay.t            |  2 +-
 5 files changed, 12 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit 89b0038b4818dcb9516d1691f1b0e164e254fd74
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..53d7a4f936 100644
--- a/lib/RT/Article.pm
+++ b/lib/RT/Article.pm
@@ -114,6 +114,8 @@ sub Create {
         return ( 0, $self->loc("Permission Denied") );
     }
 
+    return ( undef, $self->loc('Name is required') ) unless $args{Name};
+
     return ( undef, $self->loc('Name in use') )
       unless $self->ValidateName( $args{'Name'} );
 
@@ -231,7 +233,7 @@ sub Create {
 
 Takes a string name. Returns true if that name isn't in use by another article
 
-Empty names are permitted.
+Empty names are not permitted.
 
 
 =cut
@@ -241,7 +243,7 @@ sub ValidateName {
     my $name = shift;
 
     if ( !$name ) {
-        return (1);
+        return (0);
     }
 
     my $temp = RT::Article->new($RT::SystemUser);

commit 87b08830655c0357f6253566c886a191fa3af3c4
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);
 

commit f93fc25bdca2eea86a5c9e23b9f0e28c3848d20a
Merge: fabfbf5450 87b0883065
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Thu Mar 11 03:07:38 2021 +0800

    Merge branch '5.0/require-article-name' into 5.0-trunk


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


More information about the rt-commit mailing list