aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Sak <joe@joesak.com>2011-02-24 20:46:20 -0600
committerJoe Sak <joe@joesak.com>2011-02-24 20:46:20 -0600
commitc75cf8a00e916e795a0299a55e933c8b3cad17ac (patch)
treec13342d89988d6086558b21049401af0a6f466a5
parent56df60d80a7f5d3a26dbf25689fb118eeacca24d (diff)
downloadrefinerycms-blog-c75cf8a00e916e795a0299a55e933c8b3cad17ac.tar.gz
refinerycms-blog-c75cf8a00e916e795a0299a55e933c8b3cad17ac.tar.bz2
refinerycms-blog-c75cf8a00e916e795a0299a55e933c8b3cad17ac.zip
Blog Posts belong to an author ("user_id")
-rw-r--r--app/models/blog_post.rb2
-rw-r--r--spec/models/blog_posts_spec.rb6
2 files changed, 8 insertions, 0 deletions
diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb
index 679a21c..0dd1246 100644
--- a/app/models/blog_post.rb
+++ b/app/models/blog_post.rb
@@ -2,6 +2,8 @@ class BlogPost < ActiveRecord::Base
default_scope :order => 'published_at DESC'
+ belongs_to :author, :foreign_key => 'user_id'
+
has_many :comments, :class_name => 'BlogComment', :dependent => :destroy
has_many :categorizations
diff --git a/spec/models/blog_posts_spec.rb b/spec/models/blog_posts_spec.rb
index 9a58e3f..6b5edcb 100644
--- a/spec/models/blog_posts_spec.rb
+++ b/spec/models/blog_posts_spec.rb
@@ -46,6 +46,12 @@ describe BlogPost do
@blog_post.should respond_to(:categories)
end
end
+
+ describe "authors" do
+ it "are authored" do
+ BlogPost.new.methods.should include(:author)
+ end
+ end
describe "by_archive scope" do
it "returns all posts from specified month" do