Sha256: d666a04a6793350bf4dd88585f018f6bbc42a910f67677ea89e3ee34ce33c2ce

Contents?: true

Size: 1.88 KB

Versions: 24

Compression:

Stored size: 1.88 KB

Contents

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

describe Radiant::ExtensionMigrator do
  
  class Person < ActiveRecord::Base; end
  class Place < ActiveRecord::Base; end

  before :each do
    ActiveRecord::Base.connection.delete("DELETE FROM schema_migrations WHERE version LIKE 'Basic-%' OR version LIKE 'Upgrading-%'")
    ActiveRecord::Base.connection.delete("DELETE FROM extension_meta WHERE name = 'Upgrading'")
  end
  
  it 'should migrate new style migrations successfully' do
    ActiveRecord::Migration.suppress_messages do
      BasicExtension.migrator.migrate
    end
    BasicExtension.migrator.get_all_versions.should == [200812131420,200812131421]
    lambda { Person.find(:all) }.should_not raise_error
    lambda { Place.find(:all) }.should_not raise_error
    ActiveRecord::Migration.suppress_messages do
      BasicExtension.migrator.migrate(0)
    end
    BasicExtension.migrator.get_all_versions.should == []
  end
  
  it 'should migrate extensions with unusual names' do
    ActiveRecord::Migration.suppress_messages do
      SpecialCharactersExtension.migrator.migrate
    end
    SpecialCharactersExtension.migrator.get_all_versions.should == [1]
    lambda { Person.find(:all) }.should_not raise_error
    ActiveRecord::Migration.suppress_messages do
      SpecialCharactersExtension.migrator.migrate(0)
    end
    SpecialCharactersExtension.migrator.get_all_versions.should == []
  end

  it "should record existing extension migrations in the schema_migrations table" do
    ActiveRecord::Base.connection.insert("INSERT INTO extension_meta (name, schema_version) VALUES ('Upgrading', 2)")
    ActiveRecord::Migration.suppress_messages do
      UpgradingExtension.migrator.migrate(3)
    end
    UpgradingExtension.migrator.get_all_versions.should == [1,2,3]
    ActiveRecord::Base.connection.select_values("SELECT * FROM extension_meta WHERE name = 'Upgrading'").should be_empty
  end
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
radiant-rails3-0.1 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.2.4 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.2.2 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.2.1 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.2 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1.9 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1.8 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1.7 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1.6 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1.5 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1.4 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1.3 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1.2 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1.1 spec/lib/radiant/extension_migrator_spec.rb
radiantcms-couchrest_model-0.1 spec/lib/radiant/extension_migrator_spec.rb
radiant-0.7.2 spec/lib/radiant/extension_migrator_spec.rb
radiant-0.9.1 spec/lib/radiant/extension_migrator_spec.rb
radiant-0.8.2 spec/lib/radiant/extension_migrator_spec.rb
radiant-0.9.0.rc2 spec/lib/radiant/extension_migrator_spec.rb
radiant-rc-0.9.0 spec/lib/radiant/extension_migrator_spec.rb