Sha256: 0781cde27f859eb0ada1939eadfa0e868f9be14b33c869bbb9641f559435e4a2

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Article do
  it 'should be able to return only records which have translations' do
    first_article = Article.create!(:slug => 'hello')
    second_article = Article.create!(:slug => 'world', :name => 'WORLD')
    Article.with_translations.to_a.should == [second_article]
  end
  
  it 'should be able to return translation class' do
    Article.translation_class.should == ArticleTranslation
  end
  
  it 'should be able to return translated column name' do
    Article.translated_column_name(:name).should == :'article_translations.name'
  end
  
  it 'should be able to search by specific column names and locales' do
    first_article = Article.create!(:slug => 'hello', :locale => :en, :name => 'hello')
    second_article = Article.create!(:slug => 'world', :name => 'WORLD')
    third_article = Article.create!(:slug => 'hello')
    fourth_article = Article.create!(:slug => 'world', :name => 'WORLD', :locale => :en)
    Article.with_translated_attribute(:name, ['hello'], :en).should == [first_article]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
simple_model_translations-0.2.0 spec/class_methods_spec.rb
simple_model_translations-0.1.9 spec/class_methods_spec.rb
simple_model_translations-0.1.8 spec/class_methods_spec.rb
simple_model_translations-0.1.7 spec/class_methods_spec.rb
simple_model_translations-0.1.6 spec/class_methods_spec.rb
simple_model_translations-0.1.4 spec/class_methods_spec.rb
simple_model_translations-0.1.3 spec/class_methods_spec.rb
simple_model_translations-0.1.2 spec/class_methods_spec.rb
simple_model_translations-0.1.1 spec/class_methods_spec.rb