Sha256: f02e0b3dd23467a752e5d412801ff283562740158622e7000ea449b3e97036e6

Contents?: true

Size: 1.06 KB

Versions: 4

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 { allow(Apartment::Tenant.adapter).to receive(:connect_to_new) }

  describe "::migrate" do
    it "switches and migrates" do
      expect(Apartment::Tenant).to receive(:switch).with(tenant).and_call_original
      expect(ActiveRecord::Migrator).to receive(:migrate)

      Apartment::Migrator.migrate(tenant)
    end
  end

  describe "::run" do
    it "switches and runs" do
      expect(Apartment::Tenant).to receive(:switch).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 "switches and rolls back" do
      expect(Apartment::Tenant).to receive(:switch).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

4 entries across 4 versions & 1 rubygems

Version Path
apartment-2.1.0 spec/unit/migrator_spec.rb
apartment-2.0.0 spec/unit/migrator_spec.rb
apartment-1.2.0 spec/unit/migrator_spec.rb
apartment-1.1.0 spec/unit/migrator_spec.rb