aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/blog_categories_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/blog_categories_spec.rb')
-rw-r--r--spec/models/blog_categories_spec.rb24
1 files changed, 12 insertions, 12 deletions
diff --git a/spec/models/blog_categories_spec.rb b/spec/models/blog_categories_spec.rb
index 53bc345..8ddec46 100644
--- a/spec/models/blog_categories_spec.rb
+++ b/spec/models/blog_categories_spec.rb
@@ -3,39 +3,39 @@ Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each
describe BlogCategory do
before(:each) do
- @attr = { :title => "RefineryCMS" }
+ @blog_category = Factory(:blog_category)
end
describe "validations" do
it "requires title" do
- BlogCategory.new(@attr.merge(:title => "")).should_not be_valid
+ Factory.build(:blog_category, :title => "").should_not be_valid
end
it "won't allow duplicate titles" do
- BlogCategory.create!(@attr)
- BlogCategory.new(@attr).should_not be_valid
+ Factory.build(:blog_category, :title => @blog_category.title).should_not be_valid
end
end
describe "blog posts association" do
it "has a posts attribute" do
- BlogCategory.new.should respond_to(:posts)
+ @blog_category.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 => "parndt is p. okay", :body => "For a kiwi.", :published_at => Time.now })
- @category.posts.first.should == @latest_post
+ first_post = @blog_category.posts.create!({ :title => "Breaking News: Joe Sak is hot stuff you guys!!", :body => "True story.", :published_at => Time.now.yesterday })
+ latest_post = @blog_category.posts.create!({ :title => "parndt is p. okay", :body => "For a kiwi.", :published_at => Time.now })
+
+ @blog_category.posts.first.should == latest_post
end
end
describe "#post_count" do
it "returns post count in category" do
- Factory(:post, :categories => [Factory(:blog_category)])
- Factory(:post, :categories => [Factory(:blog_category)])
- BlogCategory.first.post_count.should == 2
+ 2.times do
+ @blog_category.posts << Factory(:post)
+ end
+ @blog_category.post_count.should == 2
end
end
end