blob: 904e4c87746c3ab80cef5e453d8f06d64f730045 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
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
it "requires title" do
BlogCategory.new(@attr.merge(:title => "")).should_not be_valid
end
it "won't allow duplicate titles" do
BlogCategory.create!(@attr)
BlogCategory.new(@attr).should_not be_valid
end
end
describe "blog posts association" do
it "have a posts attribute" do
BlogCategory.new.should respond_to(:posts)
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
end
end
end
|