aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/models/blog_categories_spec.rb18
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