diff options
author | Joe Sak <joe@joesak.com> | 2011-02-15 23:48:46 -0600 |
---|---|---|
committer | Joe Sak <joe@joesak.com> | 2011-02-15 23:48:46 -0600 |
commit | 3ecdeae3b004ecf2357b198551e03d39e79462b4 (patch) | |
tree | 3b5e3a6136a7412ab2b334e4214db8548134f732 /spec/models | |
parent | 652ecc4707f2e6ee019e1864179ffcaf76706ed2 (diff) | |
download | refinerycms-blog-3ecdeae3b004ecf2357b198551e03d39e79462b4.tar.gz refinerycms-blog-3ecdeae3b004ecf2357b198551e03d39e79462b4.tar.bz2 refinerycms-blog-3ecdeae3b004ecf2357b198551e03d39e79462b4.zip |
test coverage for previous changes
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/blog_categories_spec.rb | 18 |
1 files changed, 13 insertions, 5 deletions
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 |