File tree Expand file tree Collapse file tree 4 files changed +1
-26
lines changed
app/services/forest_liana Expand file tree Collapse file tree 4 files changed +1
-26
lines changed Original file line number Diff line number Diff 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 ) ,
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1919# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
2020RSpec . 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
You can’t perform that action at this time.
0 commit comments