2019-04-29 19:27:42 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-17 00:47:47 -06:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe FreedomPatches::SchemaMigrationDetails do
|
|
|
|
|
|
|
|
# we usually don't really need this model so lets not clutter up with it
|
|
|
|
class SchemaMigrationDetail < ActiveRecord::Base
|
|
|
|
end
|
|
|
|
|
2017-08-30 23:06:56 -05:00
|
|
|
class TestMigration < ActiveRecord::Migration[4.2]
|
2016-02-17 00:47:47 -06:00
|
|
|
def up
|
|
|
|
sleep 0.001
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "logs information on migration" do
|
2019-11-25 23:39:14 -06:00
|
|
|
migration = TestMigration.new("awesome_migration", "20110225050318")
|
2016-02-17 00:47:47 -06:00
|
|
|
|
|
|
|
ActiveRecord::Base.connection_pool.with_connection do |conn|
|
|
|
|
migration.exec_migration(conn, :up)
|
|
|
|
end
|
|
|
|
|
2019-11-25 23:39:14 -06:00
|
|
|
info = SchemaMigrationDetail.find_by(version: "20110225050318")
|
2016-02-17 00:47:47 -06:00
|
|
|
|
|
|
|
expect(info.duration).to be > 0
|
|
|
|
expect(info.git_version).to eq Discourse.git_version
|
|
|
|
expect(info.direction).to eq "up"
|
|
|
|
expect(info.rails_version).to eq Rails.version
|
|
|
|
expect(info.name).to eq "awesome_migration"
|
|
|
|
end
|
|
|
|
end
|