diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 432e09a4..6e9cdf84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ jobs: - rails60 - rails61 - rails70 + - rails71 db: [POSTGRES, MYSQL, SQLITE] exclude: # MySQL has issues on Ruby 2.3 @@ -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 diff --git a/Appraisals b/Appraisals index e41dacfa..96d1e5ba 100644 --- a/Appraisals +++ b/Appraisals @@ -45,3 +45,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 diff --git a/audited.gemspec b/audited.gemspec index fdcf636e..74638004 100644 --- a/audited.gemspec +++ b/audited.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |gem| gem.required_ruby_version = ">= 2.3.0" - gem.add_dependency "activerecord", ">= 5.0", "< 7.1" + gem.add_dependency "activerecord", ">= 5.0", "< 7.2" gem.add_dependency "request_store", "~> 1.2" gem.add_development_dependency "appraisal" diff --git a/gemfiles/rails71.gemfile b/gemfiles/rails71.gemfile new file mode 100644 index 00000000..e34fc967 --- /dev/null +++ b/gemfiles/rails71.gemfile @@ -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: "../" diff --git a/lib/audited.rb b/lib/audited.rb index d548711e..7f500d3d 100644 --- a/lib/audited.rb +++ b/lib/audited.rb @@ -22,7 +22,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 RequestStore.store[:audited_store] ||= {} diff --git a/lib/audited/audit.rb b/lib/audited/audit.rb index 7201adac..7117d19c 100644 --- a/lib/audited/audit.rb +++ b/lib/audited/audit.rb @@ -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) } diff --git a/spec/audited/audit_spec.rb b/spec/audited/audit_spec.rb index 546bbe36..c18abdb5 100644 --- a/spec/audited/audit_spec.rb +++ b/spec/audited/audit_spec.rb @@ -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 diff --git a/spec/rails_app/config/application.rb b/spec/rails_app/config/application.rb index 7c2bec71..dca65709 100644 --- a/spec/rails_app/config/application.rb +++ b/spec/rails_app/config/application.rb @@ -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 diff --git a/spec/support/active_record/models.rb b/spec/support/active_record/models.rb index 5c5def30..9acceb43 100644 --- a/spec/support/active_record/models.rb +++ b/spec/support/active_record/models.rb @@ -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))