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 +4 -4
- data/Gemfile.lock +1 -1
- data/db/factories.rb +2 -2
- data/lib/avo/base_resource.rb +18 -12
- data/lib/avo/fields/belongs_to_field.rb +9 -0
- data/lib/avo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d1b3e02ee566af1fcf8ac642f0b59693fc9ca60840f5a57e46c0e57df32831c9
|
4
|
+
data.tar.gz: 621dc29f10b4693db5e09531fb7cd8cd591666e0be8d098d3927a48e0e2cb0dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 325009723e404b72ab8ff8cde8c0491ecf4c520b075b7731ee837c56998f1c45d57b50805ebbce1358dfff3b9f7e6b8a53d3ada14a9fe365523a6a3f077dbf29
|
7
|
+
data.tar.gz: de4a2bcb927f0d1eb4053185e3683c0d44d06c0fce7848f3740edaee52cdabfc3c6a5cde067b6ad9f8506013ea8eb214639073e19793cc9fc4e51b72bbdcaf38
|
data/Gemfile.lock
CHANGED
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
|
data/lib/avo/base_resource.rb
CHANGED
@@ -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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
-
|
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