Sha256: f9c7c23184236286d8f9ac17e25872b2a669c44a3ff279a7a8151c7e9d753ebc

Contents?: true

Size: 946 Bytes

Versions: 3

Compression:

Stored size: 946 Bytes

Contents

require "spec_helper"
require "rake"

describe "octopus.rake" do
  before do
    load File.expand_path("../../../lib/tasks/octopus.rake", __FILE__)
    Rake::Task.define_task(:environment)
  end

  describe "octopus:copy_schema_versions" do
    class SchemaMigration < ActiveRecord::Base; end

    before do
      Rake::Task["octopus:copy_schema_versions"].reenable

      path = File.expand_path("../../migrations", __FILE__)
      ActiveRecord::Migrator.migrations_paths = [path]
    end

    it "assumes each shard migrated to the current master version" do
      SchemaMigration.create(:version => 1)
      SchemaMigration.create(:version => 2)
      SchemaMigration.create(:version => 3)

      Rake::Task["octopus:copy_schema_versions"].invoke

      ActiveRecord::Base.connection.shard_names.each do |shard_name|
        Octopus.using(shard_name) { ActiveRecord::Migrator.get_all_versions }.should == [1, 2, 3]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ar-octopus-0.8.2 spec/tasks/octopus.rake_spec.rb
ar-octopus-0.8.1 spec/tasks/octopus.rake_spec.rb
ar-octopus-0.8.0 spec/tasks/octopus.rake_spec.rb