typed_dag 2.0.0 → 2.0.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
  SHA1:
3
- metadata.gz: a7e31c0c6a123f535ad41b59c8aabaac96129a70
4
- data.tar.gz: 78ee741a3bf16ea7014f2cf69a8a3f5903c9fab1
3
+ metadata.gz: 68e6894733312f8d62be51c1f249a767890402cc
4
+ data.tar.gz: b778e272530a806ec819024ce2a23597cfe1c0b6
5
5
  SHA512:
6
- metadata.gz: 7941c61304bd469a8bff392405f09719f7246e6817e991cf835f7435d0570d8b832b37edaf87186ab359b57a20a0f5a5e949ffb65f87149b6745b4ab21be3b3c
7
- data.tar.gz: 206c14332f5e58353063cf45ac0e8d279f632f017a14bbd1c96a0a2f4ab8e9cf3424f33cc1b2378c13eaf9363259caf2a8b26e920f37ec4a7eea412e24f2e383
6
+ metadata.gz: 4c9827091a6768cc1e449f25f5cb167bae7fc8d80039adaf7b4552e79b8c63d3a9d20db5761222efcdb0b547a72d2d77a2c505afc9d9a26f184c78702fda230c
7
+ data.tar.gz: 73c1a4980d1c5e58ab6b09470f5bdac08241e6fe6bea9f9ffb9a2ac617b28d6130845b8bede5757f7413e08148f689b308a1ec8c047fae527b746f7973b6385e
@@ -14,8 +14,19 @@ module TypedDag::Edge
14
14
  private
15
15
 
16
16
  def no_circular_dependency
17
- if self.class.of_from_and_to(send(_dag_options.to_column),
18
- send(_dag_options.from_column)).exists?
17
+ # Disregard self in case one wants to inverse the edge's direction.
18
+ # If the edge has not been persisted yet, AR will turn
19
+ # where.not(id: id)
20
+ # into
21
+ # WHERE id IS NOT NULL
22
+ # which is ok.
23
+ if self
24
+ .class
25
+ .of_from_and_to(send(_dag_options.to_column),
26
+ send(_dag_options.from_column))
27
+ .where
28
+ .not(id: id)
29
+ .exists?
19
30
  errors.add :base, :'typed_dag.circular_dependency'
20
31
  end
21
32
  end
@@ -1,3 +1,3 @@
1
1
  module TypedDag
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'.freeze
3
3
  end
Binary file
@@ -134,6 +134,19 @@ RSpec.describe 'Edge' do
134
134
  end
135
135
  end
136
136
 
137
+ context 'with the relation switching directions' do
138
+ before do
139
+ relation.save
140
+ relation.from = to
141
+ relation.to = from
142
+ end
143
+
144
+ it 'is valid' do
145
+ expect(relation)
146
+ .to be_valid
147
+ end
148
+ end
149
+
137
150
  context 'with A - B - C and trying to connect C and A' do
138
151
  let(:a) { Message.create text: 'A' }
139
152
  let(:b) { Message.create text: 'B' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typed_dag
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenProject GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-08 00:00:00.000000000 Z
11
+ date: 2018-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails