Testing Namespaced Attribute Translations in Ransack
This test suite validates Ransack’s translation functionality, specifically focusing on attribute name translations in a namespaced context. It ensures proper integration with ActiveRecord’s internationalization features and verifies consistent behavior between Ransack and ActiveRecord translations.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
activerecord-hackery/ransack
spec/ransack/translate_spec.rb
require 'spec_helper'
module Ransack
describe Translate do
describe '.attribute' do
it 'translate namespaced attribute like AR does' do
ar_translation = ::Namespace::Article.human_attribute_name(:title)
ransack_translation = Ransack::Translate.attribute(
:title,
context: ::Namespace::Article.ransack.context
)
expect(ransack_translation).to eq ar_translation
end
end
end
end