Sha256: 3b307ff594f26e8e40511e9f6585c04d3737a81eecfda70d2f3b44cbaa7e3a3a

Contents?: true

Size: 1.08 KB

Versions: 89

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'fileutils'
require 'tmpdir'

TESTAPP_PATH = ENV['TESTAPP_PATH'] || File.join(Dir.tmpdir, 'declare_schema_testapp') unless defined?(TESTAPP_PATH)
FileUtils.chdir(TESTAPP_PATH)

system "rm -rf app/models/ad* app/models/alpha*"
system "rm -rf test/models/ad* test/models/alpha*"
system "rm -rf test/fixtures/ad* test/fixtures/alpha*"
system "rm -rf db/migrate/*"
system "mkdir -p #{TESTAPP_PATH}/app/assets/config"
system "echo '' >> #{TESTAPP_PATH}/app/assets/config/manifest.js"

require "#{TESTAPP_PATH}/config/environment"

require 'rails/generators'
Rails::Generators.configure!(Rails.application.config.generators)

ActiveRecord::Base.connection.schema_cache.clear!

(ActiveRecord::Base.connection.tables - Generators::DeclareSchema::Migration::Migrator.always_ignore_tables).each do |table|
  ActiveRecord::Base.connection.execute("DROP TABLE #{ActiveRecord::Base.connection.quote_table_name(table)}")
end

ActiveRecord::Base.send(:descendants).each do |model|
  unless model.name['Active'] || model.name['Application']
    nuke_model_class(model)
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
declare_schema-1.4.0 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.11 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.3.6 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.3.6.colin.1 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.3.5 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.3.5.colin.1 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.9 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.3.4 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.3.4.colin.1 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.8 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.3.3 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.3.3.colin.1 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.7 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.6 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.5 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.4 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.3 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.2 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.4.0.colin.1 spec/lib/declare_schema/prepare_testapp.rb
declare_schema-1.3.2 spec/lib/declare_schema/prepare_testapp.rb