Sha256: d6d7d2e0e824197d1d033cc28d6225ef170fc7aedb155bc2ee060aae68c8642f
Contents?: true
Size: 1.11 KB
Versions: 5
Compression:
Stored size: 1.11 KB
Contents
require 'rails_helper' module Portfolio RSpec.describe SiteItem, type: :model do context 'with a class that inherits from SiteItem' do before do class SiteItemChild < SiteItem; end end let!(:child) { SiteItemChild.create title: 'Test child', site: create(:site) } it 'automatically assigns a type based in the child class' do expect(child).to be_valid expect(child.type).to eq('Portfolio::SiteItemChild') end it 'filters based on the type' do item = create(:site_item) expect(item).to be_valid expect(SiteItemChild.count).to be 1 expect(SiteItemChild.first.type).to eq('Portfolio::SiteItemChild') end it 'should return its resource name for usage in paths construction' do expect(SiteItemChild.resource_name).to eq 'site_item_child' end it 'should return its human name for usage in views' do expect(SiteItemChild.human_name).to eq 'child' end it 'returns the list of subclases' do expect(SiteItem.subclasses).to eq [SiteProject] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems