aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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