mongoid translate spec works

This commit is contained in:
Zhomart Mukhamejanov 2014-08-02 10:38:40 -07:00
parent dace90ec93
commit 55d6b88de1
2 changed files with 20 additions and 5 deletions

View File

@ -2,11 +2,12 @@ module Ransack
module Translate
def self.i18n_key(klass)
if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0
klass.model_name.i18n_key.to_s.tr('.', '/')
else
klass.model_name.i18n_key.to_s
end
# if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0
# klass.model_name.i18n_key.to_s.tr('.', '/')
# else
# klass.model_name.i18n_key.to_s
# end
klass.model_name.i18n_key.to_s
end
end
end

View File

@ -0,0 +1,14 @@
require 'mongoid_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.search.context)
expect(ransack_translation).to eq ar_translation
end
end
end
end