Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Explicitly transform the title to a string (see #64134)

Henriette Dargee97eab50c43e
diff --git a/modules/documents/app/views/documents/index.html.erb b/modules/documents/app/views/documents/index.html.erb
index 06ddb7df9f2..41930c5ac72 100644
--- a/modules/documents/app/views/documents/index.html.erb
+++ b/modules/documents/app/views/documents/index.html.erb
@@ -59,7 +59,7 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% @grouped.keys.sort.each do |group| %>
- <%= augmented_collapsible_section(title: group.name) do %>
+ <%= augmented_collapsible_section(title: group.to_s) do %>
<div class="document-category--inner-section">
<div class="form--field document-category-elements">
<%= render partial: "documents/document", collection: @grouped[group] %>
diff --git a/modules/documents/spec/features/document_categories_spec.rb b/modules/documents/spec/features/document_categories_spec.rb
index 676553e55cb..ada622a06dc 100644
--- a/modules/documents/spec/features/document_categories_spec.rb
+++ b/modules/documents/spec/features/document_categories_spec.rb
@@ -28,7 +28,7 @@
require "spec_helper"
-RSpec.describe "Document categories" do
+RSpec.describe "Document categories", :js do
shared_let(:admin) { create(:admin) }
before do
@@ -59,4 +59,35 @@ RSpec.describe "Document categories" do
expect(DocumentCategory).to exist(name: "Specification")
expect(DocumentCategory).not_to exist(name: "Documentation")
end
+
+ context "with uploaded documents" do
+ let(:project) { create(:project) }
+ let(:category1) { create(:document_category, name: "Category 1", project:) }
+ let(:category2) { create(:document_category, name: "Category 2", project:) }
+
+ it "can group by category and date (regression #64134)" do
+ # Add documents to the category
+ create_list(:document, 2, category: category1, project:)
+ create_list(:document, 2, category: category2, project:)
+
+ # Visit the documents module
+ visit project_documents_path(project.identifier)
+
+ # Expect grouping to be applied by category
+ expect(page).to have_css(".CollapsibleSection h2", text: "Category 1")
+ expect(page).to have_css(".CollapsibleSection h2", text: "Category 2")
+
+ # Change grouping to "date"
+ within "#sidebar" do
+ choose(I18n.t(:label_date))
+ end
+
+ wait_for_reload
+
+ # Expect grouping to be changed
+ expect(page).to have_css(".CollapsibleSection h2", text: Time.zone.today)
+ expect(page).to have_no_css(".CollapsibleSection h2", text: "Category 1")
+ expect(page).to have_no_css(".CollapsibleSection h2", text: "Category 2")
+ end
+ end
end