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: 7f593dccae852483eb2b18e8254ee94c1e44804bcb59780cd26a8987ef383443
4
- data.tar.gz: f28976b48568045dfe38b3feb2915de5e87b079279b0a31e481f48741fdbd0a0
3
+ metadata.gz: 1b7a266fca197bb8333a1bfa72e2a36b2bdec447429a1e50e95b5b89dc31fb5f
4
+ data.tar.gz: fd8ec6949e6fea5015fe33090ecf09a90e9815361d8e861fb42ac856e83ff111
5
5
  SHA512:
6
- metadata.gz: a2b1d549df310a5bf569316f5e9de36f66c9be7b5d052108d85aa1345f6d05527a536494ca39ea37e2f19f663e8973dd5d62a107ea101168f63d5a2ace6566b4
7
- data.tar.gz: 1353ffb7147a62d4e35cf28a0ccafa2e976460e96db0dc566cc48ed1db0e16e2ea315d65fcd8b12c2642cea76f53e3a2b2a8c10d48000f08efb93f72f4f9c749
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
@@ -1,3 +1,3 @@
1
1
  module Klastera
2
- VERSION = "1.5.5.2"
2
+ VERSION = "1.5.5.3"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klastera
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5.2
4
+ version: 1.5.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gino Barahona