From 13b6b7704a902d0104ac1f985f300ca4afe7afee Mon Sep 17 00:00:00 2001 From: Hugh Middleton Date: Wed, 25 May 2016 17:54:28 +1000 Subject: [PATCH] fix label translation lookup for has_many collections --- .../application/_collection.html.erb | 2 +- spec/features/show_page_spec.rb | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/views/administrate/application/_collection.html.erb b/app/views/administrate/application/_collection.html.erb index 74fbc51528..862a27376f 100644 --- a/app/views/administrate/application/_collection.html.erb +++ b/app/views/administrate/application/_collection.html.erb @@ -32,7 +32,7 @@ to display a collection of resources in an HTML table. collection_presenter.order_params_for(attr_name) )) do %> <%= t( - "helpers.label.#{resource_name}.#{attr_name}", + "helpers.label.#{collection_presenter.resource_name}.#{attr_name}", default: attr_name.to_s, ).titleize %> diff --git a/spec/features/show_page_spec.rb b/spec/features/show_page_spec.rb index 192252aa06..7820ae8c8b 100644 --- a/spec/features/show_page_spec.rb +++ b/spec/features/show_page_spec.rb @@ -123,6 +123,35 @@ end end + it "displays translated labels in has_many collection partials" do + custom_label = "Time Shipped" + customer = create(:customer) + create(:order, customer: customer) + + translations = { + administrate: { + actions: { + edit: "Edit", + destroy: "Destroy", + confirm: "Are you sure?", + }, + }, + helpers: { + label: { + order: { + shipped_at: custom_label, + }, + }, + }, + } + + with_translations(:en, translations) do + visit admin_customer_path(customer) + + expect(page).to have_css(".cell-label", text: custom_label) + end + end + def have_order_row(id) have_css('tr td:first-child', text: id) end