From 3ecdeae3b004ecf2357b198551e03d39e79462b4 Mon Sep 17 00:00:00 2001 From: Joe Sak Date: Tue, 15 Feb 2011 23:48:46 -0600 Subject: test coverage for previous changes --- spec/models/blog_categories_spec.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/models/blog_categories_spec.rb b/spec/models/blog_categories_spec.rb index 904e4c8..f804dd6 100644 --- a/spec/models/blog_categories_spec.rb +++ b/spec/models/blog_categories_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory} describe BlogCategory do - describe "validations" do - before(:each) do - @attr = { :title => "RefineryCMS" } - end + before(:each) do + @attr = { :title => "RefineryCMS" } + end + describe "validations" do it "requires title" do BlogCategory.new(@attr.merge(:title => "")).should_not be_valid end @@ -18,9 +18,17 @@ describe BlogCategory do end describe "blog posts association" do - it "have a posts attribute" do + it "has a posts attribute" do BlogCategory.new.should respond_to(:posts) end + + it "returns posts by published_at date in descending order" do + @category = BlogCategory.create!(@attr) + @first_post = @category.posts.create!({ :title => "Breaking News: Joe Sak is hot stuff you guys!!", :body => "True story.", :published_at => Time.now.yesterday }) + @latest_post = @category.posts.create!({ :title => "pardnt is p. okay", :body => "For a kiwi.", :published_at => Time.now }) + @category.posts.first.should == @latest_post + end + end describe "#post_count" do -- cgit v1.2.3