require File.dirname(__FILE__) + '/../spec_helper' describe Publication do describe 'content types' do it 'detects articles' do Publication.new(:content_type => 'Articles').has_articles?.should be_true end it 'detects faqs' do Publication.new(:content_type => 'FAQs').has_faqs?.should be_true end it 'detects terms' do Publication.new(:content_type => 'Terms and Definitions').has_terms?.should be_true end it 'detects documents' do Publication.new(:content_type => 'Documents').has_documents?.should be_true end it 'returns a label for headlines appropriate for articles' do Publication.new(:content_type => 'Articles').headline_label.should == 'Headline' end it 'returns a label for headlines appropriate for documents' do Publication.new(:content_type => 'Documents').headline_label.should == 'Title' end it 'returns a label for headlines appropriate for faqs' do Publication.new(:content_type => 'FAQs').headline_label.should == 'Question' end it 'returns a label for headlines appropriate for terms' do Publication.new(:content_type => 'Terms and Definitions').headline_label.should == 'Term' end it 'returns a label for content appropriate for articles' do Publication.new(:content_type => 'Articles').content_label.should == 'Content' end it 'returns a label for content appropriate for documents' do Publication.new(:content_type => 'Documents').content_label.should == 'Document' end it 'returns a label for content appropriate for faqs' do Publication.new(:content_type => 'FAQs').content_label.should == 'Answer' end it 'returns a label for content appropriate for terms' do Publication.new(:content_type => 'Terms and Definitions').content_label.should == 'Definition' end end describe 'slug' do it 'returns an SEO-friendly URL' do publication = Publication.new( :name => 'FAQs', :desired_slug => 'somewhat-dense' ) publication.make_slug publication.humanize_path.should == '/somewhat-dense/' end it 'is generated based on the desired_slug' do publication = Publication.new( :name => 'FAQs', :desired_slug => 'unfortunate beginnings' ) publication.make_slug.should == 'unfortunate-beginnings' end it 'is generated based on the name' do publication = Publication.new(:name => 'Flood Brothers') publication.make_slug.should == 'flood-brothers' end it 'truncates extra hyphens' do publication = Publication.new(:name => 'Mario!! Brothers') publication.make_slug.should == 'mario-brothers' end it 'truncates trailing hyphens' do publication = Publication.new(:name => 'Blues Brothers?') publication.make_slug.should == 'blues-brothers' end end it 'returns its feed URL' do Publication.create(:name => 'Blues News', :desired_slug => 'blues-news').rss_feed_url.should == '/blues-news/feed' end end