shoulda-matchers 4.5.0 → 4.5.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a62f760706ab97ba90edd181dbdf330ce6e8203c8ec3ec37a258022e202a53a6
|
4
|
+
data.tar.gz: 68f333b57646a8a437b73ff43f617efa9231674fb92f68de73365eb1408932f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea01851ee8521ff08ab6b1caea192c161e34286e5fd361cbceb6b84404813fa952acb73c70481c3140b2c5116ffce8bb386bf1feea70754f827a3918292b1bfb
|
7
|
+
data.tar.gz: 286ac5e78d534651889c5e3ed3843e1afa50d0fd77ed896c4ca3cf3622596cb7e1f47d2ae053e38100ce443dbfd80fbf1a8d099ecdfbbcf8d70912dbe3f42ad3
|
@@ -1397,7 +1397,7 @@ module Shoulda
|
|
1397
1397
|
if options.key?(:foreign_key) && !foreign_key_correct?
|
1398
1398
|
@missing = foreign_key_failure_message(klass, options[:foreign_key])
|
1399
1399
|
false
|
1400
|
-
elsif !
|
1400
|
+
elsif !has_column?(klass, foreign_key)
|
1401
1401
|
@missing = foreign_key_failure_message(klass, foreign_key)
|
1402
1402
|
false
|
1403
1403
|
else
|
@@ -1405,6 +1405,15 @@ module Shoulda
|
|
1405
1405
|
end
|
1406
1406
|
end
|
1407
1407
|
|
1408
|
+
def has_column?(klass, column)
|
1409
|
+
case column
|
1410
|
+
when Array
|
1411
|
+
column.all? { |c| has_column?(klass, c) }
|
1412
|
+
else
|
1413
|
+
column_names_for(klass).include?(column)
|
1414
|
+
end
|
1415
|
+
end
|
1416
|
+
|
1408
1417
|
def foreign_key_correct?
|
1409
1418
|
option_verifier.correct_for_string?(
|
1410
1419
|
:foreign_key,
|
@@ -1434,12 +1443,18 @@ module Shoulda
|
|
1434
1443
|
end
|
1435
1444
|
|
1436
1445
|
def foreign_key
|
1437
|
-
if foreign_key_reflection
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1446
|
+
key = if foreign_key_reflection
|
1447
|
+
if foreign_key_reflection.respond_to?(:foreign_key)
|
1448
|
+
foreign_key_reflection.foreign_key
|
1449
|
+
else
|
1450
|
+
foreign_key_reflection.primary_key_name
|
1451
|
+
end
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
if key.is_a?(Array)
|
1455
|
+
key.map(&:to_s)
|
1456
|
+
else
|
1457
|
+
key.to_s
|
1443
1458
|
end
|
1444
1459
|
end
|
1445
1460
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoulda-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.5.
|
4
|
+
version: 4.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tammer Saleh
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2021-01-
|
17
|
+
date: 2021-01-22 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activesupport
|