Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribe to rails deprecations #242

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/dep_shield/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ source "https://rubygems.org"
gemspec

gem "nokogiri", "< 1.16"

gem "rails", "<= 7.0.6"
gem "rake", "~> 13.0"

gem "rspec", "~> 3.0"

gem "rubocop-powerhome", path: "../rubocop-powerhome"
5 changes: 3 additions & 2 deletions packages/dep_shield/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
specs:
dep_shield (0.2.1)
nitro_config
rails (>= 6.0.6.1, <= 7.0.6)
railties (>= 6.0.6.1, <= 7.0.6)
sentry-rails (= 5.5.0)
sentry-ruby (= 5.5.0)

Expand Down Expand Up @@ -119,7 +119,7 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.21.1)
net-imap (0.4.9.1)
net-imap (0.4.10)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -266,6 +266,7 @@ DEPENDENCIES
dep_shield!
license_finder (>= 7.0)
nokogiri (< 1.16)
rails (<= 7.0.6)
rake (~> 13.0)
rspec (~> 3.0)
rspec-rails (~> 5.1.2)
Expand Down
10 changes: 5 additions & 5 deletions packages/dep_shield/dep_shield.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "nitro_config"
spec.add_dependency "railties", ">= 6.0.6.1", "<= 7.0.6"
spec.add_dependency "sentry-rails", "5.5.0"
spec.add_dependency "sentry-ruby", "5.5.0"

spec.add_development_dependency "appraisal", "~> 2.5.0"
spec.add_development_dependency "combustion", "~> 1.4"
spec.add_development_dependency "license_finder", ">= 7.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rspec-rails", "~> 5.1.2"
spec.add_development_dependency "sqlite3", "~> 1.4.2"

spec.add_dependency "nitro_config"
spec.add_dependency "rails", ">= 6.0.6.1", "<= 7.0.6"
spec.add_dependency "sentry-rails", "5.5.0"
spec.add_dependency "sentry-ruby", "5.5.0"
end
2 changes: 1 addition & 1 deletion packages/dep_shield/gemfiles/rails_6_0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
specs:
dep_shield (0.2.1)
nitro_config
rails (>= 6.0.6.1, <= 7.0.6)
railties (>= 6.0.6.1, <= 7.0.6)
sentry-rails (= 5.5.0)
sentry-ruby (= 5.5.0)

Expand Down
2 changes: 1 addition & 1 deletion packages/dep_shield/gemfiles/rails_6_1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
specs:
dep_shield (0.2.1)
nitro_config
rails (>= 6.0.6.1, <= 7.0.6)
railties (>= 6.0.6.1, <= 7.0.6)
sentry-rails (= 5.5.0)
sentry-ruby (= 5.5.0)

Expand Down
2 changes: 1 addition & 1 deletion packages/dep_shield/gemfiles/rails_7_0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PATH
specs:
dep_shield (0.2.1)
nitro_config
rails (>= 6.0.6.1, <= 7.0.6)
railties (>= 6.0.6.1, <= 7.0.6)
sentry-rails (= 5.5.0)
sentry-ruby (= 5.5.0)

Expand Down
17 changes: 17 additions & 0 deletions packages/dep_shield/lib/dep_shield/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

require "dep_shield"

module DepShield
# Ties DepShield to rails deprecations system
class Railtie < Rails::Railtie
initializer "dep_shield.subscribe" do
ActiveSupport::Notifications.subscribe("deprecation.rails") do |name, _start, _finish, _id, payload|
message = payload[:message] || "this is deprecated in rails"
callstack = payload[:callstack] || caller

DepShield.raise_or_capture!(name: name, message: message, callstack: callstack)
end
end
end
end
18 changes: 18 additions & 0 deletions packages/dep_shield/spec/dep_shield/railtie_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require "spec_helper"

RSpec.describe DepShield::Deprecation do
it "subscribes to deprecation.rails" do
expect(DepShield).to(
receive(:raise_or_capture!)
.with(name: "deprecation.rails", message: "This has been so deprecated", callstack: ["file1.rb", "file2.rb"])
)

ActiveSupport::Notifications.instrument(
"deprecation.rails",
message: "This has been so deprecated",
callstack: ["file1.rb", "file2.rb"]
)
end
end
2 changes: 1 addition & 1 deletion packages/dep_shield/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "bundler"
require "dep_shield"
require "dep_shield/railtie"
require "rspec/rails"

Bundler.require :default, :development
Expand Down
Loading