Guest User

Untitled

a guest
Jan 7th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. class Node < ApplicationRecord
  2. belongs_to :parent, :class_name => "Node"
  3. has_many :children, :class_name => "Node", :foreign_key => "parent_id"
  4.  
  5. validates :name, presence: true
  6. end
  7.  
  8. it 'created successfully' do
  9. node = Node(name:"test1", parent_id:1).save
  10. expect(node).to be_truthy
  11. end
  12.  
  13. it 'has root category' do
  14. expect(Node.where('parent_id = id').count).to eq(1)
  15. end
Add Comment
Please, Sign In to add comment