Skip to content

Commit 1470de3

Browse files
committed
chore(rails): refactor and fix test app setup
1 parent 997ef4e commit 1470de3

39 files changed

+668
-1062
lines changed

sentry-rails/.rspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
--format documentation
1+
--format progress
22
--color
33
--require spec_helper

sentry-rails/spec/dummy/test_rails_app/app.rb

Lines changed: 0 additions & 123 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# frozen_string_literal: true
2+
3+
class HelloController < ActionController::Base
4+
protect_from_forgery with: :exception
5+
6+
def exception
7+
raise "An unhandled exception!"
8+
end
9+
10+
def reporting
11+
render plain: Sentry.last_event_id
12+
end
13+
14+
def view_exception
15+
render inline: "<%= foo %>"
16+
end
17+
18+
def view
19+
render template: "test_template"
20+
end
21+
22+
def world
23+
render plain: "Hello World!"
24+
end
25+
26+
def with_custom_instrumentation
27+
custom_event = "custom.instrument"
28+
ActiveSupport::Notifications.subscribe(custom_event) do |*args|
29+
data = args[-1]
30+
data += 1
31+
end
32+
33+
ActiveSupport::Notifications.instrument(custom_event, 1)
34+
35+
head :ok
36+
end
37+
38+
def not_found
39+
raise ActionController::BadRequest
40+
end
41+
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
class PostsController < ActionController::Base
4+
def index
5+
Post.all.to_a
6+
raise "foo"
7+
end
8+
9+
def show
10+
p = Post.find(params[:id])
11+
12+
render plain: p.id
13+
end
14+
15+
def attach
16+
p = Post.find(params[:id])
17+
18+
attach_params = {
19+
io: File.open(File.join(Rails.root, "public", "sentry-logo.png")),
20+
filename: "sentry-logo.png"
21+
}
22+
23+
# service_name parameter was added in Rails 6.1
24+
if Rails.gem_version >= Gem::Version.new("6.1.0")
25+
attach_params[:service_name] = "test"
26+
end
27+
28+
p.cover.attach(attach_params)
29+
30+
render plain: p.id
31+
end
32+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
class Comment < ActiveRecord::Base
4+
belongs_to :post
5+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
class Post < ActiveRecord::Base
4+
has_many :comments
5+
has_one_attached :cover
6+
end

sentry-rails/spec/dummy/test_rails_app/apps/5-2.rb

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

0 commit comments

Comments
 (0)