Sha256: 6ef7203518d25929f3f9273c3e994d5a43d2e580421514d451f7e56b9d76ab7f

Contents?: true

Size: 1.3 KB

Versions: 20

Compression:

Stored size: 1.3 KB

Contents

# encoding: utf-8
require File.dirname(__FILE__) + '/spec_helper'

describe 'HasTranslations' do
  it "should switch locales" do
    g = Group.create!(:name => "Sport")
    c = Category.create!(:name => "Golf", :groups => [g])
    z = News.create!(:title => "Tiger Woods sucks", :body => Faker::Lorem::paragraphs(10).join, :category_id => c.id)
    # translate
    g.translations.create!(:locale => 'lv', :name => "Sports")
    c.translations.create!(:locale => 'lv', :name => "Golfs")
    z.translations.create!(:locale => 'lv', :title => "Taigers Vuds nekam neder")
    
    g.name.should == "Sport"
    c.name.should == "Golf"
    z.title.should == "Tiger Woods sucks"

    I18n.locale = :lv
    
    g.name.should == "Sports"
    c.name.should == "Golfs"
    z.title.should == "Taigers Vuds nekam neder"

    z.category.name.should == "Golfs"
    z.category.groups.first.name.should == "Sports"

    z.destroy
    c.destroy
    g.destroy
    #--------------------------------
    I18n.locale = I18n.default_locale
  end

  it "should load requested locale with 'in' method" do
    g = Group.create!(:name => "Sport")
    g.translations.create!(:locale => 'lv', :name => "Sports")

    g = Group.find_by_name "Sport"    
    g.name.should == "Sport"
    g.name.in(:lv).should == "Sports"
    g.name.should == "Sport"
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
lolita-translation-0.3.3 spec/has_translations_spec.rb
lolita-translation-0.2.18 spec/has_translations_spec.rb
lolita-translation-0.3.2 spec/has_translations_spec.rb
lolita-translation-0.3.1 spec/has_translations_spec.rb
lolita-translation-0.3.0 spec/has_translations_spec.rb
lolita-translation-0.2.9 spec/has_translations_spec.rb
lolita-translation-0.2.8 spec/has_translations_spec.rb
lolita-translation-0.2.7 spec/has_translations_spec.rb
lolita-translation-0.2.6 spec/has_translations_spec.rb
lolita-translation-0.2.5 spec/has_translations_spec.rb
lolita-translation-0.2.1 spec/has_translations_spec.rb
lolita-translation-0.2.0 spec/has_translations_spec.rb
lolita-translation-0.1.4 spec/has_translations_spec.rb
lolita-translation-0.1.3 spec/has_translations_spec.rb
lolita-translation-0.1.2 spec/has_translations_spec.rb
lolita-translation-0.1.1 spec/has_translations_spec.rb
lolita-translation-0.1.0 spec/has_translations_spec.rb
lolita-translation-0.0.3 spec/has_translations_spec.rb
lolita-translation-0.0.2 spec/has_translations_spec.rb
lolita-translation-0.0.1 spec/has_translations_spec.rb