[Git][noosfero/noosfero][master] 2 commits: article: return environment name if author_name is nil

Rodrigo Souto gitlab at mg.gitlab.com
Fri Mar 9 14:06:03 BRT 2018


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
4c516c3d by Rodrigo Souto at 2018-03-09T13:33:55Z
article: return environment name if author_name is nil

- - - - -
acf22012 by Rodrigo Souto at 2018-03-09T17:05:51Z
Merge branch 'no-author' into 'master'

article: return environment name if author_name is nil

See merge request noosfero/noosfero!1413
- - - - -


2 changed files:

- app/models/article.rb
- test/unit/article_test.rb


Changes:

=====================================
app/models/article.rb
=====================================
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -771,9 +771,9 @@ class Article < ApplicationRecord
   def author_name(version_number = nil)
     person = author_by_version(version_number)
     if version_number
-      person ? person.name : _('Unknown')
+      person ? person.name : environment.name
     else
-      person ? person.name : (setting[:author_name] || _('Unknown'))
+      person ? person.name : (setting[:author_name] || environment.name)
     end
   end
 


=====================================
test/unit/article_test.rb
=====================================
--- a/test/unit/article_test.rb
+++ b/test/unit/article_test.rb
@@ -2341,4 +2341,10 @@ class ArticleTest < ActiveSupport::TestCase
     assert article.metadata['custom_fields']['text-1'].present?
   end
 
+  should 'return environment name as author if no author name available' do
+    article = fast_create(Article)
+    article.author = nil
+    assert_equal article.environment.name, article.author_name
+  end
+
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/b11d37bf8e997202d496e0961d3b567511e74623...acf22012d001bab3638670d36df3c464e3aaa718

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/b11d37bf8e997202d496e0961d3b567511e74623...acf22012d001bab3638670d36df3c464e3aaa718
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180309/eba65868/attachment.html>


More information about the Noosfero-dev mailing list