File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ def find_all_by_generation(generation_level)
112
112
113
113
# Find the node whose +ancestry_path+ is +path+
114
114
def find_by_path ( path , attributes = { } , parent_id = nil )
115
+ return nil if path . blank?
115
116
path = _ct . build_ancestry_attr_path ( path , attributes )
116
117
if path . size > _ct . max_join_tables
117
118
return _ct . find_by_large_path ( path , attributes , parent_id )
Original file line number Diff line number Diff line change 72
72
expect ( tag_class . leaves ) . to eq ( [ @tag ] )
73
73
end
74
74
75
+ it 'should not be found by passing find_by_path an array of blank strings' do
76
+ expect ( tag_class . find_by_path ( [ '' ] ) ) . to be_nil
77
+ end
78
+
79
+ it 'should not be found by passing find_by_path an empty array' do
80
+ expect ( tag_class . find_by_path ( [ ] ) ) . to be_nil
81
+ end
82
+
83
+ it 'should not be found by passing find_by_path nil' do
84
+ expect ( tag_class . find_by_path ( nil ) ) . to be_nil
85
+ end
86
+
87
+ it 'should not be found by passing find_by_path an empty string' do
88
+ expect ( tag_class . find_by_path ( '' ) ) . to be_nil
89
+ end
90
+
91
+ it 'should not be found by passing find_by_path an array of nils' do
92
+ expect ( tag_class . find_by_path ( [ nil ] ) ) . to be_nil
93
+ end
94
+
95
+ it 'should not be found by passing find_by_path an array with an additional blank string' do
96
+ expect ( tag_class . find_by_path ( [ @tag . name , '' ] ) ) . to be_nil
97
+ end
98
+
99
+ it 'should not be found by passing find_by_path an array with an additional nil' do
100
+ expect ( tag_class . find_by_path ( [ @tag . name , nil ] ) ) . to be_nil
101
+ end
102
+
103
+ it 'should be found by passing find_by_path an array with its name' do
104
+ expect ( tag_class . find_by_path ( [ @tag . name ] ) ) . to eq @tag
105
+ end
106
+
107
+ it 'should be found by passing find_by_path its name' do
108
+ expect ( tag_class . find_by_path ( @tag . name ) ) . to eq @tag
109
+ end
110
+
75
111
context 'with child' do
76
112
before do
77
113
@child = tag_class . create! ( name : 'tag 2' )
You can’t perform that action at this time.
0 commit comments