Sha256: 5c6990dbaf0491b74ada654a33a608289d4aedfec4ff9e9efa155a3e799b52cd
Contents?: true
Size: 1.75 KB
Versions: 10
Compression:
Stored size: 1.75 KB
Contents
require 'spec_helper' require 'ar_schema' ARSchema.connect! describe Lolita::Translation::Migrators::ActiveRecordMigrator do let(:klass){ Lolita::Translation::Migrators::ActiveRecordMigrator } 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 new table for class" do migrator = klass.new(Comment) ActiveRecord::Base.connection.tables.should_not include("comments_translations") migrator.migrate ActiveRecord::Base.connection.tables.should include("comments_translations") CommentTranslation.column_names.sort.should eq(%w(body locale comment_id id).sort) end it "should add new column to table when one is added to configuration" do migrator = klass.new(Comment) ActiveRecord::Base.connection.tables.should_not include("comments_translations") migrator.migrate CommentTranslation.column_names.sort.should eq(%w(body locale comment_id id).sort) Comment.translations_configuration.attributes << :commenter migrator.migrate CommentTranslation.column_names.sort.should eq(%w(body locale comment_id id commenter).sort) end it "should remove column from table if it is removed from configuration" do migrator = klass.new(Comment) Comment.translations_configuration.attributes << :commenter migrator.migrate CommentTranslation.column_names.sort.should eq(%w(body locale comment_id id commenter).sort) Comment.translations_configuration.attributes.pop migrator.migrate CommentTranslation.column_names.sort.should eq(%w(body locale comment_id id).sort) end end
Version data entries
10 entries across 10 versions & 1 rubygems