Project

General

Profile

Defect #32704 » 32704.patch

Go MAEDA, 2023-06-25 07:59

View differences:

app/views/documents/index.html.erb
17 17
<h2><%=l(:label_document_plural)%></h2>
18 18

  
19 19
<div id="document-list">
20
<% if @grouped.empty? %><p class="nodata"><%= l(:label_no_data) %></p><% end %>
20
<% group_keys = @grouped.keys.compact %>
21
<% if @grouped.empty? || group_keys.empty? %><p class="nodata"><%= l(:label_no_data) %></p><% end %>
21 22

  
22
<% @grouped.keys.sort.__send__(@sort_by == 'date' ? :reverse_each : :each) do |group| %>
23
<% group_keys.compact.sort.__send__(@sort_by == 'date' ? :reverse_each : :each) do |group| %>
23 24
  <div class="document-group document-group-<%= @sort_by %>">
24 25
    <h3 class="group-name"><%= group %></h3>
25 26
    <%= render :partial => 'documents/document', :collection => @grouped[group] %>
test/functional/documents_controller_test.rb
62 62
    end
63 63
  end
64 64

  
65
  def test_index_grouped_by_category_should_ignore_invalid_document_category
66
    # Delete a document category skipping callbacks
67
    DocumentCategory.find_by(name: 'Technical documentation').delete
68
    get(
69
      :index,
70
      :params => {
71
        :project_id => 'ecookbook',
72
        :sort_by => 'category'
73
      }
74
    )
75
    assert_response :success
76
    assert_select 'h3.group-name', :text => 'Uncategorized', :count => 1
77
    assert_select 'h3.group-name', :text => 'Technical documentation', :count => 0
78
  end
79

  
65 80
  def test_index_grouped_by_date
66 81
    get(
67 82
      :index,
(2-2/2)