Sha256: 2e869129e6d06c8ade74aeb89e503c0fd2a563ae3f079e0dd2e8f0d3da6668e6

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'
require 'apartment/migrator'

describe Apartment::Migrator do

  let(:tenant){ Apartment::Test.next_db }

  # Don't need a real switch here, just testing behaviour
  before { Apartment::Database.adapter.stub(:connect_to_new) }

  describe "::migrate" do
    it "processes and migrates" do
      expect(Apartment::Database).to receive(:process).with(tenant).and_call_original
      expect(ActiveRecord::Migrator).to receive(:migrate)

      Apartment::Migrator.migrate(tenant)
    end
  end

  describe "::run" do
    it "processes and runs" do
      expect(Apartment::Database).to receive(:process).with(tenant).and_call_original
      expect(ActiveRecord::Migrator).to receive(:run).with(:up, anything, 1234)

      Apartment::Migrator.run(:up, tenant, 1234)
    end
  end

  describe "::rollback" do
    it "processes and rolls back" do
      expect(Apartment::Database).to receive(:process).with(tenant).and_call_original
      expect(ActiveRecord::Migrator).to receive(:rollback).with(anything, 2)

      Apartment::Migrator.rollback(tenant, 2)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
apartment-0.24.3 spec/unit/migrator_spec.rb
apartment-0.24.2 spec/unit/migrator_spec.rb
apartment-0.24.1 spec/unit/migrator_spec.rb
apartment-0.24.0 spec/unit/migrator_spec.rb
apartment-0.23.2 spec/unit/migrator_spec.rb
apartment-0.23.1 spec/unit/migrator_spec.rb