diff options
author | Joe Sak <joe@joesak.com> | 2011-04-22 15:05:55 -0500 |
---|---|---|
committer | Joe Sak <joe@joesak.com> | 2011-04-22 15:05:55 -0500 |
commit | fe3bb08fcf7455bf446734e380e68bfc410886c3 (patch) | |
tree | 7928c3a13ed728accf8a50bbce0614d047ac25b2 /spec/models/blog_categories_spec.rb | |
parent | b0d7a687b7dcf2bc70fe83b8b4b191f8861d3c0f (diff) | |
download | refinerycms-blog-fe3bb08fcf7455bf446734e380e68bfc410886c3.tar.gz refinerycms-blog-fe3bb08fcf7455bf446734e380e68bfc410886c3.tar.bz2 refinerycms-blog-fe3bb08fcf7455bf446734e380e68bfc410886c3.zip |
tests were failing all over the place
Diffstat (limited to 'spec/models/blog_categories_spec.rb')
-rw-r--r-- | spec/models/blog_categories_spec.rb | 24 |
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 |