-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
console
executable file
路54 lines (43 loc) 路 1.48 KB
/
console
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/setup"
require "solidus"
module IRBSolidusHelpers
def dummy_app
@dummy_app ||= begin
print "Loading the dummy app..."
ENV['DATABASE_URL'] ||= 'sqlite3::memory:?pool=1'
require "spree/testing_support/dummy_app"
class << (Rails.application)
# Allow to run migrations from the console
def migrate!
ActiveRecord::Migrator.migrations_paths =
Rails.application.migration_railties.flat_map do |engine|
(engine.paths['db/migrate'] if engine.respond_to?(:paths)).to_a
end
ActiveRecord::Migration.verbose = false
# Prepare the db with a basic spree structure for LegacyUser
ActiveRecord::Base.connection.migration_context.run(:up, '20160101010000_solidus_one_four'.to_i)
ActiveRecord::Tasks::DatabaseTasks.migrate
self
end
# Avoid flooding the console with the original #inspect
def inspect
"#<#{self.class.name} root=#{root}>"
end
end
puts "done."
Rails.application
end
end
USAGE = <<~TXT
USAGE:
dummy_app # Load the dummy app and return the Rails.application instance
dummy_app.initialize! # Initialize the dummy app
dummy_app.migrate! # Run all the dummy app migrations
TXT
end
puts IRBSolidusHelpers::USAGE
require "irb"
IRB::ExtendCommandBundle.prepend IRBSolidusHelpers
IRB.start(__FILE__)