Commit 30b2a8e5600d95cefcd9de537d7197ce472398ff

Authored by Antonio Terceiro
2 parents 5b476303 41e81521

Merge commit 'refs/merge-requests/232' of git://gitorious.org/noosfero/noosfero …

…into merge-requests/232
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
... ... @@ -1096,6 +1096,10 @@ a.comment-picture {
1096 1096 left: 33px;
1097 1097 background-repeat: no-repeat;
1098 1098 }
  1099 +.comment-user-status-wall {
  1100 + top: 16px;
  1101 + left: 16px;
  1102 +}
1099 1103 #article .article-comments-list, #article .article-comments-list ul, #article .article-comments-list li {
1100 1104 padding: 0;
1101 1105 margin: 0;
... ...
test/functional/profile_controller_test.rb
... ... @@ -1300,4 +1300,28 @@ class ProfileControllerTest &lt; 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
... ...