Commit 9688304f73948898a44d7b4dbbb721b901993959

Authored by Antonio Terceiro
1 parent 8eb0bfa5

List exiting comments after disabling new comments

(ActionItem2305)
app/views/content_viewer/view_page.rhtml
... ... @@ -70,23 +70,29 @@
70 70 <%= display_source_info(@page) %>
71 71  
72 72 <div class="comments" id="comments_list">
73   - <% if @page.accept_comments? %>
74   - <h3 <%= 'class="no-comments-yet"' if @comments.size == 0 %>>
75   - <%= number_of_comments(@page) %>
76   - </h3>
77   - <% if @comments_count > 1 %>
78   - <p class="post-comment-button"><a href="#comment_form" onclick="jQuery('#page-comment-form h4').first().trigger('click')"><%= _('Post a comment') %></a></p>
  73 +
  74 + <% if @page.accept_comments? || @comments_count > 0 %>
  75 + <h3 <%= 'class="no-comments-yet"' if @comments_count == 0 %>>
  76 + <%= number_of_comments(@page) %>
  77 + </h3>
  78 + <% end %>
  79 +
  80 + <% if @page.accept_comments? && @comments_count > 1 %>
  81 + <p class="post-comment-button"><a href="#comment_form" onclick="jQuery('#page-comment-form h4').first().trigger('click')"><%= _('Post a comment') %></a></p>
79 82 <% end %>
  83 +
80 84 <ul class="article-comments-list">
81 85 <%= render :partial => 'comment', :collection => @comments %>
82 86 </ul>
83   - <div id="page-comment-form"><%= render :partial => 'comment_form' %></div>
84   - <script type="text/javascript">
85   - jQuery( function() {
86   - jQuery('.article-comment').live('mouseover', function() { jQuery(this).find('.icon-delete:first').show(); });
87   - jQuery('.article-comment').live('mouseout', function() { jQuery(this).find('.icon-delete').hide(); });
88   - });
89   - </script>
  87 +
  88 + <% if @page.accept_comments? %>
  89 + <div id="page-comment-form"><%= render :partial => 'comment_form' %></div>
  90 + <script type="text/javascript">
  91 + jQuery( function() {
  92 + jQuery('.article-comment').live('mouseover', function() { jQuery(this).find('.icon-delete:first').show(); });
  93 + jQuery('.article-comment').live('mouseout', function() { jQuery(this).find('.icon-delete').hide(); });
  94 + });
  95 + </script>
90 96 <% end %>
91 97 </div><!-- end class="comments" -->
92 98  
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -436,6 +436,14 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
436 436 end
437 437 end
438 438  
  439 + should 'list comments if article has them, even if new comments are not allowed' do
  440 + page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text', :accept_comments => false)
  441 + page.comments.create!(:author => profile, :title => 'list my comment', :body => 'foo bar baz')
  442 + get :view_page, :profile => profile.identifier, :page => ['myarticle']
  443 +
  444 + assert_tag :content => /list my comment/
  445 + end
  446 +
439 447 should 'show link to publication on view' do
440 448 page = profile.articles.create!(:name => 'myarticle', :body => 'the body of the text')
441 449 login_as(profile.identifier)
... ...