From d9b4d5ab69060768eaad1b270be699d247d8eb67 Mon Sep 17 00:00:00 2001 From: Daniel Morrison Date: Mon, 6 Nov 2023 16:57:04 -0500 Subject: [PATCH] Revert "Replace RequestStore with ActiveSupport::CurrentAttributes" This reverts commit f8416b14598ffe011fcfb3ab59c6aa19145efbc2. --- audited.gemspec | 6 +++--- lib/audited.rb | 4 ++-- lib/audited/request_store.rb | 9 --------- spec/audited_spec.rb | 6 +----- 4 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 lib/audited/request_store.rb diff --git a/audited.gemspec b/audited.gemspec index 67339ff5..b6b31fca 100644 --- a/audited.gemspec +++ b/audited.gemspec @@ -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" diff --git a/lib/audited.rb b/lib/audited.rb index 6940e2ba..76e514b1 100644 --- a/lib/audited.rb +++ b/lib/audited.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "active_record" +require "request_store" module Audited class << self @@ -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 @@ -41,7 +42,6 @@ def config end require "audited/auditor" -require "audited/request_store" ActiveSupport.on_load :active_record do require "audited/audit" diff --git a/lib/audited/request_store.rb b/lib/audited/request_store.rb deleted file mode 100644 index 5e246ad4..00000000 --- a/lib/audited/request_store.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -require "active_support" - -module Audited - class RequestStore < ActiveSupport::CurrentAttributes - attribute :audited_store - end -end diff --git a/spec/audited_spec.rb b/spec/audited_spec.rb index 09252273..aa142199 100644 --- a/spec/audited_spec.rb +++ b/spec/audited_spec.rb @@ -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