Commit 41e81521e7230ee3c5d423b97de74fd07d177a7e
1 parent
20c9a186
Exists in
master
and in
29 other branches
Shows removed users and unauthenticated users in wall comments
Comments with no author would break the wall. This fixes this issue. Comments are shown similar to the ones in article pages, displaying an specific icon to unknown users (non logged users) and other icon to removed users. Shows author name only if it exists (i.e if the author has a profile or if the name was provided for a non logged user) (ActionItem2445)
Showing
3 changed files
with
47 additions
and
3 deletions
Show diff stats
app/views/profile/_comment.rhtml
... | ... | @@ -5,19 +5,35 @@ |
5 | 5 | <li class="article-comment" style='border-bottom:none;'> |
6 | 6 | <div class="article-comment-inner"> |
7 | 7 | |
8 | - <div class="comment-content comment-logged-in"> | |
8 | + <div class="comment-content comment-logged-<%= comment.author ? 'in' : 'out' %>"> | |
9 | 9 | |
10 | 10 | <% if comment.author %> |
11 | 11 | <%= link_to image_tag(profile_icon(comment.author, :minor)), |
12 | - Person.find(comment.author_id).url, | |
12 | + comment.author_url, | |
13 | 13 | :class => 'comment-picture', |
14 | 14 | :title => comment.author_name |
15 | 15 | %> |
16 | + <% else %> | |
17 | + <% url_image, status_class = comment.author_id ? | |
18 | + [comment.removed_user_image, 'icon-user-removed'] : | |
19 | + [str_gravatar_url_for( comment.email ), 'icon-user-unknown'] %> | |
20 | + | |
21 | + <%= link_to( | |
22 | + image_tag(url_image, :onerror=>'gravatarCommentFailback(this)', | |
23 | + 'data-gravatar'=>str_gravatar_url_for(comment.email)) + | |
24 | + content_tag('span', comment.author_name, :class => 'comment-info') + | |
25 | + content_tag('span', comment.message, | |
26 | + :class => 'comment-user-status comment-user-status-wall ' + status_class), | |
27 | + gravatar_profile_url(comment.email), | |
28 | + :target => '_blank', | |
29 | + :class => 'comment-picture', | |
30 | + :title => '%s %s' % [comment.author_name, comment.message] | |
31 | + )%> | |
16 | 32 | <% end %> |
17 | 33 | |
18 | 34 | <div class="comment-details"> |
19 | 35 | <div class="comment-text"> |
20 | - <%= link_to(comment.author_name, comment.author.url) %> | |
36 | + <%= comment.author.present? ? link_to(comment.author_name, comment.author.url) : content_tag('strong', comment.author_name) %> | |
21 | 37 | <% unless comment.title.blank? %> |
22 | 38 | <span class="comment-title"><%= comment.title %></span><br/> |
23 | 39 | <% end %> | ... | ... |
public/stylesheets/application.css
... | ... | @@ -1094,6 +1094,10 @@ a.comment-picture { |
1094 | 1094 | left: 33px; |
1095 | 1095 | background-repeat: no-repeat; |
1096 | 1096 | } |
1097 | +.comment-user-status-wall { | |
1098 | + top: 16px; | |
1099 | + left: 16px; | |
1100 | +} | |
1097 | 1101 | #article .article-comments-list, #article .article-comments-list ul, #article .article-comments-list li { |
1098 | 1102 | padding: 0; |
1099 | 1103 | margin: 0; | ... | ... |
test/functional/profile_controller_test.rb
... | ... | @@ -1300,4 +1300,28 @@ class ProfileControllerTest < ActionController::TestCase |
1300 | 1300 | assert_response :success |
1301 | 1301 | assert_equal "Comment successfully added.", assigns(:message) |
1302 | 1302 | end |
1303 | + | |
1304 | + should 'display comment in wall if user was removed' do | |
1305 | + UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | |
1306 | + article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') | |
1307 | + to_be_removed = create_user('removed_user').person | |
1308 | + comment = Comment.create!(:author => to_be_removed, :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') | |
1309 | + to_be_removed.destroy | |
1310 | + | |
1311 | + login_as(profile.identifier) | |
1312 | + get :index, :profile => profile.identifier | |
1313 | + | |
1314 | + assert_tag :tag => 'span', :content => '(removed user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-removed'} | |
1315 | + end | |
1316 | + | |
1317 | + should 'display comment in wall from non logged users' do | |
1318 | + UserStampSweeper.any_instance.stubs(:current_user).returns(profile) | |
1319 | + article = TinyMceArticle.create!(:profile => profile, :name => 'An article about free software') | |
1320 | + comment = Comment.create!(:name => 'outside user', :email => 'outside@localhost.localdomain', :title => 'Test Comment', :body => 'My author does not exist =(', :source_id => article.id, :source_type => 'Article') | |
1321 | + | |
1322 | + login_as(profile.identifier) | |
1323 | + get :index, :profile => profile.identifier | |
1324 | + | |
1325 | + assert_tag :tag => 'span', :content => '(unauthenticated user)', :attributes => {:class => 'comment-user-status comment-user-status-wall icon-user-unknown'} | |
1326 | + end | |
1303 | 1327 | end | ... | ... |