Skip to content

Commit

Permalink
Fix table header classes of has_many field
Browse files Browse the repository at this point in the history
When displaying has_many resources in the show page, parent resource
name was used for child table header classes.
  • Loading branch information
shouichi committed Feb 16, 2022
1 parent 6939dbe commit 8b60c9f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/administrate/application/_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ to display a collection of resources in an HTML table.
<th class="cell-label
cell-label--<%= attr_type.html_class %>
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
cell-label--<%= "#{resource_name}_#{attr_name}" %>"
cell-label--<%= "#{collection_presenter.resource_name}_#{attr_name}" %>"
scope="col"
role="columnheader"
aria-sort="<%= sort_order(collection_presenter.ordered_html_class(attr_name)) %>">
Expand Down
9 changes: 9 additions & 0 deletions spec/features/show_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8b60c9f

Please sign in to comment.