Skip to content

Commit

Permalink
Merge pull request #42 from amygurski/fix_rails_6_1
Browse files Browse the repository at this point in the history
Support Rails 6.1
  • Loading branch information
jrs40492 authored May 20, 2021
2 parents bbbae05 + 360c7f2 commit dc07f0e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
3.0.0 / 2021-05-12
==================

* Changes to support Rails 6.1.
* Fetch config for database name differently because rails removed the connection_id key from the sql.active_record notification.

1.0.0 / 2016-05-04
==================
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@ before do
end
```

Or if you're using FactoryGirl you could do something like this:
Or if you're using FactoryBot you could do something like this:
```ruby
RSpec.configure do |config|
module FactoryBoy
module FactoryKid
def create(*args)
SqlFootprint.exclude { FactoryGirl.create(*args) }
SqlFootprint.exclude { FactoryBot.create(*args) }
end
end
config.include FactoryBoy
config.include FactoryKid
end
```

## Compatibility
- For Rails < 6.0 compatibility, please use v2.0.1.
- For Rails >= 6.0 compatibility, please use v3.0.0.

DO NOT run SqlFootprint in production!
4 changes: 1 addition & 3 deletions lib/sql_footprint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
module SqlFootprint
ActiveSupport::Notifications.subscribe('sql.active_record') do |_, _, _, _, payload|
if @capture
adapter = ObjectSpace._id2ref(payload.fetch(:connection_id))
config = adapter.instance_variable_get(:@config) ||
adapter.instance_variable_get(:@connection_options)
config = payload.fetch(:connection).instance_variable_get(:@config)
database_name = config.fetch(:database)
capturers[database_name].capture payload.fetch(:sql)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/sql_footprint/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module SqlFootprint
VERSION = '2.0.1'.freeze
VERSION = '3.0.0'.freeze
end
4 changes: 2 additions & 2 deletions sql_footprint.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'activerecord', ['>= 3.0']
spec.add_dependency 'activesupport', ['>= 3.0']
spec.add_dependency 'activerecord', ['>= 6.0', '< 7.0']
spec.add_dependency 'activesupport', ['>= 6.0', '< 7.0']

spec.add_development_dependency 'bundler', ['>= 1.7', '< 3.0']
spec.add_development_dependency 'rake', '~> 10.0'
Expand Down

0 comments on commit dc07f0e

Please sign in to comment.