avo 1.22.1 → 1.22.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '04783e6660bd1ebada3544318b2f48082e3e43eb4bc7ee3df2986a9951d04090'
4
- data.tar.gz: 6e997ae6e0dbb4eaa7828b669b73efd811370c0cfb5213d405f15bdd41bb9240
3
+ metadata.gz: d1b3e02ee566af1fcf8ac642f0b59693fc9ca60840f5a57e46c0e57df32831c9
4
+ data.tar.gz: 621dc29f10b4693db5e09531fb7cd8cd591666e0be8d098d3927a48e0e2cb0dd
5
5
  SHA512:
6
- metadata.gz: d61380b2f4c216d4ff1bd4e3e2f882500ba5e09835712d0661e8a79afd505f4b308ab7f30b41fcd95750e061003ca79a25b826e94eb9d007ba786923ce18740c
7
- data.tar.gz: 383afdfdc9eaaa92e00b6b91895a1b14ebff2d1655e3c605e39838e6640e9ff9f74eebef1f0322d2eedd402b11060b2b02d4d933a7823edbd7343f47e3a5cd35
6
+ metadata.gz: 325009723e404b72ab8ff8cde8c0491ecf4c520b075b7731ee837c56998f1c45d57b50805ebbce1358dfff3b9f7e6b8a53d3ada14a9fe365523a6a3f077dbf29
7
+ data.tar.gz: de4a2bcb927f0d1eb4053185e3683c0d44d06c0fce7848f3740edaee52cdabfc3c6a5cde067b6ad9f8506013ea8eb214639073e19793cc9fc4e51b72bbdcaf38
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (1.22.1)
4
+ avo (1.22.2)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
data/db/factories.rb CHANGED
@@ -42,11 +42,11 @@ FactoryBot.define do
42
42
  end
43
43
 
44
44
  factory :comment do
45
- body { Faker::Lorem.paragraphs(number: rand(4...10)) }
45
+ body { Faker::Lorem.paragraphs(number: rand(4...10)).join(' ') }
46
46
  end
47
47
 
48
48
  factory :review do
49
- body { Faker::Lorem.paragraphs(number: rand(4...10)) }
49
+ body { Faker::Lorem.paragraphs(number: rand(4...10)).join(' ') }
50
50
  end
51
51
 
52
52
  factory :person do
@@ -127,23 +127,29 @@ module Avo
127
127
  field.visible?
128
128
  end
129
129
  .select do |field|
130
+ is_valid = true
131
+
130
132
  # Strip out the reflection field in index queries with a parent association.
131
133
  if reflection.present?
132
- if reflection.options.present? &&
133
- field.respond_to?(:polymorphic_as) &&
134
- field.polymorphic_as.to_s == reflection.options[:as].to_s
135
- next
136
- end
137
-
138
- if field.respond_to?(:foreign_key) &&
139
- reflection.respond_to?(:foreign_key) &&
140
- reflection.foreign_key != field.foreign_key &&
141
- @params[:resource_name] == field.resource.model_key
142
- next
134
+ # regular non-polymorphic association
135
+ # we're matching the reflection inverse_of foriegn key with the field's foreign_key
136
+ if field.is_a?(Avo::Fields::BelongsToField)
137
+ if field.respond_to?(:foreign_key) &&
138
+ reflection.inverse_of.foreign_key == field.foreign_key
139
+ is_valid = false
140
+ end
141
+
142
+ # polymorphic association
143
+ if field.respond_to?(:foreign_key) &&
144
+ field.is_polymorphic? &&
145
+ reflection.respond_to?(:polymorphic?) &&
146
+ reflection.inverse_of.foreign_key == field.reflection.foreign_key
147
+ is_valid = false
148
+ end
143
149
  end
144
150
  end
145
151
 
146
- true
152
+ is_valid
147
153
  end
148
154
 
149
155
  if panel.present?
@@ -136,6 +136,8 @@ module Avo
136
136
 
137
137
  def is_polymorphic?
138
138
  polymorphic_as.present?
139
+ rescue
140
+ false
139
141
  end
140
142
 
141
143
  def foreign_key
@@ -154,6 +156,13 @@ module Avo
154
156
  nil
155
157
  end
156
158
 
159
+ # Get the model reflection instance
160
+ def reflection
161
+ reflection_for_key(id)
162
+ rescue
163
+ nil
164
+ end
165
+
157
166
  def relation_model_class
158
167
  @resource.model_class
159
168
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "1.22.1"
2
+ VERSION = "1.22.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.1
4
+ version: 1.22.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin