From b39db6b4345dac743fc48f13134e4d8b7508eaa2 Mon Sep 17 00:00:00 2001 From: Shouichi Kamiya Date: Wed, 16 Feb 2022 13:08:07 +0900 Subject: [PATCH] Fix table header classes of has_many field When displaying has_many resources in the show page, parent resource name was used for child table header classes. --- app/views/administrate/application/_collection.html.erb | 2 +- spec/features/show_page_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/views/administrate/application/_collection.html.erb b/app/views/administrate/application/_collection.html.erb index 207191950b..6ab1285cc3 100644 --- a/app/views/administrate/application/_collection.html.erb +++ b/app/views/administrate/application/_collection.html.erb @@ -25,7 +25,7 @@ to display a collection of resources in an HTML table. " + cell-label--<%= "#{collection_presenter.resource_name}_#{attr_name}" %>" scope="col" role="columnheader" aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>"> diff --git a/spec/features/show_page_spec.rb b/spec/features/show_page_spec.rb index b1f2c9066e..55d980a7f3 100644 --- a/spec/features/show_page_spec.rb +++ b/spec/features/show_page_spec.rb @@ -99,6 +99,15 @@ end end + it "adds has_many resource/attribute name to table headers" do + customer = create(:customer) + create_list(:order, 2, customer: customer) + + visit admin_customer_path(customer) + + expect(page).to have_css("th.cell-label--order_total_price") + end + it "sorts each of the customer's orders" do customer = create(:customer) orders = create_list(:order, 4, customer: customer)