Skip to content

Commit dfb972a

Browse files
committed
More e2e coverage
1 parent 1bba282 commit dfb972a

File tree

9 files changed

+236
-203
lines changed

9 files changed

+236
-203
lines changed

spec/apps/rails-mini/Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
44

55
gem "rake"
66
gem "puma"
7+
gem "rack-cors"
78
gem 'railties', '~> 8.0'
89
gem 'actionpack', '~> 8.0'
910
gem 'sentry-ruby', path: Pathname(__dir__).join("../../..").realpath

spec/apps/rails-mini/app.rb

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
ENV["RAILS_ENV"] = "development"
88

99
require "action_controller"
10+
require "rack/cors"
1011

1112
class RailsMiniApp < Rails::Application
1213
config.hosts = nil
@@ -17,6 +18,18 @@ class RailsMiniApp < Rails::Application
1718
config.api_only = true
1819
config.force_ssl = false
1920

21+
# Add CORS middleware using Rack::Cors
22+
config.middleware.insert_before 0, Rack::Cors do
23+
allow do
24+
origins '*'
25+
resource '*',
26+
headers: :any,
27+
methods: :any,
28+
expose: :any,
29+
credentials: false
30+
end
31+
end
32+
2033
initializer :configure_sentry do
2134
Sentry.init do |config|
2235
config.dsn = ENV["SENTRY_DSN"]
@@ -30,38 +43,29 @@ class RailsMiniApp < Rails::Application
3043
config.release = "sentry-ruby-rails-mini-#{Time.now.utc}"
3144

3245
config.transport.transport_class = Sentry::DebugTransport
33-
config.sdk_debug_transport_log_file = "/workspace/sentry/log/sentry_debug_events.log"
3446
config.background_worker_threads = 0
3547
end
3648
end
3749
end
3850

3951
class ErrorController < ActionController::Base
40-
before_action :set_cors_headers
41-
4252
def error
53+
# Let the exception bubble up so Sentry Rails integration captures it with proper context
4354
result = 1 / 0
4455
render json: { result: result }
4556
end
4657

47-
private
48-
49-
def set_cors_headers
50-
response.headers['Access-Control-Allow-Origin'] = '*'
51-
response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'
52-
response.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization, sentry-trace, baggage'
58+
def options
59+
head :ok
5360
end
5461
end
5562

5663
class EventsController < ActionController::Base
57-
before_action :set_cors_headers
58-
5964
def health
6065
render json: {
6166
status: "ok",
6267
timestamp: Time.now.utc.iso8601,
63-
sentry_initialized: Sentry.initialized?,
64-
log_file_writable: check_log_file_writable
68+
sentry_initialized: Sentry.initialized?
6569
}
6670
end
6771

@@ -70,20 +74,8 @@ def trace_headers
7074
render json: { headers: headers }
7175
end
7276

73-
private
74-
75-
def check_log_file_writable
76-
log_file_path = "/workspace/sentry/log/sentry_debug_events.log"
77-
File.writable?(File.dirname(log_file_path)) &&
78-
(!File.exist?(log_file_path) || File.writable?(log_file_path))
79-
rescue
80-
false
81-
end
82-
83-
def set_cors_headers
84-
response.headers['Access-Control-Allow-Origin'] = '*'
85-
response.headers['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'
86-
response.headers['Access-Control-Allow-Headers'] = 'Content-Type, Authorization, sentry-trace, baggage'
77+
def options
78+
head :ok
8779
end
8880
end
8981

@@ -94,7 +86,12 @@ def set_cors_headers
9486
get '/error', to: 'error#error'
9587
get '/trace_headers', to: 'events#trace_headers'
9688

97-
# Add CORS headers for cross-origin requests from JS app
89+
# Handle OPTIONS preflight requests explicitly
90+
options '/health', to: 'events#options'
91+
options '/error', to: 'error#options'
92+
options '/trace_headers', to: 'events#options'
93+
94+
# Catch-all OPTIONS handler for any other paths
9895
match '*path', to: proc { |env|
9996
[200, {
10097
'Access-Control-Allow-Origin' => '*',

spec/apps/svelte-mini/package-lock.json

Lines changed: 52 additions & 123 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/apps/svelte-mini/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
"preview": "vite preview"
99
},
1010
"devDependencies": {
11-
"@sveltejs/vite-plugin-svelte": "^3.0.0",
12-
"svelte": "^4.0.0",
13-
"vite": "^5.0.0"
11+
"@sveltejs/vite-plugin-svelte": "^3.1.0",
12+
"svelte": "^4.2.0",
13+
"vite": "^5.4.0"
1414
},
1515
"dependencies": {
16-
"@sentry/svelte": "^7.0.0"
16+
"@sentry/svelte": "^8.0.0"
1717
}
1818
}

0 commit comments

Comments
 (0)