Skip to content

Commit

Permalink
removal of nil before remove_children
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswnl committed Mar 2, 2018
1 parent fb9e78a commit d456dec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/mixins/relationship_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ def remove_parent(parent)
end

def remove_children(*child_objs)
child_objs = child_objs.flatten
child_objs = child_objs.flatten.compact
return child_objs if child_objs.empty?

child_rels = self.child_rels
Expand Down
6 changes: 6 additions & 0 deletions spec/models/mixins/relationship_mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
# host with no tree
let(:host) { FactoryGirl.create(:host) }

describe "#remove_children" do
it "handles [nil]" do
expect { vms[3].remove_children(nil) }.to_not raise_error
end
end

context "tree with relationship" do
it "#with_relationship_type and #relationship_type" do
expect(vms[0].relationship_type).not_to eq(test_rel_type)
Expand Down

0 comments on commit d456dec

Please sign in to comment.