Commit a07045349fdd3d3bad7be30a83153cce2e024e07
1 parent
7ea7efc5
Exists in
master
and in
22 other branches
ActionItem938: display author when available
When we know who is the author, use it instead of just using the profile owning the article. This is rather limited, though, since the history is not queried to get all the authors; only the last author is displayed.
Showing
6 changed files
with
35 additions
and
3 deletions
Show diff stats
app/helpers/content_viewer_helper.rb
... | ... | @@ -20,7 +20,7 @@ module ContentViewerHelper |
20 | 20 | unless args[:no_link] |
21 | 21 | title = content_tag('h3', link_to(article.name, article.url), :class => 'title') |
22 | 22 | end |
23 | - title << content_tag('span', _("%s, by %s") % [show_date(article.created_at), article.profile.name], :class => 'created-at') | |
23 | + title << content_tag('span', _("%s, by %s") % [show_date(article.created_at), link_to(article.author.name, article.author.url)], :class => 'created-at') | |
24 | 24 | end |
25 | 25 | title |
26 | 26 | end | ... | ... |
app/models/article.rb
app/models/published_article.rb
test/unit/article_test.rb
... | ... | @@ -659,4 +659,12 @@ class ArticleTest < Test::Unit::TestCase |
659 | 659 | assert_equal a.url, a.view_url |
660 | 660 | end |
661 | 661 | |
662 | + should 'know its author' do | |
663 | + assert_equal profile, Article.new(:last_changed_by => profile).author | |
664 | + end | |
665 | + | |
666 | + should 'use owning profile as author when we dont know who did the last change' do | |
667 | + assert_equal profile, Article.new(:last_changed_by => nil, :profile => profile).author | |
668 | + end | |
669 | + | |
662 | 670 | end | ... | ... |
test/unit/content_viewer_helper_test.rb
... | ... | @@ -15,13 +15,13 @@ class ContentViewerHelperTest < Test::Unit::TestCase |
15 | 15 | blog = Blog.create!(:name => 'Blog test', :profile => profile) |
16 | 16 | post = TextileArticle.create!(:name => 'post test', :profile => profile, :parent => blog) |
17 | 17 | result = article_title(post) |
18 | - assert_match /#{show_date(post.created_at)}, by #{profile.identifier}/, result | |
18 | + assert_match /#{show_date(post.created_at)}, by .*#{profile.identifier}/, result | |
19 | 19 | end |
20 | 20 | |
21 | 21 | should 'not display created-at for non-blog posts' do |
22 | 22 | article = TextileArticle.create!(:name => 'article for test', :profile => profile) |
23 | 23 | result = article_title(article) |
24 | - assert_no_match /#{show_date(article.created_at)}, by #{profile.identifier}/, result | |
24 | + assert_no_match /#{show_date(article.created_at)}, by .*#{profile.identifier}/, result | |
25 | 25 | end |
26 | 26 | |
27 | 27 | should 'create link on title of blog posts' do | ... | ... |
test/unit/published_article_test.rb
... | ... | @@ -73,5 +73,15 @@ class PublishedArticleTest < ActiveSupport::TestCase |
73 | 73 | assert_nil p.parent |
74 | 74 | end |
75 | 75 | |
76 | + should "use author of original article as its author" do | |
77 | + original = Article.new(:last_changed_by => @profile) | |
78 | + community = Community.new | |
79 | + published = PublishedArticle.new(:reference_article => original, :profile => community) | |
80 | + assert_equal @profile, published.author | |
81 | + end | |
82 | + | |
83 | + should 'use owning profile as author when there is no referenced article yet' do | |
84 | + assert_equal @profile, PublishedArticle.new(:profile => @profile).author | |
85 | + end | |
76 | 86 | |
77 | 87 | end | ... | ... |