Sha256: 29039c7751099a1dc47dbbf21e442e395054a13fea1207f91f1ce675f92ad364

Contents?: true

Size: 1.05 KB

Versions: 5

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 "processes and migrates" do
      expect(Apartment::Tenant).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::Tenant).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::Tenant).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

5 entries across 5 versions & 1 rubygems

Version Path
apartment-0.26.1 spec/unit/migrator_spec.rb
apartment-0.26.0 spec/unit/migrator_spec.rb
apartment-0.25.2 spec/unit/migrator_spec.rb
apartment-0.25.1 spec/unit/migrator_spec.rb
apartment-0.25.0 spec/unit/migrator_spec.rb