Sha256: c3915e5bc599ba1c238e5954608ebcc426b591e3a9ff67a8d03829f83c037a8e

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require_relative 'spec_helper'

describe 'Integration' do
  before do
    Translation.delete_all
    UserTranslation.delete_all
  end

  it "manages different translations appropriatly" do
    User.create(:name_in_en=>'User1NameEn', :name_in_de=>'User1NameDe')
    User.create(:name_in_en=>'User2NameEn', :name_in_fr=>'User2NameFr')
    Product.create(:title=>'Product1TitleEn', :title_in_de=>'Product1TitleDe')

    User.first.translated_attributes = {}
    u = User.last
    u.translated_attributes = {:fr=>{:name=>'User1NameFr'}}
    u.save!

    UserTranslation.count.should == 3
    Translation.count.should == 2
    User.last.name.should == 'User1NameFr'
  end

  it "cleans up translations" do
    User.create!(:name=>'u1')
    Product.create!(:title=>'p1',:description=>'d1')
    Product.create!(:title=>'p2')

    Translation.count.should == 3
    UserTranslation.count.should == 1

    Product.destroy_all

    Translation.count.should == 0
    UserTranslation.count.should == 1

    User.destroy_all

    Translation.count.should == 0
    UserTranslation.count.should == 0
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
teonimesic-translated_attributes-0.5.8 spec/integration_spec.rb
teonimesic-translated_attributes-0.5.7 spec/integration_spec.rb