Sha256: 66288ff9e068232108538eee391cd47d077a05a314aec181d0bd830142325b98

Contents?: true

Size: 993 Bytes

Versions: 9

Compression:

Stored size: 993 Bytes

Contents

require 'spec_helper'
require 'ar_schema'
ARSchema.connect!

describe "lolita_translation:sync_tables" do
  def translations
    ActiveRecord::Base.connection.tables.reject{|tn| !tn.match(/translations/)}.sort
  end

  before(:each) do
    c_class = Class.new(ActiveRecord::Base)
    stub_const('Comment',c_class)
    c_class.class_eval do
      include Lolita::Translation
      translate :body
    end
    ActiveRecord::Base.connection.execute("DROP TABLE comments_translations") rescue nil
  end

  it "should create translation tables for all lolita mappings" do
    translations.should eq(%w(categories_translations posts_translations products_translations).sort)
    Lolita.mappings[:comment] = Lolita::Mapping.new(:comments)
    load(File.expand_path("lib/tasks/lolita_translation.rake"))
    Rake.application["lolita_translation:sync_tables"].invoke()
    translations.should eq(%w(categories_translations posts_translations comments_translations products_translations).sort)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lolita-translation-0.8.3 spec/tasks/lolita_translation_spec.rb
lolita-translation-0.8.2 spec/tasks/lolita_translation_spec.rb
lolita-translation-0.8.1 spec/tasks/lolita_translation_spec.rb
lolita-translation-0.8.0 spec/tasks/lolita_translation_spec.rb
lolita-translation-0.7.4 spec/tasks/lolita_translation_spec.rb
lolita-translation-0.7.3 spec/tasks/lolita_translation_spec.rb
lolita-translation-0.7.2 spec/tasks/lolita_translation_spec.rb
lolita-translation-0.7.1 spec/tasks/lolita_translation_spec.rb
lolita-translation-0.7.0 spec/tasks/lolita_translation_spec.rb