Permalink
Browse files

Merge remote-tracking branch 'Nethemba/published_at_author_validation'

  • Loading branch information...
2 parents 800d478 + 4cfd546 commit 8eeb044650e580dc602bcd8e006092b9cf6c363b @parndt parndt committed Sep 5, 2012
Showing with 12 additions and 2 deletions.
  1. +1 −0 app/models/refinery/blog/post.rb
  2. +1 −0 spec/factories/blog_posts.rb
  3. +10 −2 spec/models/refinery/blog/category_spec.rb
@@ -26,6 +26,7 @@ class Post < ActiveRecord::Base
validates :title, :presence => true, :uniqueness => true
validates :body, :presence => true
+ validates :published_at, :author, :presence => true
validates :source_url, :url => { :if => 'Refinery::Blog.validate_source_url',
:update => true,
@@ -5,6 +5,7 @@
draft false
tag_list "chicago, shopping, fun times"
published_at Time.now
+ author { Factory(:refinery_user) }
factory :blog_post_draft do
draft true
@@ -4,6 +4,7 @@ module Refinery
module Blog
describe Category do
let(:category) { FactoryGirl.create(:blog_category) }
+ let(:refinery_user) { FactoryGirl.create(:refinery_user) }
describe "validations" do
it "requires title" do
@@ -21,8 +22,15 @@ module Blog
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 })
+ first_post = category.posts.create!({ :title => "Breaking News: Joe Sak is hot stuff you guys!!",
+ :body => "True story.",
+ :published_at => Time.now.yesterday,
+ :author => refinery_user })
+
+ latest_post = category.posts.create!({ :title => "parndt is p. okay",
+ :body => "For a Kiwi.",
+ :published_at => Time.now,
+ :author => refinery_user })
category.posts.first.should == latest_post
end

0 comments on commit 8eeb044

Please sign in to comment.