Skip to content

Commit

Permalink
Support for Rails 6.1.4.1 and onward (Until 7) + Supporting CI Change…
Browse files Browse the repository at this point in the history
…s. (#47)

* Support for rails below

* formatting

* run bundle install before bundle exec.

* cache bad.

* delete lock files.

* rails 6.1 test

* add force:false

* conditional force:false

* set fail fast to be false

* use association or reflection depending on version.
  • Loading branch information
Aelphaeis authored Oct 26, 2021
1 parent 24eb372 commit 01be377
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 304 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
gemfile:
- Gemfile.rails-5.0-stable
- Gemfile.rails-5.1-stable
- Gemfile.rails-5.2-stable
- Gemfile.rails-6.0-stable
- Gemfile.rails-6.1-stable
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
steps:
Expand All @@ -25,6 +27,8 @@ jobs:
uses: ruby/setup-ruby@v1
with:
ruby-version: "2.6"
bundler-cache: true
- name: Install dependencies
run: bundle install
- name: Run tests
run: bundle exec rspec
run:
bundle exec rspec
74 changes: 0 additions & 74 deletions gemfiles/Gemfile.rails-5.0-stable.lock

This file was deleted.

74 changes: 0 additions & 74 deletions gemfiles/Gemfile.rails-5.1-stable.lock

This file was deleted.

74 changes: 0 additions & 74 deletions gemfiles/Gemfile.rails-5.2-stable.lock

This file was deleted.

74 changes: 0 additions & 74 deletions gemfiles/Gemfile.rails-6.0-stable.lock

This file was deleted.

7 changes: 7 additions & 0 deletions gemfiles/Gemfile.rails-6.1-stable
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec path: ".."

gem "activerecord", github: "rails/rails", branch: "6-1-stable"
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ module PolymorphicArrayValueExtension
# end

def type_to_ids_mapping
association = @associated_table.send(:association)
if ACTIVE_RECORD_VERSION < Gem::Version.new("6.1")
association = @associated_table.send(:association)
else
association = @associated_table.send(:reflection)
end

name = association.name
default_hash = Hash.new { |hsh, key| hsh[key] = [] }
values.each_with_object(default_hash) do |value, hash|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
module ActiveRecord
module Associations
class BelongsToPolymorphicAssociation < BelongsToAssociation
private def replace_keys(record)
super
unless record.nil?
owner[reflection.foreign_type] = record.class.base_class
private

if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("6.1")
def replace_keys(record)
super
owner[reflection.foreign_type] = record.class.base_class unless record.nil?
end
elsif
def replace_keys(record, force: false)
super
owner[reflection.foreign_type] = record.class.base_class unless record.nil?
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion polymorphic_integer_type.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_dependency "activerecord", "< 6.1"
spec.add_dependency "activerecord", "< 7"
spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
Expand Down

0 comments on commit 01be377

Please sign in to comment.