aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/blog_comment.rb3
-rw-r--r--spec/factories/blog_categories.rb4
-rw-r--r--spec/factories/blog_comments.rb10
-rw-r--r--spec/factories/blog_posts.rb4
-rw-r--r--spec/models/blog_categories_spec.rb20
-rw-r--r--spec/models/blog_comments_spec.rb20
-rw-r--r--spec/models/blog_posts_spec.rb15
7 files changed, 73 insertions, 3 deletions
diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb
index 7c6b51f..ada3f14 100644
--- a/app/models/blog_comment.rb
+++ b/app/models/blog_comment.rb
@@ -4,9 +4,6 @@ class BlogComment < ActiveRecord::Base
acts_as_indexed :fields => [:name, :email, :body]
- validates_presence_of :title
- validates_uniqueness_of :title
-
named_scope :approved, :conditions => {:approved => true}
named_scope :rejected, :conditions => {:approved => false}
end
diff --git a/spec/factories/blog_categories.rb b/spec/factories/blog_categories.rb
new file mode 100644
index 0000000..590e5b5
--- /dev/null
+++ b/spec/factories/blog_categories.rb
@@ -0,0 +1,4 @@
+Factory.define(:blog_category) do |f|
+ f.title "Shopping"
+ f.posts {|p| [p.association :post]}
+end \ No newline at end of file
diff --git a/spec/factories/blog_comments.rb b/spec/factories/blog_comments.rb
new file mode 100644
index 0000000..93beaf3
--- /dev/null
+++ b/spec/factories/blog_comments.rb
@@ -0,0 +1,10 @@
+Factory.sequence :email do |n|
+ "person#{n}@example.com"
+end
+
+Factory.define(:blog_comment) do |f|
+ f.name "Joe Commenter"
+ f.email { Factory.next(:email) }
+ f.body "Which one is the best for picking up new shoes?"
+ f.association :post
+end \ No newline at end of file
diff --git a/spec/factories/blog_posts.rb b/spec/factories/blog_posts.rb
new file mode 100644
index 0000000..6947e81
--- /dev/null
+++ b/spec/factories/blog_posts.rb
@@ -0,0 +1,4 @@
+Factory.define(:post, :class => BlogPost) do |f|
+ f.title "Top Ten Shopping Centers in Chicago"
+ f.body "These are the top ten shopping centers in Chicago. You're going to read a long blog post about them. Come to peace with it."
+end \ No newline at end of file
diff --git a/spec/models/blog_categories_spec.rb b/spec/models/blog_categories_spec.rb
new file mode 100644
index 0000000..d97172c
--- /dev/null
+++ b/spec/models/blog_categories_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe BlogCategory do
+ context "wiring up" do
+
+ before(:each) do
+ @category = Factory(:blog_category)
+ end
+
+ it "saves" do
+ @category.should_not be_nil
+ end
+
+ it "has a blog post" do
+ BlogPost.last.categories.should include(@category)
+ end
+
+ end
+
+end \ No newline at end of file
diff --git a/spec/models/blog_comments_spec.rb b/spec/models/blog_comments_spec.rb
new file mode 100644
index 0000000..145626d
--- /dev/null
+++ b/spec/models/blog_comments_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+describe BlogComment do
+
+ context "wiring up" do
+
+ before(:each) do
+ @comment = Factory(:blog_comment)
+ end
+
+ it "saves" do
+ @comment.should_not be_nil
+ end
+
+ it "has a blog post" do
+ @comment.post.should_not be_nil
+ end
+
+ end
+end \ No newline at end of file
diff --git a/spec/models/blog_posts_spec.rb b/spec/models/blog_posts_spec.rb
new file mode 100644
index 0000000..a334c73
--- /dev/null
+++ b/spec/models/blog_posts_spec.rb
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+describe BlogPost do
+ context "wiring up" do
+
+ before(:each) do
+ @post = Factory(:post)
+ end
+
+ it "saves to the database" do
+ @post.should_not be_nil
+ end
+
+ end
+end \ No newline at end of file