Skip to content

Commit a39df47

Browse files
committed
WIP
1 parent 3d64bb4 commit a39df47

File tree

9 files changed

+14
-34
lines changed

9 files changed

+14
-34
lines changed

sentry-rails/spec/dummy/test_rails_app/config/application.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ def self.schema_file
4747
@schema_file ||= root_path.join("db/schema.rb")
4848
end
4949

50+
def self.db_path
51+
@db_path ||= root_path.join("db", "db.sqlite3")
52+
end
53+
5054
def self.application_file
5155
@application_file ||= begin
5256
current = Dir[root_path.join("config/applications/rails-*.rb")]
@@ -61,10 +65,7 @@ def self.load_test_schema
6165
# Silence migrations output
6266
ActiveRecord::Migration.verbose = false
6367

64-
ActiveRecord::Base.establish_connection(
65-
adapter: "sqlite3",
66-
database: root_path.join("db", "db.sqlite3")
67-
)
68+
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: db_path)
6869

6970
# Load schema from db/schema.rb into the current connection
7071
require Test::Application.schema_file
@@ -83,6 +84,7 @@ def configure
8384
config.active_job.queue_adapter = :test
8485
config.cache_store = :memory_store
8586
config.action_controller.perform_caching = true
87+
config.active_storage.service = :test
8688

8789
config.filter_parameters = [
8890
:password,
@@ -122,7 +124,7 @@ def configure
122124
end
123125

124126
def before_initialize!
125-
# no-op by default
127+
ENV["DATABASE_URL"] = "sqlite3://#{self.class.db_path}"
126128
end
127129

128130
def after_initialize!
@@ -140,6 +142,12 @@ def cleanup!
140142
end
141143

142144
require_relative "applications/#{application_file}"
145+
146+
::Rails.module_eval do
147+
def self.root
148+
Sentry::TestRailsApp.root_path
149+
end
150+
end
143151
end
144152
end
145153
end

sentry-rails/spec/dummy/test_rails_app/config/applications/rails-5.2.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@
22

33
module Sentry
44
class TestRailsApp < Sentry::Rails::Test::Application
5-
def configure
6-
super
7-
config.active_storage.service = :test
8-
end
95
end
106
end

sentry-rails/spec/dummy/test_rails_app/config/applications/rails-6.0.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ module Sentry
44
class TestRailsApp < Sentry::Rails::Test::Application
55
def configure
66
super
7-
config.active_storage.service = :test
87
config.active_record.sqlite3 = ActiveSupport::OrderedOptions.new
98
config.active_record.sqlite3.represent_boolean_as_integer = nil
109
end

sentry-rails/spec/dummy/test_rails_app/config/applications/rails-6.1.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
module Sentry
44
class TestRailsApp < Sentry::Rails::Test::Application
5-
def configure
6-
super
7-
config.active_storage.service = :test
8-
end
9-
105
def before_initialize!
116
ActionCable::Channel::Base.reset_callbacks(:subscribe)
127
ActionCable::Channel::Base.reset_callbacks(:unsubscribe)

sentry-rails/spec/dummy/test_rails_app/config/applications/rails-7.0.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
module Sentry
44
class TestRailsApp < Sentry::Rails::Test::Application
5-
def configure
6-
super
7-
config.active_storage.service = :test
8-
end
9-
105
def before_initialize!
116
# Zeitwerk checks if registered loaders load paths repeatedly and raises error if that happens.
127
# And because every new Rails::Application instance registers its own loader, we need to clear previously registered ones from Zeitwerk.

sentry-rails/spec/dummy/test_rails_app/config/applications/rails-latest.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module Sentry
66
class TestRailsApp < Sentry::Rails::Test::Application
77
def configure
88
super
9-
config.active_storage.service = :test
109
config.enable_reloading = false
1110
end
1211

sentry-rails/spec/dummy/test_rails_app/config/database.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

sentry-rails/spec/dummy/test_rails_app/config/environment.rb

Lines changed: 0 additions & 5 deletions
This file was deleted.

sentry-rails/spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
config.include(Sentry::Rails::TestHelper)
5555

5656
config.before :suite do
57-
Sentry::Rails::Test::Application.load_test_schema
57+
Sentry::TestRailsApp.load_test_schema
5858
end
5959

6060
config.before :each do

0 commit comments

Comments
 (0)