Skip to content
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/fields/belongs_to/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ that displays all possible records to associate with.
%>

<div class="field-unit__label">
<%= f.label field.permitted_attribute %>
<%= f.label field.attribute, for: "#{f.object_name}_#{field.permitted_attribute}" %>
</div>
<div class="field-unit__field">
<%= f.select(field.permitted_attribute,
Expand Down
40 changes: 40 additions & 0 deletions spec/features/orders_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@
expected = order.customer.id.to_s
expect(find_field("Customer").value).to eq expected
end

it "displays translated label when translation for the attribute is available" do
order = create(:order)
custom_attribute_name = "Client"
translations = {
activerecord: {
attributes: {
order: {
customer: custom_attribute_name
}
}
}
}

with_translations(:en, translations) do
visit edit_admin_order_path(order)

expect(page).to have_css("label", text: custom_attribute_name)
end
end
end

describe "has_many relationships" do
Expand Down Expand Up @@ -92,6 +112,26 @@
end
end

it "displays translated label when translation for the attribute is available" do
order = create(:order)
custom_attribute_name = "Lines"
translations = {
activerecord: {
attributes: {
order: {
line_items: custom_attribute_name
}
}
}
}

with_translations(:en, translations) do
visit edit_admin_order_path(order)

expect(page).to have_css("label", text: custom_attribute_name)
end
end

def find_option(associated_model, field_locator)
field = find_field(field_locator)
field.find("option", text: displayed(associated_model))
Expand Down