libis-workflow-mongoid 2.0.18 → 2.0.19

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
  SHA1:
3
- metadata.gz: 032144e349fab139b8d8b790a2efe60182d2c6ac
4
- data.tar.gz: d2d9b8a18f3c870bb0bb57d1019747c31daf36c4
3
+ metadata.gz: 0dbf52eb295a357488cc482b75e3b3cf2ab4c2a8
4
+ data.tar.gz: aafeac6cd8e4a50a9864d422c2de51a7894ee8c4
5
5
  SHA512:
6
- metadata.gz: 67fb90f5e6fbf5eab1575db46ecb49cb37d8d90569411ba5adc203cca36866e4b78e22df87c94e34f44f92885046275149fcb6c5cb4a93a88e1ae6fca29b7d89
7
- data.tar.gz: 1b69d6fe573724a7849644cd623204e39beea57bec8d3bb83483b11944217ca68efde4aebf53e9971039c3bdd151b2518cfdb87657ba4f028c264e6b66433308
6
+ metadata.gz: 092ae4d3b766b028096ad93c2b3ee85865dd433675d943338aa979e524fbb7b4da3cca8b535c782915524b747067eea995c6b39ede4dd069a28ac0668dd2289f
7
+ data.tar.gz: 28b502a5aaa9cb58f4781ccecfc174b33020ff2393b58c7ec69701aa9883ee4bf336b4f2da9d8d638946208666598bd33b63fd6716bf7ac3bcd38db1c2a61baf
@@ -52,11 +52,6 @@ module Libis
52
52
 
53
53
  end
54
54
 
55
- def dup
56
- new_obj = self.class.new
57
- new_obj.copy_attributes(self)
58
- end
59
-
60
55
  def to_hash
61
56
  result = self.attributes.reject { |k, v| v.blank? || volatile_attributes.include?(k) }
62
57
  result = result.to_yaml.gsub(/!ruby\/hash:BSON::Document/, '')
@@ -46,6 +46,8 @@ module Libis
46
46
  def run(action = :run)
47
47
  self.tasks = []
48
48
  super action
49
+ self.reload
50
+ self.reload_relations
49
51
  close_logger
50
52
  end
51
53
 
@@ -1,7 +1,7 @@
1
1
  module Libis
2
2
  module Workflow
3
3
  module Mongoid
4
- VERSION = '2.0.18' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
4
+ VERSION = '2.0.19' unless const_defined? :VERSION # the guard is against a redefinition warning that happens on Travis
5
5
  end
6
6
  end
7
7
  end
@@ -13,7 +13,6 @@ module Libis
13
13
 
14
14
  field :options, type: Hash, default: -> { Hash.new }
15
15
  field :properties, type: Hash, default: -> { Hash.new }
16
- field :summary, type: Hash, default: -> { Hash.new }
17
16
  field :status_log, type: Array, default: -> { Array.new }
18
17
 
19
18
  index({_id: 1, _type: 1}, {unique: true, name: 'by_id'})
@@ -26,11 +25,20 @@ module Libis
26
25
  index({parent_id: 1, parent_type: 1, c_at: 1}, {name: 'by_parent'})
27
26
 
28
27
  def add_item(item)
28
+ raise Libis::WorkflowError, 'Trying to add item already linked to another item' unless item.parent.nil?
29
+ super(item)
30
+ end
31
+
32
+ def move_item(item)
33
+ new_item = item.dup
34
+ yield new_item, item if block_given?
35
+ new_item.parent = nil
36
+ item.items.each { |i| new_item.move_item(i) }
37
+ self.add_item(new_item)
29
38
  if item.parent
30
- item.parent.delete(item)
31
- item.parent.save!
39
+ item.parent.items.delete(item)
32
40
  end
33
- super
41
+ new_item
34
42
  end
35
43
 
36
44
  def get_items
@@ -213,7 +213,7 @@ STR
213
213
  it 'move item in relation' do
214
214
  item = run.items.first
215
215
  sub_item = item.items.first
216
- run.add_item(sub_item)
216
+ run.move_item(sub_item)
217
217
  expect(run.size).to eq 2
218
218
  expect(item.size).to eq 3
219
219
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-workflow-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.18
4
+ version: 2.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser