aboutsummaryrefslogtreecommitdiffstats
path: root/spec/factories
diff options
context:
space:
mode:
authorJamie Winsor <jamie@enmasse.com>2011-09-04 03:20:51 -0700
committerJamie Winsor <jamie@enmasse.com>2011-09-04 14:35:03 -0700
commit7903bdfed26f085f6d07d104ac458bc4319b1e32 (patch)
treefd950e2c1d1d234e0e6a590d24296a4a396798a3 /spec/factories
parent40be4f71ee425ee55ecedea96ff2b0dc510d71db (diff)
downloadrefinerycms-blog-7903bdfed26f085f6d07d104ac458bc4319b1e32.tar.gz
refinerycms-blog-7903bdfed26f085f6d07d104ac458bc4319b1e32.tar.bz2
refinerycms-blog-7903bdfed26f085f6d07d104ac458bc4319b1e32.zip
refactor factories and add #show tests for posts controller
Do not want to cache classes, but do want to reload models after factory girl: http://groups.google.com/group/factory_girl/browse_thread/thread/daa24556d90c31fc http://stackoverflow.com/questions/5145165/associationtypemismatch-and-factorygirl rails_autolink was removed from Rails 3.1 and abstracted to an external gem fix display author name and post time on comment show fix namespace for thanking and moderated flash notices
Diffstat (limited to 'spec/factories')
-rw-r--r--spec/factories/blog_categories.rb5
-rw-r--r--spec/factories/blog_comments.rb19
-rw-r--r--spec/factories/blog_posts.rb9
3 files changed, 33 insertions, 0 deletions
diff --git a/spec/factories/blog_categories.rb b/spec/factories/blog_categories.rb
new file mode 100644
index 0000000..9ee4f16
--- /dev/null
+++ b/spec/factories/blog_categories.rb
@@ -0,0 +1,5 @@
+FactoryGirl.define do
+ factory :blog_category, :class => Refinery::BlogCategory do
+ sequence(:title) { |n| "Shopping #{n}" }
+ end
+end
diff --git a/spec/factories/blog_comments.rb b/spec/factories/blog_comments.rb
new file mode 100644
index 0000000..9818c07
--- /dev/null
+++ b/spec/factories/blog_comments.rb
@@ -0,0 +1,19 @@
+FactoryGirl.define do
+ factory :blog_comment, :class => Refinery::BlogComment do
+ name "Joe Commenter"
+ sequence(:email) { |n| "person#{n}@example.com" }
+ body "Which one is the best for picking up new shoes?"
+ association :post, :factory => :blog_post
+
+ trait :approved do
+ state 'approved'
+ end
+
+ trait :rejected do
+ state 'rejected'
+ end
+
+ factory :approved_comment, :traits => [:approved]
+ factory :rejected_comment, :traits => [:rejected]
+ end
+end
diff --git a/spec/factories/blog_posts.rb b/spec/factories/blog_posts.rb
new file mode 100644
index 0000000..0b8b888
--- /dev/null
+++ b/spec/factories/blog_posts.rb
@@ -0,0 +1,9 @@
+FactoryGirl.define do
+ factory :blog_post, :class => Refinery::BlogPost do
+ sequence(:title) { |n| "Top #{n} Shopping Centers in Chicago" }
+ 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."
+ draft false
+ tag_list "chicago, shopping, fun times"
+ published_at Time.now
+ end
+end