Skip to content

Commit

Permalink
Merge pull request #40 from zendesk/edytaroz/rails-main-testing
Browse files Browse the repository at this point in the history
Test with rails main
  • Loading branch information
zendesk-edytaroz authored Aug 14, 2024
2 parents 4b8c8bd + f345225 commit d8fb372
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 34 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ jobs:
fail-fast: false
matrix:
ruby:
- '3.0'
- '3.1'
- '3.2'
- '3.3'
gemfile:
- rails6.0
- rails6.1
- rails7.0
- rails7.1
- rails7.2
env:
CI: true
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/rails_main_testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test against Rails main

on:
schedule:
- cron: "0 0 * * *" # Run every day at 00:00 UTC
workflow_dispatch:
push:

jobs:
main:
name: Ruby${{ matrix.ruby }} rails_main
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby:
- '3.3'
env:
CI: true
BUNDLE_GEMFILE: gemfiles/rails_main.gemfile

steps:
- uses: zendesk/checkout@v3
- uses: zendesk/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake test
6 changes: 3 additions & 3 deletions active_record_inherit_assoc.gemspec
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name = "active_record_inherit_assoc"

Gem::Specification.new name, "2.13.2" do |s|
Gem::Specification.new name, "2.14.0" do |s|
s.summary = "Attribute inheritance for AR associations"
s.authors = ["Ben Osheroff"]
s.email = ["[email protected]"]
s.files = `git ls-files lib`.split("\n")
s.license = "Apache License Version 2.0"
s.homepage = "https://github.com/zendesk/#{name}"

s.add_runtime_dependency 'activerecord', '>= 5.0.0', '< 7.2'
s.required_ruby_version = '>= 2.6'
s.add_runtime_dependency 'activerecord', '>= 6.1'
s.required_ruby_version = '>= 3.1'
end
2 changes: 1 addition & 1 deletion gemfiles/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
gem 'minitest-rg'
gem 'rake'
gem 'bump'
gem 'sqlite3'
gem 'sqlite3', '~> 1.4'
gem 'byebug'
3 changes: 0 additions & 3 deletions gemfiles/rails5.0.gemfile

This file was deleted.

3 changes: 0 additions & 3 deletions gemfiles/rails5.1.gemfile

This file was deleted.

3 changes: 0 additions & 3 deletions gemfiles/rails5.2.gemfile

This file was deleted.

3 changes: 0 additions & 3 deletions gemfiles/rails6.0.gemfile

This file was deleted.

3 changes: 3 additions & 0 deletions gemfiles/rails7.2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eval_gemfile('common.rb')

gem 'activerecord', '~> 7.2.0'
3 changes: 3 additions & 0 deletions gemfiles/rails_main.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eval_gemfile('common.rb')

gem 'activerecord', github: 'rails/rails', branch: 'main'
21 changes: 5 additions & 16 deletions lib/active_record_inherit_assoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,12 @@ def skip_statement_cache?(*)
ActiveRecord::Associations::Association.send(:prepend, ActiveRecordInheritAssocPrepend)

module ActiveRecordInheritPreloadAssocPrepend
if ActiveRecord::VERSION::STRING < '5.2.0'
def associated_records_by_owner(*)
super.tap do |result|
next unless inherit = reflection.options[:inherit]
result.each do |owner, associated_records|
filter_associated_records_with_inherit!(owner, associated_records, inherit)
end
end
end
else
def associate_records_to_owner(owner, records)
if inherit = reflection.options[:inherit]
records = Array(records)
filter_associated_records_with_inherit!(owner, records, inherit)
end
super
def associate_records_to_owner(owner, records)
if inherit = reflection.options[:inherit]
records = Array(records)
filter_associated_records_with_inherit!(owner, records, inherit)
end
super
end

def build_scope
Expand Down

0 comments on commit d8fb372

Please sign in to comment.