Sha256: 98b0eae5c40a4358f41c1f51159001afb1a6312e62a8c0952703237b9521ede0
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require 'rails_helper' module Anubis RSpec.describe GroupMenu, type: :model do before(:all) do @system = create :system, ident: 'test' @group = create :group, ident: 'test', system: @system @menu1 = create :menu, mode: 'menu1', action: 'data' @menu2 = create :menu, mode: 'menu2', action: 'data', menu: @menu1 @menu3 = create :menu, mode: 'menu3', action: 'data', menu: @menu2 create :system_menu, system: @system, menu: @menu3 end it "can create" do expect(build_stubbed(:group_menu, group: @group, menu: @menu1)).to be_valid end it "can create tree" do expect(build_stubbed(:group_menu, group: @group, menu: @menu3)).to be_valid end it "check created tree" do create :group_menu, group: @group, menu: @menu3 expect(Anubis::GroupMenu.where(group: @group).count(:id)).to eq 3 end it "can destroy" do data = create :group_menu, group: @group, menu: @menu1 data.destroy expect(data.destroyed?).to eq true end it "can destroy tree" do create :group_menu, group: @group, menu: @menu3 Anubis::GroupMenu.where(group: @group, menu: @menu1).first.destroy expect(Anubis::GroupMenu.where(group: @group).count(:id)).to eq 0 end after(:all) do Anubis::SystemMenu.where(system: @system, menu: @menu1).first.destroy @menu3.destroy @menu2.destroy @menu1.destroy Anubis::Group.where(system_id: @system.id).each do |item| item.destroy end @system.destroy end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
anoubis-1.0.0 | spec/models/anoubis/group_menu_spec.rb |