Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix I18n translation for attributes in has_many collections #594

Merged
merged 1 commit into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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 %>

Expand Down
29 changes: 29 additions & 0 deletions spec/features/show_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down