Sha256: 71c3cac87ac55d3eb0aef05e3c2c0057d3b509f936789091bcd11e080e42d716

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

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

describe Article do
  it { should have_many :translations }

  it "should have empty translations for a new record" do
    Article.new.translations.should be_empty
  end
  
  it 'should destroy dependent locales' do
    article = Article.create!(:slug => '__hello__', :name => 'Hello', :content => 'World')
    expect do
      article.destroy
    end.to change(ArticleTranslation, :count).by(-1)
  end
  
  it 'should use I18n fallbacks' do
    article = Article.create!(:slug => '__hello__', :name => 'Hello', :content => 'World')
    article.update_attributes! :locale => :en, :name => 'Hello in English'
    I18n.locale = :en
    article.name.should == 'Hello in English'
    I18n.locale = :ru
    article.name.should == 'Hello'
    I18n.locale = :de
    article.name.should == 'Hello'
  end
end

describe ArticleTranslation do
  it { should belong_to :article }
  
  it 'always has an article' do
    article = Article.new(:name => 'hello')
    article.translations.first.article.should == article
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
simple_model_translations-0.2.1 spec/simple_model_translations_spec.rb
simple_model_translations-0.2.0 spec/simple_model_translations_spec.rb
simple_model_translations-0.1.9 spec/simple_model_translations_spec.rb
simple_model_translations-0.1.8 spec/simple_model_translations_spec.rb
simple_model_translations-0.1.7 spec/simple_model_translations_spec.rb