audited 5.3.2 → 5.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9441d78ecdc47f146411573dbbba291449a94d062e2e564be52ff58548a2c25
4
- data.tar.gz: e2843b1bfe94e4a19aa6666a98c01d23fd165240f96d2c602d5291383b68f4a1
3
+ metadata.gz: 1979018213d9b4793bf6c450161759ad6e2ee8c0749c21c9c361bb012b703016
4
+ data.tar.gz: 113875c36e93998ef49e54e1ee65812996a28d553f5fd17c9a6252ea046f2cbc
5
5
  SHA512:
6
- metadata.gz: fbee8a19b3da64248a2d2ea58bdac95f94431b4e57545ceae25897b50470a3adf7bc9b7497da58a7e85e466502d2baa3c0d9e9e96e070b2f48b8a0ebe506cd0d
7
- data.tar.gz: e0093f598ceec9caade9d14c9fdba938e8ba92b3355bc164ba9587b1863230681586071ac5864ede9aaf361be58bdad38e08742a9f06e1093e89422c0a04e4ea
6
+ metadata.gz: 9d490c64b590cc9df55d67551908bd450c2737f04d55201000c637122682aaf6c1df069cc61894774c1778ddb29488e0f6e22d5786f155f6415cb47c12fc45f5
7
+ data.tar.gz: 7801bb4dadea8bef4499f50115749cf589f59ffc795c950dbfdf918989311ec6a1380237ef0bbd05f1c1c9edcfe9c42ff5d66d3e44fb71666127fe57dfbcaaee
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Audited ChangeLog
2
2
 
3
+ ## 5.3.3 (2023-03-24)
4
+
5
+ - Use RequestStore instead of Thread.current for thread-safe requests - @tiagocassio
6
+ [#669](https://github.com/collectiveidea/audited/pull/669)
7
+ - Clean up Touch audits - @mcyoung, @akostadinov
8
+ [#668](https://github.com/collectiveidea/audited/pull/668)
9
+
3
10
  ## 5.3.2 (2023-02-22)
4
11
 
5
12
  - Touch audit bug fixes - @mcyoung
data/README.md CHANGED
@@ -37,7 +37,7 @@ Audited is currently ActiveRecord-only. In a previous life, Audited worked with
37
37
  Add the gem to your Gemfile:
38
38
 
39
39
  ```ruby
40
- gem "audited", "~> 5.0"
40
+ gem "audited"
41
41
  ```
42
42
 
43
43
  And if you're using ```require: false``` you must add initializers like this:
@@ -238,7 +238,7 @@ class ApplicationController < ActionController::Base
238
238
  if current_user
239
239
  current_user
240
240
  else
241
- 'Elon Musk'
241
+ 'Alexander Fleming'
242
242
  end
243
243
  end
244
244
  end
@@ -247,12 +247,10 @@ module Audited
247
247
  all_changes.except(*self.class.non_audited_columns)
248
248
  end
249
249
 
250
- if for_touch
250
+ if for_touch && (last_audit = audits.last&.audited_changes)
251
251
  filtered_changes.reject! do |k, v|
252
- next unless audits.present?
253
-
254
- audits.last.audited_changes[k].to_json == v.to_json ||
255
- audits.last.audited_changes[k].to_json == v[1].to_json
252
+ last_audit[k].to_json == v.to_json ||
253
+ last_audit[k].to_json == v[1].to_json
256
254
  end
257
255
  end
258
256
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Audited
4
- VERSION = "5.3.2"
4
+ VERSION = "5.3.3"
5
5
  end
data/lib/audited.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_record"
4
+ require "request_store"
4
5
 
5
6
  module Audited
6
7
  class << self
@@ -24,13 +25,7 @@ module Audited
24
25
  deprecate audit_model: "use Audited.audit_class instead of Audited.audit_model. This method will be removed."
25
26
 
26
27
  def store
27
- current_store_value = Thread.current.thread_variable_get(:audited_store)
28
-
29
- if current_store_value.nil?
30
- Thread.current.thread_variable_set(:audited_store, {})
31
- else
32
- current_store_value
33
- end
28
+ RequestStore.store[:audited_store] ||= {}
34
29
  end
35
30
 
36
31
  def config
data/spec/audited_spec.rb CHANGED
@@ -3,16 +3,12 @@ require "spec_helper"
3
3
  describe Audited do
4
4
  describe "#store" do
5
5
  describe "maintains state of store" do
6
- let(:current_user) { "current_user" }
6
+ let(:current_user) { RequestStore.store[:audited_store] }
7
7
  before { Audited.store[:current_user] = current_user }
8
8
 
9
- it "when executed without fibers" do
9
+ it "checks store is not nil" do
10
10
  expect(Audited.store[:current_user]).to eq(current_user)
11
11
  end
12
-
13
- it "when executed with Fibers" do
14
- Fiber.new { expect(Audited.store[:current_user]).to eq(current_user) }.resume
15
- end
16
12
  end
17
13
  end
18
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audited
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.2
4
+ version: 5.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Keepers
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2023-02-22 00:00:00.000000000 Z
16
+ date: 2023-04-24 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activerecord
@@ -35,6 +35,20 @@ dependencies:
35
35
  - - "<"
36
36
  - !ruby/object:Gem::Version
37
37
  version: '7.1'
38
+ - !ruby/object:Gem::Dependency
39
+ name: request_store
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "~>"
43
+ - !ruby/object:Gem::Version
44
+ version: '1.2'
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '1.2'
38
52
  - !ruby/object:Gem::Dependency
39
53
  name: appraisal
40
54
  requirement: !ruby/object:Gem::Requirement
@@ -252,7 +266,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
266
  - !ruby/object:Gem::Version
253
267
  version: '0'
254
268
  requirements: []
255
- rubygems_version: 3.4.6
269
+ rubygems_version: 3.4.7
256
270
  signing_key:
257
271
  specification_version: 4
258
272
  summary: Log all changes to your models