8000 Re-use I18n translations of formtastic ~ Labels (#5764) · stephancom/activeadmin@8a7aff0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a7aff0

Browse files
WaKeMaTTajavierjulio
authored andcommitted
Re-use I18n translations of formtastic ~ Labels (activeadmin#5764)
* Re-use I18n translations of formtastic ~ Labels * Undo unnecessary change and add a spec * Simplify
1 parent 1478675 commit 8a7aff0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/active_admin/filters/active_filter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def related_class_name
6666
def filter_label
6767
return unless filter
6868

69-
filter[:label]
69+
filter[:label] || I18n.t(name, scope: ['formtastic', 'labels'], default: nil)
7070
end
7171

7272
#@return Ransack::Nodes::Attribute

spec/unit/filters/active_filter_spec.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,20 @@
2929
expect(subject.values).to eq([post.title])
3030
end
3131

32-
it 'should have valid label' do
33-
expect(subject.label).to eq("Title equals")
32+
describe 'label' do
33+
context 'by default' do
34+
it 'should have valid label' do
35+
expect(subject.label).to eq("Title equals")
36+
end
37+
end
38+
39+
context 'with formtastic translations' do
40+
it 'should pick up formtastic label' do
41+
with_translation formtastic: { labels: { title: 'Supertitle' } } do
42+
expect(subject.label).to eq("Supertitle equals")
43+
end
44+
end
45+
end
3446
end
3547

3648
it 'should pick predicate name translation' do

0 commit comments

Comments
 (0)
0