Skip to content

Commit

Permalink
Rails 7.1 support, Ruby 3.1-3.2 support (#196)
Browse files Browse the repository at this point in the history
* Change GitHub Actions to run on ubuntu-20.04

* Be less specific with Ruby versions, cleanup matrix excludes

* Use strings for Ruby versions, fix Struct usage for Ruby 3.2

* Replace unsupported git:// protocol

* Update rails_head.gemfile

* Use main branch for rack

* Add Rails 7.1 support

* Gemfile should test against 7.1

* Rails 7.1+ support

* Amend CHANGELOG
  • Loading branch information
cgriego authored Oct 30, 2023
1 parent cd5b59b commit 3e7aeb9
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 114 deletions.
203 changes: 103 additions & 100 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ on:
jobs:
test:
name: Ruby ${{ matrix.ruby }} with ${{ matrix.gemfile }}
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
continue-on-error: ${{ contains(matrix.ruby, 'head') || contains(matrix.gemfile, 'head') }}
strategy:
fail-fast: false
matrix:
ruby:
- 2.1.9
- 2.2.10
- 2.3.8
- 2.4.10
- 2.5.9
- 2.6.8
- 2.7.4
- 3.0.2
- "2.1"
- "2.2"
- "2.3"
- "2.4"
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- truffleruby-head
gemfile:
- gemfiles/rails_3_0.gemfile
Expand All @@ -36,140 +38,141 @@ jobs:
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_6_0.gemfile
- gemfiles/rails_6_1.gemfile
- gemfiles/rails_7_0.gemfile
- Gemfile
- gemfiles/rails_head.gemfile
exclude:
- ruby: 1.9.2
gemfile: gemfiles/rails_4_0.gemfile
- ruby: 1.9.2
gemfile: gemfiles/rails_4_1.gemfile
- ruby: 1.9.2
gemfile: gemfiles/rails_4_2.gemfile
- ruby: 1.9.2
gemfile: gemfiles/rails_5_0.gemfile
- ruby: 1.9.2
gemfile: gemfiles/rails_5_1.gemfile
- ruby: 1.9.2
gemfile: gemfiles/rails_5_2.gemfile
- ruby: 1.9.2
gemfile: gemfiles/rails_6_0.gemfile
- ruby: 1.9.2
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 1.9.2
gemfile: Gemfile
- ruby: 1.9.2
gemfile: gemfiles/rails_head.gemfile
- ruby: 1.9.3
gemfile: gemfiles/rails_5_0.gemfile
- ruby: 1.9.3
gemfile: gemfiles/rails_5_1.gemfile
- ruby: 1.9.3
gemfile: gemfiles/rails_5_2.gemfile
- ruby: 1.9.3
gemfile: gemfiles/rails_6_0.gemfile
- ruby: 1.9.3
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 1.9.3
gemfile: Gemfile
- ruby: 1.9.3
gemfile: gemfiles/rails_head.gemfile
- ruby: 2.0.0
gemfile: gemfiles/rails_5_0.gemfile
- ruby: 2.0.0
gemfile: gemfiles/rails_5_1.gemfile
- ruby: 2.0.0
gemfile: gemfiles/rails_5_2.gemfile
- ruby: 2.0.0
gemfile: gemfiles/rails_6_0.gemfile
- ruby: 2.0.0
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 2.0.0
gemfile: Gemfile
- ruby: 2.0.0
gemfile: gemfiles/rails_head.gemfile
- ruby: 2.1.9
- ruby: "2.1"
gemfile: gemfiles/rails_5_0.gemfile
- ruby: 2.1.9
- ruby: "2.1"
gemfile: gemfiles/rails_5_1.gemfile
- ruby: 2.1.9
- ruby: "2.1"
gemfile: gemfiles/rails_5_2.gemfile
- ruby: 2.1.9
- ruby: "2.1"
gemfile: gemfiles/rails_6_0.gemfile
- ruby: 2.1.9
- ruby: "2.1"
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 2.1.9
- ruby: "2.1"
gemfile: gemfiles/rails_7_0.gemfile
- ruby: "2.1"
gemfile: Gemfile
- ruby: 2.1.9
- ruby: "2.1"
gemfile: gemfiles/rails_head.gemfile
- ruby: 2.2.10
- ruby: "2.2"
gemfile: gemfiles/rails_6_0.gemfile
- ruby: 2.2.10
- ruby: "2.2"
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 2.2.10
- ruby: "2.2"
gemfile: gemfiles/rails_7_0.gemfile
- ruby: "2.2"
gemfile: Gemfile
- ruby: 2.2.10
- ruby: "2.2"
gemfile: gemfiles/rails_head.gemfile
- ruby: 2.3.8
- ruby: "2.3"
gemfile: gemfiles/rails_6_0.gemfile
- ruby: 2.3.8
- ruby: "2.3"
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 2.3.8
- ruby: "2.3"
gemfile: gemfiles/rails_7_0.gemfile
- ruby: "2.3"
gemfile: Gemfile
- ruby: 2.3.8
- ruby: "2.3"
gemfile: gemfiles/rails_head.gemfile
- ruby: 2.4.10
- ruby: "2.4"
gemfile: gemfiles/rails_6_0.gemfile
- ruby: 2.4.10
- ruby: "2.4"
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 2.4.10
- ruby: "2.4"
gemfile: gemfiles/rails_7_0.gemfile
- ruby: "2.4"
gemfile: Gemfile
- ruby: 2.4.10
- ruby: "2.4"
gemfile: gemfiles/rails_head.gemfile
- ruby: 2.5.9
- ruby: "2.5"
gemfile: gemfiles/rails_3_0.gemfile
- ruby: 2.5.9
- ruby: "2.5"
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 2.5.9
- ruby: "2.5"
gemfile: gemfiles/rails_7_0.gemfile
- ruby: "2.5"
gemfile: Gemfile
- ruby: 2.5.9
- ruby: "2.5"
gemfile: gemfiles/rails_head.gemfile
- ruby: 2.6.8
- ruby: "2.6"
gemfile: gemfiles/rails_3_0.gemfile
- ruby: 2.6.8
- ruby: "2.6"
gemfile: gemfiles/rails_6_1.gemfile
- ruby: 2.6.8
- ruby: "2.6"
gemfile: gemfiles/rails_7_0.gemfile
- ruby: "2.6"
gemfile: Gemfile
- ruby: 2.6.8
- ruby: "2.6"
gemfile: gemfiles/rails_head.gemfile
- ruby: 2.7.4
- ruby: "2.7"
gemfile: gemfiles/rails_3_0.gemfile
- ruby: 2.7.4
- ruby: "2.7"
gemfile: gemfiles/rails_3_1.gemfile
- ruby: 2.7.4
- ruby: "2.7"
gemfile: gemfiles/rails_3_2.gemfile
- ruby: 2.7.4
- ruby: "2.7"
gemfile: gemfiles/rails_4_0.gemfile
- ruby: 2.7.4
- ruby: "2.7"
gemfile: gemfiles/rails_4_1.gemfile
- ruby: 2.7.4
- ruby: "2.7"
gemfile: gemfiles/rails_4_2.gemfile
- ruby: 3.0.2
- ruby: "3.0"
gemfile: gemfiles/rails_3_0.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_3_1.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_3_2.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_4_0.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_4_1.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_4_2.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_5_0.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_5_1.gemfile
- ruby: "3.0"
gemfile: gemfiles/rails_5_2.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_3_0.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_3_1.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_3_2.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_4_0.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_4_1.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_4_2.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_5_0.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_5_1.gemfile
- ruby: "3.1"
gemfile: gemfiles/rails_5_2.gemfile
- ruby: "3.2"
gemfile: gemfiles/rails_3_0.gemfile
- ruby: 3.0.2
- ruby: "3.2"
gemfile: gemfiles/rails_3_1.gemfile
- ruby: 3.0.2
- ruby: "3.2"
gemfile: gemfiles/rails_3_2.gemfile
- ruby: 3.0.2
- ruby: "3.2"
gemfile: gemfiles/rails_4_0.gemfile
- ruby: 3.0.2
- ruby: "3.2"
gemfile: gemfiles/rails_4_1.gemfile
- ruby: 3.0.2
- ruby: "3.2"
gemfile: gemfiles/rails_4_2.gemfile
- ruby: 3.0.2
- ruby: "3.2"
gemfile: gemfiles/rails_5_0.gemfile
- ruby: 3.0.2
- ruby: "3.2"
gemfile: gemfiles/rails_5_1.gemfile
- ruby: 3.0.2
- ruby: "3.2"
gemfile: gemfiles/rails_5_2.gemfile
- ruby: truffleruby-head
gemfile: gemfiles/rails_3_0.gemfile
Expand All @@ -195,7 +198,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Nokogiri support for TruffleRuby
run: sudo apt-get -yqq install libxml2-dev libxslt-dev
if: ${{ matrix.ruby == 'truffleruby-head' }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# ActiveAttr 0.16.0 (October 30, 2023)

* ActiveAttr now supports Ruby 3.1
* ActiveAttr now supports Ruby 3.2
* ActiveAttr now supports Rails 7.1 (thanks @mathieujobin)

# ActiveAttr 0.15.4 (December 16, 2021)

* ActiveAttr now supports Rails 7.0 (Steve Hoeksema)
Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ source "https://rubygems.org"

gemspec :development_group => :test

gem "activemodel", "~> 7.0.0"
gem "activesupport", "~> 7.0.0"
gem "actionpack", "~> 7.0.0"
gem "activemodel", "~> 7.1.0"
gem "activesupport", "~> 7.1.0"
gem "actionpack", "~> 7.1.0"
gem "activemodel-serializers-xml", :group => :test
gem "rexml", :group => :test
gem "protected_attributes_continued", :group => :test
Expand Down
6 changes: 3 additions & 3 deletions active_attr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = ">= 2.1.0"

gem.add_runtime_dependency "actionpack", ">= 3.0.2", "< 7.1"
gem.add_runtime_dependency "activemodel", ">= 3.0.2", "< 7.1"
gem.add_runtime_dependency "activesupport", ">= 3.0.2", "< 7.1"
gem.add_runtime_dependency "actionpack", ">= 3.0.2", "< 7.2"
gem.add_runtime_dependency "activemodel", ">= 3.0.2", "< 7.2"
gem.add_runtime_dependency "activesupport", ">= 3.0.2", "< 7.2"

gem.add_development_dependency "bundler"
gem.add_development_dependency "factory_bot", "< 5.0"
Expand Down
10 changes: 10 additions & 0 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source "https://rubygems.org"

gemspec :development_group => :test, :path => ".."

gem "activemodel", "~> 7.0.0"
gem "activesupport", "~> 7.0.0"
gem "actionpack", "~> 7.0.0"
gem "activemodel-serializers-xml", :group => :test
gem "rexml", :group => :test
gem "protected_attributes_continued", :group => :test
8 changes: 4 additions & 4 deletions gemfiles/rails_head.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ source "https://rubygems.org"

gemspec :development_group => :test, :path => ".."

git "git://github.com/rails/rails.git", :branch => "main" do
git "https://github.com/rails/rails.git", :branch => "main" do
gem "activemodel"
gem "activesupport"
gem "actionpack"
end

gem "activemodel-serializers-xml", :group => :test, :git => "git://github.com/rails/activemodel-serializers-xml.git"
gem "activemodel-serializers-xml", :group => :test, :git => "https://github.com/rails/activemodel-serializers-xml.git"
gem "rexml", :group => :test
gem "protected_attributes_continued", :group => :test, :git => "git://github.com/westonganger/protected_attributes_continued"
gem "rack", :group => :test, :git => "git://github.com/rack/rack.git"
gem "protected_attributes_continued", :group => :test, :git => "https://github.com/westonganger/protected_attributes_continued.git"
gem "rack", :group => :test, :git => "https://github.com/rack/rack.git", :branch => "main"
12 changes: 10 additions & 2 deletions lib/active_attr/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def self.filter_attributes=(new_filter_attributes)
class_attribute :filter_attributes, :instance_writer => false
self.filter_attributes = Attributes.filter_attributes

attribute_method_suffix "" if attribute_method_matchers.none? { |matcher| matcher.prefix == "" && matcher.suffix == "" }
attribute_method_suffix "" if attribute_method_patterns.none? { |matcher| matcher.prefix == "" && matcher.suffix == "" }
attribute_method_suffix "="
end

Expand Down Expand Up @@ -323,6 +323,14 @@ def inspect
"#{name}#{attributes_list}"
end

# Renamed in ActiveModel 7.1
#
# @private
# @since 0.16.0
def attribute_method_patterns
attribute_method_matchers
end unless method_defined?(:attribute_method_patterns)

protected

# Assign a set of attribute definitions, used when subclassing models
Expand All @@ -346,7 +354,7 @@ def instance_method_already_implemented?(method_name)
#
# @since 0.6.0
def attribute_methods(name)
attribute_method_matchers.map { |matcher| matcher.method_name name }
attribute_method_patterns.map { |matcher| matcher.method_name name }
end

# Ruby inherited hook to assign superclass attributes to subclasses
Expand Down
2 changes: 1 addition & 1 deletion lib/active_attr/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ActiveAttr
# Complete version string
# @since 0.1.0
VERSION = "0.15.4"
VERSION = "0.16.0"
end
2 changes: 1 addition & 1 deletion spec/unit/active_attr/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def self.name
end

it "returns false when compared to another type" do
should_not == Struct.new(:attributes).new("first_name" => "Ben")
should_not == Struct.new(:attributes).new({ "first_name" => "Ben" })
end
end

Expand Down

0 comments on commit 3e7aeb9

Please sign in to comment.