klastera 1.5.5.2 → 1.5.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b7a266fca197bb8333a1bfa72e2a36b2bdec447429a1e50e95b5b89dc31fb5f
|
|
4
|
+
data.tar.gz: fd8ec6949e6fea5015fe33090ecf09a90e9815361d8e861fb42ac856e83ff111
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29ed3030a1296a3fb95073255642e9bef489fea5d136291d8d6f8e71f5b2b6f8ab040034e56c5dc66e70d09451d1880290fedfbbc904ac105ec7dc58ae4810f8
|
|
7
|
+
data.tar.gz: 7bc4e57bdac9abc5cf68be34bc64c48dbce81f6db405485e4dca1e6a8079e1d97e28630e159fb5049158a5d0f280fd000849b89e0cf6dfdc87f2a56bd4ae4e6b
|
|
@@ -54,8 +54,10 @@ module Klastera::Concerns::Clusterizable
|
|
|
54
54
|
)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
# No cuenta las filas marcadas para destruir: quitar una zona con el basurero y agregar otra en
|
|
58
|
+
# el mismo guardado deja una sola zona al final, y no debe rechazarse.
|
|
57
59
|
def has_one_cluster_entity
|
|
58
|
-
if cluster_entities.length > 1
|
|
60
|
+
if cluster_entities.reject(&:marked_for_destruction?).length > 1
|
|
59
61
|
return errors.add(:cluster_entities, I18n.t('klastera.messages.has_one_cluster_entity'))
|
|
60
62
|
end
|
|
61
63
|
end
|
data/lib/klastera/version.rb
CHANGED
|
@@ -39,5 +39,26 @@ module Klastera
|
|
|
39
39
|
assert entity.cluster_entities.any?(&:marked_for_destruction?)
|
|
40
40
|
assert entity.cluster_entities.any? { |c| c.new_record? && c.cluster_id == otro.id }
|
|
41
41
|
end
|
|
42
|
+
|
|
43
|
+
# Entidad que permite una sola zona (por defecto): quitar una y agregar otra en el mismo guardado
|
|
44
|
+
# deja una sola, y la validacion no debe contar la fila marcada para destruir.
|
|
45
|
+
test "acepta quitar una zona y agregar otra en el mismo guardado" do
|
|
46
|
+
entity, ce, = build_entity_with_cluster
|
|
47
|
+
otro = ::Cluster.create!(organization: entity.organization, name: "otro-#{SecureRandom.hex(2)}")
|
|
48
|
+
entity.assign_attributes(cluster_entities_attributes: {
|
|
49
|
+
"0" => { "id" => ce.id, "_destroy" => "1" },
|
|
50
|
+
"1" => { "cluster_id" => otro.id.to_s, "_destroy" => "false" }
|
|
51
|
+
})
|
|
52
|
+
entity.valid?
|
|
53
|
+
assert_not entity.errors[:cluster_entities].any? { |m| m == I18n.t('klastera.messages.has_one_cluster_entity') }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
test "sigue rechazando dos zonas vigentes en una entidad de una sola zona" do
|
|
57
|
+
entity, _ce, = build_entity_with_cluster
|
|
58
|
+
otro = ::Cluster.create!(organization: entity.organization, name: "otro2-#{SecureRandom.hex(2)}")
|
|
59
|
+
entity.assign_attributes(cluster_entities_attributes: { "1" => { "cluster_id" => otro.id.to_s, "_destroy" => "false" } })
|
|
60
|
+
entity.valid?
|
|
61
|
+
assert entity.errors[:cluster_entities].any?
|
|
62
|
+
end
|
|
42
63
|
end
|
|
43
64
|
end
|