Skip to content

Commit 31fc3d2

Browse files
committed
chore(rails): refactor and fix test app setup
1 parent 4e1d9bc commit 31fc3d2

40 files changed

+653
-990
lines changed

sentry-rails/.rspec

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

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

Lines changed: 0 additions & 123 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# frozen_string_literal: true
2+
3+
class HelloController < ActionController::Base
4+
def exception
5+
raise "An unhandled exception!"
6+
end
7+
8+
def reporting
9+
render plain: Sentry.last_event_id
10+
end
11+
12+
def view_exception
13+
render inline: "<%= foo %>"
14+
end
15+
16+
def view
17+
render template: "test_template"
18+
end
19+
20+
def world
21+
render plain: "Hello World!"
22+
end
23+
24+
def with_custom_instrumentation
25+
custom_event = "custom.instrument"
26+
ActiveSupport::Notifications.subscribe(custom_event) do |*args|
27+
data = args[-1]
28+
data += 1
29+
end
30+
31+
ActiveSupport::Notifications.instrument(custom_event, 1)
32+
33+
head :ok
34+
end
35+
36+
def not_found
37+
raise ActionController::BadRequest
38+
end
39+
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)