Skip to content

Commit

Permalink
Merge pull request #645 from ForestAdmin/beta
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasalexandre9 authored Jan 25, 2024
2 parents 1a73eb6 + ca036ec commit 12a8652
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 29 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [9.0.0-beta.1](https://github.com/ForestAdmin/forest-rails/compare/v8.1.0...v9.0.0-beta.1) (2024-01-23)


### Features

* **polymorphic:** enabled polymorphic associations support by default ([#644](https://github.com/ForestAdmin/forest-rails/issues/644)) ([92853a9](https://github.com/ForestAdmin/forest-rails/commit/92853a91ed23b8834f85582aef8f24c6b12f3cb0))


### BREAKING CHANGES

* **polymorphic:** polymorphic association support enabled by default. It is no longer necessary to define the env variable ENABLE_SUPPORT_POLYMORPHISM

# [8.1.0](https://github.com/ForestAdmin/forest-rails/compare/v8.0.17...v8.1.0) (2024-01-18)


Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
forest_liana (8.1.0)
forest_liana (9.0.0-beta.1)
arel-helpers
bcrypt
deepsort
Expand Down
2 changes: 0 additions & 2 deletions app/services/forest_liana/schema_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,6 @@ def add_associations
SchemaUtils.associations(@model).each do |association|
begin
if SchemaUtils.polymorphic?(association) &&
(ENV['ENABLE_SUPPORT_POLYMORPHISM'].present? && ENV['ENABLE_SUPPORT_POLYMORPHISM'].downcase == 'true')

collection.fields << {
field: association.name.to_s,
type: get_type_for_association(association),
Expand Down
7 changes: 1 addition & 6 deletions app/services/forest_liana/schema_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ class SchemaUtils
def self.associations(active_record_class)
active_record_class.reflect_on_all_associations.select do |association|
begin
if (ENV['ENABLE_SUPPORT_POLYMORPHISM'].present? && ENV['ENABLE_SUPPORT_POLYMORPHISM'].downcase == 'true')
polymorphic?(association) ? true : !is_active_type?(association.klass)
else
!polymorphic?(association) && !is_active_type?(association.klass)
end

polymorphic?(association) ? true : !is_active_type?(association.klass)
rescue
FOREST_LOGGER.warn "Unknown association #{association.name} on class #{active_record_class.name}"
false
Expand Down
2 changes: 1 addition & 1 deletion lib/forest_liana/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ForestLiana
VERSION = "8.1.0"
VERSION = "9.0.0-beta.1"
end
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "forest-rails",
"version": "8.1.0",
"version": "9.0.0-beta.1",
"description": "The official Rails liana for Forest.",
"directories": {
"test": "test"
Expand Down
17 changes: 0 additions & 17 deletions spec/services/forest_liana/schema_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,6 @@ module ForestLiana

expect(removed_fields).to be_empty
end

context 'when the polymorphic support was disabled' do
it 'should not define the association' do
ENV['ENABLE_SUPPORT_POLYMORPHISM'] = 'false'
Bootstrapper.new(true)
collection = ForestLiana.apimap.find do |object|
object.name.to_s == ForestLiana.name_for(Address)
end
association = collection.fields.find { |field| field[:field] == 'addressable' }
fields = collection.fields.select do |field|
field[:field] == 'addressable_id' || field[:field] == 'addressable_type'
end

expect(association).to be_nil
expect(fields.size).to eq(2)
end
end
end

context 'with an "unhandled" column types (binary, postgis geography, ...)' do
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
ENV['RAILS_ENV'] = 'test'
ENV['ENABLE_SUPPORT_POLYMORPHISM'] = 'true'

require File.expand_path('../dummy/config/environment', __FILE__)

Expand Down

0 comments on commit 12a8652

Please sign in to comment.