From 21b19db5a30fcb6db83f4ac9302cc94c6320a0db Mon Sep 17 00:00:00 2001 From: Jamie Winsor Date: Mon, 1 Aug 2011 11:27:28 -0700 Subject: refactor engine testing scenario Engine is now tested standalone by leveraging a dummy rails app Enable Guard for speedy testing Move factories to the more standard location `spec/factories/*` Update README with a Testing section Rename migrations to contain datetimestamps for their version to fix migration order issues when migrating the dummy application --- spec/factories/blog_categories.rb | 3 +++ spec/factories/blog_comments.rb | 6 ++++++ spec/factories/blog_posts.rb | 7 +++++++ spec/factories/user.rb | 27 +++++++++++++++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 spec/factories/blog_categories.rb create mode 100644 spec/factories/blog_comments.rb create mode 100644 spec/factories/blog_posts.rb create mode 100644 spec/factories/user.rb (limited to 'spec/factories') diff --git a/spec/factories/blog_categories.rb b/spec/factories/blog_categories.rb new file mode 100644 index 0000000..c3701dd --- /dev/null +++ b/spec/factories/blog_categories.rb @@ -0,0 +1,3 @@ +Factory.define :blog_category, :class => 'refinery/blog_category' do |f| + f.sequence(:title) { |n| "Shopping #{n}" } +end diff --git a/spec/factories/blog_comments.rb b/spec/factories/blog_comments.rb new file mode 100644 index 0000000..d738cac --- /dev/null +++ b/spec/factories/blog_comments.rb @@ -0,0 +1,6 @@ +Factory.define :blog_comment, :class => 'refinery/blog_comment' do |f| + f.name "Joe Commenter" + f.sequence(:email) { |n| "person#{n}@example.com" } + f.body "Which one is the best for picking up new shoes?" + f.association :post, :factory => :blog_post +end diff --git a/spec/factories/blog_posts.rb b/spec/factories/blog_posts.rb new file mode 100644 index 0000000..548636d --- /dev/null +++ b/spec/factories/blog_posts.rb @@ -0,0 +1,7 @@ +Factory.define :blog_post, :class => 'refinery/blog_post' do |f| + f.sequence(:title) { |n| "Top #{n} 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." + f.draft false + f.tag_list "chicago, shopping, fun times" + f.published_at Time.now +end diff --git a/spec/factories/user.rb b/spec/factories/user.rb new file mode 100644 index 0000000..94fe1d0 --- /dev/null +++ b/spec/factories/user.rb @@ -0,0 +1,27 @@ +require 'refinerycms/all' +require 'refinery/role' + +Factory.define :user, :class => ::Refinery::User do |u| + u.sequence(:username) { |n| "person#{n}" } + u.sequence(:email) { |n| "person#{n}@cucumber.com" } + u.password "greenandjuicy" + u.password_confirmation "greenandjuicy" +end + +Factory.define :refinery_user, :parent => :user do |u| + u.roles { [ ::Refinery::Role[:refinery] ] } + + u.after_create do |user| + ::Refinery::Plugins.registered.each_with_index do |plugin, index| + user.plugins.create(:name => plugin.name, :position => index) + end + end +end + +Factory.define :refinery_translator, :parent => :user do |u| + u.roles { [ ::Refinery::Role[:refinery], ::Refinery::Role[:translator] ] } + + u.after_create do |user| + user.plugins.create(:name => 'refinery_pages', :position => 0) + end +end -- cgit v1.2.3