diff options
author | Philip Arndt <parndt@gmail.com> | 2011-11-09 22:19:07 +1300 |
---|---|---|
committer | Philip Arndt <parndt@gmail.com> | 2011-11-09 22:19:07 +1300 |
commit | 36c005ecd112b76d3c9c2d7092f22d6e06755d73 (patch) | |
tree | 23e37055e6c6aa79a9c5285387052acdc708ba30 /spec/models/refinery/blog/category_spec.rb | |
parent | d18364d359359fa6564ad187d7303f8c167154cd (diff) | |
download | refinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.tar.gz refinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.tar.bz2 refinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.zip |
Refactored everything (models, helpers) into proper namespace of Refinery::Blog. Requires refinery commit 25162b585b9c4023d39fd1a9796140bfa4ecb909
Diffstat (limited to 'spec/models/refinery/blog/category_spec.rb')
-rw-r--r-- | spec/models/refinery/blog/category_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/models/refinery/blog/category_spec.rb b/spec/models/refinery/blog/category_spec.rb new file mode 100644 index 0000000..9c4a7d3 --- /dev/null +++ b/spec/models/refinery/blog/category_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +module Refinery + module Blog + describe Category do + let(:category) { FactoryGirl.create(:blog_category) } + + describe "validations" do + it "requires title" do + FactoryGirl.build(:blog_category, :title => "").should_not be_valid + end + + it "won't allow duplicate titles" do + FactoryGirl.build(:blog_category, :title => category.title).should_not be_valid + end + end + + describe "blog posts association" do + it "has a posts attribute" do + category.should respond_to(:posts) + end + + it "returns posts by published_at date in descending order" do + 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 + end + + end + + describe "#post_count" do + it "returns post count in category" do + 2.times do + category.posts << FactoryGirl.create(:blog_post) + end + category.post_count.should == 2 + end + end + end + end +end
\ No newline at end of file |