From fddcebd878a03f579bb3c1a3265fa9cc9ef427c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=A3is=20Ozols?= Date: Wed, 3 Aug 2011 13:54:07 +0300 Subject: Make those specs green again. --- spec/models/refinery/blog_category_spec.rb | 1 - spec/models/refinery/blog_comment_spec.rb | 1 - spec/models/refinery/blog_post_spec.rb | 1 - spec/requests/blog_categories_spec.rb | 6 +----- spec/requests/blog_posts_spec.rb | 6 +----- spec/requests/manage_blog_posts_spec.rb | 11 +---------- spec/support/refinery/factories/blog_categories.rb | 3 +++ spec/support/refinery/factories/blog_comments.rb | 6 ++++++ spec/support/refinery/factories/blog_posts.rb | 7 +++++++ 9 files changed, 19 insertions(+), 23 deletions(-) create mode 100644 spec/support/refinery/factories/blog_categories.rb create mode 100644 spec/support/refinery/factories/blog_comments.rb create mode 100644 spec/support/refinery/factories/blog_posts.rb (limited to 'spec') diff --git a/spec/models/refinery/blog_category_spec.rb b/spec/models/refinery/blog_category_spec.rb index 9a6e2e4..9c92d14 100644 --- a/spec/models/refinery/blog_category_spec.rb +++ b/spec/models/refinery/blog_category_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory} module Refinery describe BlogCategory do diff --git a/spec/models/refinery/blog_comment_spec.rb b/spec/models/refinery/blog_comment_spec.rb index 455ea4a..5337958 100644 --- a/spec/models/refinery/blog_comment_spec.rb +++ b/spec/models/refinery/blog_comment_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory} module Refinery describe BlogComment do diff --git a/spec/models/refinery/blog_post_spec.rb b/spec/models/refinery/blog_post_spec.rb index deb1409..d5000f1 100644 --- a/spec/models/refinery/blog_post_spec.rb +++ b/spec/models/refinery/blog_post_spec.rb @@ -1,5 +1,4 @@ require 'spec_helper' -Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory} module Refinery describe BlogPost do diff --git a/spec/requests/blog_categories_spec.rb b/spec/requests/blog_categories_spec.rb index d0682b6..2ba5f82 100644 --- a/spec/requests/blog_categories_spec.rb +++ b/spec/requests/blog_categories_spec.rb @@ -1,11 +1,7 @@ require "spec_helper" describe "blog categories" do - before(:all) do - # destroy all existing (if any) users before creating new one - Refinery::User.destroy_all - Factory(:refinery_user) - end + login_refinery_user before(:each) do @blog_post = Factory(:blog_post, :title => "Refinery CMS blog post") diff --git a/spec/requests/blog_posts_spec.rb b/spec/requests/blog_posts_spec.rb index 284bd07..e7ab573 100644 --- a/spec/requests/blog_posts_spec.rb +++ b/spec/requests/blog_posts_spec.rb @@ -1,11 +1,7 @@ require "spec_helper" describe "blog" do - before(:all) do - # destroy all existing (if any) users before creating new one - Refinery::User.destroy_all - Factory(:refinery_user) - end + login_refinery_user it "displays the blog rss feed" do get blog_rss_feed_path diff --git a/spec/requests/manage_blog_posts_spec.rb b/spec/requests/manage_blog_posts_spec.rb index 2e44c53..724cc59 100644 --- a/spec/requests/manage_blog_posts_spec.rb +++ b/spec/requests/manage_blog_posts_spec.rb @@ -1,16 +1,7 @@ require "spec_helper" describe "manage blog posts" do - # TODO: share this with other request specs - before(:each) do - Factory(:refinery_user, :username => "refinerycms", - :password => "123456", - :password_confirmation => "123456") - visit new_refinery_user_session_url - fill_in "Login", :with => "refinerycms" - fill_in "Password", :with => "123456" - click_button "Sign in" - end + login_refinery_user let!(:blog_post) { Factory(:blog_post, :title => "Refinery CMS blog post") } diff --git a/spec/support/refinery/factories/blog_categories.rb b/spec/support/refinery/factories/blog_categories.rb new file mode 100644 index 0000000..c3701dd --- /dev/null +++ b/spec/support/refinery/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/support/refinery/factories/blog_comments.rb b/spec/support/refinery/factories/blog_comments.rb new file mode 100644 index 0000000..d738cac --- /dev/null +++ b/spec/support/refinery/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/support/refinery/factories/blog_posts.rb b/spec/support/refinery/factories/blog_posts.rb new file mode 100644 index 0000000..548636d --- /dev/null +++ b/spec/support/refinery/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 -- cgit v1.2.3