Sha256: ccebc45dab3986439e450e25f6d79bc9ee21edaba91d7f1c5485a493a7ad50b1

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 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::Tenant.adapter.stub(: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

3 entries across 3 versions & 1 rubygems

Version Path
apartment-1.0.2 spec/unit/migrator_spec.rb
apartment-1.0.1 spec/unit/migrator_spec.rb
apartment-1.0.0 spec/unit/migrator_spec.rb