Skip to content

Commit

Permalink
Revert "Replace RequestStore with ActiveSupport::CurrentAttributes"
Browse files Browse the repository at this point in the history
This reverts commit f8416b1.
  • Loading branch information
danielmorrison committed Nov 6, 2023
1 parent e2513bb commit d9b4d5a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
6 changes: 3 additions & 3 deletions audited.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = ">= 2.3.0"

gem.add_dependency "activerecord", ">= 5.0", "< 7.7"
gem.add_dependency "activesupport", ">= 5.0", "< 7.7"
gem.add_dependency "activerecord", ">= 5.0", "< 7.2"
gem.add_dependency "request_store", "~> 1.2"

gem.add_development_dependency "appraisal"
gem.add_development_dependency "rails", ">= 5.0", "< 7.7"
gem.add_development_dependency "rails", ">= 5.0", "< 7.2"
gem.add_development_dependency "rspec-rails"
gem.add_development_dependency "standard"
gem.add_development_dependency "single_cov"
Expand Down
4 changes: 2 additions & 2 deletions lib/audited.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "active_record"
require "request_store"

module Audited
class << self
Expand All @@ -25,7 +26,7 @@ def audit_class
deprecator: ActiveSupport::Deprecation.new('6.0.0', 'Audited')

def store
Audited::RequestStore.audited_store ||= {}
RequestStore.store[:audited_store] ||= {}
end

def config
Expand All @@ -41,7 +42,6 @@ def config
end

require "audited/auditor"
require "audited/request_store"

ActiveSupport.on_load :active_record do
require "audited/audit"
Expand Down
9 changes: 0 additions & 9 deletions lib/audited/request_store.rb

This file was deleted.

6 changes: 1 addition & 5 deletions spec/audited_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
describe Audited do
describe "#store" do
describe "maintains state of store" do
let(:current_user) { Audited::RequestStore.audited_store }
let(:current_user) { RequestStore.store[:audited_store] }
before { Audited.store[:current_user] = current_user }

it "checks store is not nil" do
expect(Audited.store[:current_user]).to eq(current_user)
end

it "when executed with Fibers" do
Fiber.new { expect(Audited.store[:current_user]).to eq(current_user) }.resume
end
end
end
end

0 comments on commit d9b4d5a

Please sign in to comment.