Skip to content

Commit 12a8652

Browse files
Merge pull request #645 from ForestAdmin/beta
2 parents 1a73eb6 + ca036ec commit 12a8652

File tree

8 files changed

+16
-29
lines changed

8 files changed

+16
-29
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# [9.0.0-beta.1](https://github.com/ForestAdmin/forest-rails/compare/v8.1.0...v9.0.0-beta.1) (2024-01-23)
2+
3+
4+
### Features
5+
6+
* **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))
7+
8+
9+
### BREAKING CHANGES
10+
11+
* **polymorphic:** polymorphic association support enabled by default. It is no longer necessary to define the env variable ENABLE_SUPPORT_POLYMORPHISM
12+
113
# [8.1.0](https://github.com/ForestAdmin/forest-rails/compare/v8.0.17...v8.1.0) (2024-01-18)
214

315

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
forest_liana (8.1.0)
4+
forest_liana (9.0.0-beta.1)
55
arel-helpers
66
bcrypt
77
deepsort

app/services/forest_liana/schema_adapter.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ def add_associations
242242
SchemaUtils.associations(@model).each do |association|
243243
begin
244244
if SchemaUtils.polymorphic?(association) &&
245-
(ENV['ENABLE_SUPPORT_POLYMORPHISM'].present? && ENV['ENABLE_SUPPORT_POLYMORPHISM'].downcase == 'true')
246-
247245
collection.fields << {
248246
field: association.name.to_s,
249247
type: get_type_for_association(association),

app/services/forest_liana/schema_utils.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ class SchemaUtils
44
def self.associations(active_record_class)
55
active_record_class.reflect_on_all_associations.select do |association|
66
begin
7-
if (ENV['ENABLE_SUPPORT_POLYMORPHISM'].present? && ENV['ENABLE_SUPPORT_POLYMORPHISM'].downcase == 'true')
8-
polymorphic?(association) ? true : !is_active_type?(association.klass)
9-
else
10-
!polymorphic?(association) && !is_active_type?(association.klass)
11-
end
12-
7+
polymorphic?(association) ? true : !is_active_type?(association.klass)
138
rescue
149
FOREST_LOGGER.warn "Unknown association #{association.name} on class #{active_record_class.name}"
1510
false

lib/forest_liana/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ForestLiana
2-
VERSION = "8.1.0"
2+
VERSION = "9.0.0-beta.1"
33
end

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "forest-rails",
3-
"version": "8.1.0",
3+
"version": "9.0.0-beta.1",
44
"description": "The official Rails liana for Forest.",
55
"directories": {
66
"test": "test"

spec/services/forest_liana/schema_adapter_spec.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,6 @@ module ForestLiana
4040

4141
expect(removed_fields).to be_empty
4242
end
43-
44-
context 'when the polymorphic support was disabled' do
45-
it 'should not define the association' do
46-
ENV['ENABLE_SUPPORT_POLYMORPHISM'] = 'false'
47-
Bootstrapper.new(true)
48-
collection = ForestLiana.apimap.find do |object|
49-
object.name.to_s == ForestLiana.name_for(Address)
50-
end
51-
association = collection.fields.find { |field| field[:field] == 'addressable' }
52-
fields = collection.fields.select do |field|
53-
field[:field] == 'addressable_id' || field[:field] == 'addressable_type'
54-
end
55-
56-
expect(association).to be_nil
57-
expect(fields.size).to eq(2)
58-
end
59-
end
6043
end
6144

6245
context 'with an "unhandled" column types (binary, postgis geography, ...)' do

spec/spec_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
2020
RSpec.configure do |config|
2121
ENV['RAILS_ENV'] = 'test'
22-
ENV['ENABLE_SUPPORT_POLYMORPHISM'] = 'true'
2322

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

0 commit comments

Comments
 (0)