Skip to content

[wip] use rails 8.0 #194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
strategy:
matrix:
ruby-version:
- '3.1'
- '3.2'
- '3.3'
- '3.4'
services:
Expand Down Expand Up @@ -65,7 +63,7 @@ jobs:
DB: mysql2
run: bundle exec rake
- name: Report code coverage
if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.1' }}
if: ${{ github.ref == 'refs/heads/master' && matrix.ruby-version == '3.3' }}
continue-on-error: true
uses: paambaati/codeclimate-action@v9
env:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ The versioning of this gem follows ActiveRecord versioning, and does not follow

## [Unreleased]

## [8.0.0.0] - 2025-07-10

* Rails 8.0 support [#194](https://github.com/ManageIQ/activerecord-virtual_attributes/pull/194)

## [7.2.0.1] - 2025-07-18

* Fix includes and associations with empty uses [#195](https://github.com/ManageIQ/activerecord-virtual_attributes/pull/195)
Expand Down
9 changes: 5 additions & 4 deletions activerecord-virtual_attributes.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib = File.expand_path("../lib", __FILE__)
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.push(lib) unless $LOAD_PATH.include?(lib)

require "active_record/virtual_attributes/version"
Expand All @@ -22,13 +22,14 @@ Gem::Specification.new do |spec|

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|bin)/}) || f.match(/^(\.)|renovate.json/) }
end

spec.require_paths = ["lib"]

spec.add_runtime_dependency "activerecord", "~> 7.2.2", ">=7.2.2.1"
# spec.add_runtime_dependency "activerecord", "~> 7.2.2", ">=7.2.2.1"
spec.add_runtime_dependency "activerecord", "~> 8.0", ">= 8.0.2"

spec.add_development_dependency "byebug"
spec.add_development_dependency "database_cleaner-active_record", "~> 2.1"
Expand All @@ -40,5 +41,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "simplecov", ">= 0.21.2"
spec.add_development_dependency "sqlite3", "< 2"
spec.add_development_dependency "sqlite3", "~>2.1"
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RSpec::Matchers.define(:have_virtual_attribute) do |name, type|
match do |klass|
expect(klass.has_attribute?(name)).to be_truthy
expect(klass.virtual_attribute?(name)).to be_truthy
expect(klass.has_attribute?(name)).to(be_truthy)
expect(klass.virtual_attribute?(name)).to(be_truthy)
expect(klass.type_for_attribute(name.to_s).type).to(eq(type)) if type
klass.instance_methods.include?(name.to_sym)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_record/virtual_attributes/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ActiveRecord
module VirtualAttributes
VERSION = "7.2.0.1".freeze
VERSION = "8.0.0.0".freeze
end
end
2 changes: 1 addition & 1 deletion lib/active_record/virtual_attributes/virtual_delegates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def determine_method_names(column, to, prefix) # rubocop:disable Naming/MethodPa
end

method_prefix = "#{prefix == true ? to : prefix}_" if prefix
method_name = "#{method_prefix}#{method_name}".to_sym
method_name = :"#{method_prefix}#{method_name}"

[method_name, to.to_sym, column]
end
Expand Down
2 changes: 2 additions & 0 deletions lib/active_record/virtual_attributes/virtual_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module VirtualFields
include ActiveRecord::VirtualAttributes::VirtualReflections

# rubocop:disable Style/SingleLineMethods
# rubocop:disable Naming/PredicateMethod
module NonARModels
def dangerous_attribute_method?(_); false; end

Expand All @@ -15,6 +16,7 @@ def add_autosave_association_callbacks(*_args); self; end

def belongs_to_required_by_default; false; end
end
# rubocop:enable Naming/PredicateMethod
# rubocop:enable Style/SingleLineMethods

included do
Expand Down
2 changes: 1 addition & 1 deletion lib/active_record/virtual_attributes/virtual_total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ def virtual_aggregate_arel(reflection, method_name, column)
end
end

ActiveRecord::Base.include VirtualAttributes::VirtualTotal
ActiveSupport.on_load(:active_record) { include VirtualAttributes::VirtualTotal }