Skip to content

Commit

Permalink
Merge branch 'main' into migrate_to_current_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorrison committed Nov 6, 2023
2 parents f8416b1 + 9a1bed7 commit 626a97b
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- rails60
- rails61
- rails70
- rails71
db: [POSTGRES, MYSQL, SQLITE]
exclude:
# MySQL has issues on Ruby 2.3
Expand Down Expand Up @@ -96,6 +97,16 @@ jobs:
- appraisal: rails70
ruby: 2.6

# Rails 7.1 supports Ruby 2.7+
- appraisal: rails71
ruby: 2.3
- appraisal: rails71
ruby: 2.4
- appraisal: rails71
ruby: 2.5
- appraisal: rails71
ruby: 2.6

services:
postgres:
image: postgres
Expand Down
10 changes: 10 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ appraise "rails50" do
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "psych", "~> 3.1"
gem "loofah", "2.20.0"
end

appraise "rails51" do
Expand All @@ -15,6 +16,7 @@ appraise "rails51" do
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "psych", "~> 3.1"
gem "loofah", "2.20.0"
end

appraise "rails52" do
Expand All @@ -23,6 +25,7 @@ appraise "rails52" do
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "psych", "~> 3.1"
gem "loofah", "2.20.0"
end

appraise "rails60" do
Expand All @@ -45,3 +48,10 @@ appraise "rails70" do
gem "pg", ">= 1.1"
gem "sqlite3", ">= 1.4"
end

appraise "rails71" do
gem "rails", ">= 7.1.0.beta1", "< 7.2"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1"
gem "sqlite3", ">= 1.4"
end
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Audited ChangeLog

## 5.4.0 (2023-09-30)

- Add Rails 7.1 support - @yuki24
[#686](https://github.com/collectiveidea/audited/pull/686)

## 5.3.3 (2023-03-24)

- Use RequestStore instead of Thread.current for thread-safe requests - @tiagocassio
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Audited
**Audited** (previously acts_as_audited) is an ORM extension that logs all changes to your models. Audited can also record who made those changes, save comments and associate models related to the changes.


Audited currently (5.x) works with Rails 7.0, 6.1, 6.0, 5.2, 5.1, and 5.0.
Audited currently (5.x) works with Rails 7.1, 7.0, 6.1, 6.0, 5.2, 5.1, and 5.0.

For Rails 4, use gem version 4.x
For Rails 3, use gem version 3.0 or see the [3.0-stable branch](https://github.com/collectiveidea/audited/tree/3.0-stable).
Expand Down
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.1"
gem.add_dependency "activesupport", ">= 5.0", "< 7.1"
gem.add_dependency "activerecord", ">= 5.0", "< 7.7"
gem.add_dependency "activesupport", ">= 5.0", "< 7.7"

gem.add_development_dependency "appraisal"
gem.add_development_dependency "rails", ">= 5.0", "< 7.1"
gem.add_development_dependency "rails", ">= 5.0", "< 7.7"
gem.add_development_dependency "rspec-rails"
gem.add_development_dependency "standard"
gem.add_development_dependency "single_cov"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails50.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ gem "mysql2", ">= 0.3.18", "< 0.6.0"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "psych", "~> 3.1"
gem "loofah", "2.20.0"

gemspec name: "audited", path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails51.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ gem "mysql2", ">= 0.3.18", "< 0.6.0"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "psych", "~> 3.1"
gem "loofah", "2.20.0"

gemspec name: "audited", path: "../"
1 change: 1 addition & 0 deletions gemfiles/rails52.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ gem "mysql2", ">= 0.4.4", "< 0.6.0"
gem "pg", ">= 0.18", "< 2.0"
gem "sqlite3", "~> 1.3.6"
gem "psych", "~> 3.1"
gem "loofah", "2.20.0"

gemspec name: "audited", path: "../"
10 changes: 10 additions & 0 deletions gemfiles/rails71.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", ">= 7.1.0.beta1", "< 7.2"
gem "mysql2", ">= 0.4.4"
gem "pg", ">= 1.1"
gem "sqlite3", ">= 1.4"

gemspec name: "audited", path: "../"
3 changes: 2 additions & 1 deletion lib/audited.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def audit_class

# remove audit_model in next major version it was only shortly present in 5.1.0
alias_method :audit_model, :audit_class
deprecate audit_model: "use Audited.audit_class instead of Audited.audit_model. This method will be removed."
deprecate audit_model: "use Audited.audit_class instead of Audited.audit_model. This method will be removed.",
deprecator: ActiveSupport::Deprecation.new('6.0.0', 'Audited')

def store
Audited::RequestStore.audited_store ||= {}
Expand Down
6 changes: 5 additions & 1 deletion lib/audited/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ class Audit < ::ActiveRecord::Base
cattr_accessor :audited_class_names
self.audited_class_names = Set.new

serialize :audited_changes, YAMLIfTextColumnType
if Rails.version >= "7.1"
serialize :audited_changes, coder: YAMLIfTextColumnType
else
serialize :audited_changes, YAMLIfTextColumnType
end

scope :ascending, -> { reorder(version: :asc) }
scope :descending, -> { reorder(version: :desc) }
Expand Down
2 changes: 1 addition & 1 deletion lib/audited/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Audited
VERSION = "5.3.3"
VERSION = "5.4.0"
end
2 changes: 1 addition & 1 deletion spec/audited/audit_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

SingleCov.covered! uncovered: 1 # Rails version check
SingleCov.covered! uncovered: 2 # Rails version check

class CustomAudit < Audited::Audit
def custom_method
Expand Down
25 changes: 24 additions & 1 deletion spec/rails_app/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,34 @@ class Application < Rails::Application
config.root = File.expand_path("../../", __FILE__)
config.i18n.enforce_available_locales = true

if !Rails.version.start_with?("5.0") && !Rails.version.start_with?("5.1") && config.active_record.respond_to?(:yaml_column_permitted_classes=)
if Rails.version.start_with?("7.1") && config.active_record.respond_to?(:yaml_column_permitted_classes=)
config.active_record.yaml_column_permitted_classes = [
String,
Symbol,
Integer,
NilClass,
Float,
Time,
Date,
FalseClass,
Hash,
Array,
DateTime,
TrueClass,
BigDecimal,
ActiveSupport::TimeWithZone,
ActiveSupport::TimeZone,
ActiveSupport::HashWithIndifferentAccess
]
elsif !Rails.version.start_with?("5.0") && !Rails.version.start_with?("5.1") && config.active_record.respond_to?(:yaml_column_permitted_classes=)
config.active_record.yaml_column_permitted_classes =
%w[String Symbol Integer NilClass Float Time Date FalseClass Hash Array DateTime TrueClass BigDecimal
ActiveSupport::TimeWithZone ActiveSupport::TimeZone ActiveSupport::HashWithIndifferentAccess]
end

if Rails.version >= "7.1"
config.active_support.cache_format_version = 7.1
end
end
end

Expand Down
7 changes: 6 additions & 1 deletion spec/support/active_record/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ class User < ::ActiveRecord::Base
attribute :non_column_attr if Rails.version >= "5.1"
attr_protected :logins if respond_to?(:attr_protected)
enum status: {active: 0, reliable: 1, banned: 2}
serialize :phone_numbers, Array

if Rails.version >= "7.1"
serialize :phone_numbers, type: Array
else
serialize :phone_numbers, Array
end

def name=(val)
write_attribute(:name, CGI.escapeHTML(val))
Expand Down

0 comments on commit 626a97b

Please sign in to comment.