resque_jobs_tree 0.4.1 → 0.4.2

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.
@@ -42,12 +42,10 @@ class ResqueJobsTree::Definitions::Node < ResqueJobsTree::Definitions
42
42
  root? ? [] : (parent.node_childs - [self])
43
43
  end
44
44
 
45
- def find _name
46
- if name == _name.to_s
47
- self
48
- else
49
- node_childs.inject(nil){|result,node| result ||= node.find _name }
50
- end
45
+ def find _name, first=true
46
+ return self if name == _name.to_s
47
+ node_childs.inject(nil){|result,node| result ||= node.find(_name, false) } ||
48
+ (first && raise(ResqueJobsTree::TreeDefinitionInvalid, "Cannot find node #{_name} in #{tree.name}"))
51
49
  end
52
50
 
53
51
  def validate!
@@ -1,3 +1,3 @@
1
1
  module ResqueJobsTree
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -96,4 +96,19 @@ class DefinitionsTest < MiniTest::Unit::TestCase
96
96
  assert_equal options, @tree.find(:node2).options
97
97
  end
98
98
 
99
+ def test_find
100
+ tree_definition = ResqueJobsTree::Factory.create :tree1 do
101
+ root :job1 do
102
+ perform {}
103
+ childs { [:job4] }
104
+ node :job2 do
105
+ perform {}
106
+ end
107
+ end
108
+ end
109
+ assert_raises ResqueJobsTree::TreeDefinitionInvalid do
110
+ tree_definition.spawn([]).launch
111
+ end
112
+ end
113
+
99
114
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_jobs_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: