aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2011-09-03 11:44:21 +1200
committerPhilip Arndt <parndt@gmail.com>2011-09-03 11:44:21 +1200
commit0497261f39f351ab5be8862646c35669ee58579d (patch)
treee4dd365b0bdd147a0e05653cd2b16ec5cc358879 /spec
parent67cc6b451205e04ef80754f711f9fdb9e42d3660 (diff)
downloadrefinerycms-blog-0497261f39f351ab5be8862646c35669ee58579d.tar.gz
refinerycms-blog-0497261f39f351ab5be8862646c35669ee58579d.tar.bz2
refinerycms-blog-0497261f39f351ab5be8862646c35669ee58579d.zip
Converted Factory to FactoryGirl to fix deprecation warnings.
Diffstat (limited to 'spec')
-rw-r--r--spec/dummy/db/schema.rb3
-rw-r--r--spec/models/refinery/blog_category_spec.rb8
-rw-r--r--spec/models/refinery/blog_comment_spec.rb2
-rw-r--r--spec/models/refinery/blog_post_spec.rb58
-rw-r--r--spec/requests/blog_categories_spec.rb4
-rw-r--r--spec/requests/blog_posts_spec.rb2
-rw-r--r--spec/requests/manage_blog_posts_spec.rb2
7 files changed, 39 insertions, 40 deletions
diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb
index f65cc81..2cf06e5 100644
--- a/spec/dummy/db/schema.rb
+++ b/spec/dummy/db/schema.rb
@@ -95,10 +95,10 @@ ActiveRecord::Schema.define(:version => 20110812055013) do
t.integer "refinery_page_id"
t.string "locale"
t.string "title"
- t.string "custom_slug"
t.string "menu_title"
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "custom_slug"
end
add_index "refinery_page_translations", ["refinery_page_id"], :name => "index_d079468f88bff1c6ea81573a0d019ba8bf5c2902"
@@ -113,7 +113,6 @@ ActiveRecord::Schema.define(:version => 20110812055013) do
t.string "link_url"
t.string "menu_match"
t.boolean "deletable", :default => true
- t.string "custom_title"
t.boolean "draft", :default => false
t.boolean "skip_to_first_child", :default => false
t.integer "lft"
diff --git a/spec/models/refinery/blog_category_spec.rb b/spec/models/refinery/blog_category_spec.rb
index 9c92d14..704b6bb 100644
--- a/spec/models/refinery/blog_category_spec.rb
+++ b/spec/models/refinery/blog_category_spec.rb
@@ -3,16 +3,16 @@ require 'spec_helper'
module Refinery
describe BlogCategory do
before(:each) do
- @blog_category = Factory.create(:blog_category)
+ @blog_category = FactoryGirl.create(:blog_category)
end
describe "validations" do
it "requires title" do
- Factory.build(:blog_category, :title => "").should_not be_valid
+ FactoryGirl.build(:blog_category, :title => "").should_not be_valid
end
it "won't allow duplicate titles" do
- Factory.build(:blog_category, :title => @blog_category.title).should_not be_valid
+ FactoryGirl.build(:blog_category, :title => @blog_category.title).should_not be_valid
end
end
@@ -33,7 +33,7 @@ module Refinery
describe "#post_count" do
it "returns post count in category" do
2.times do
- @blog_category.posts << Factory.create(:blog_post)
+ @blog_category.posts << FactoryGirl.create(:blog_post)
end
@blog_category.post_count.should == 2
end
diff --git a/spec/models/refinery/blog_comment_spec.rb b/spec/models/refinery/blog_comment_spec.rb
index 5337958..57c90e8 100644
--- a/spec/models/refinery/blog_comment_spec.rb
+++ b/spec/models/refinery/blog_comment_spec.rb
@@ -6,7 +6,7 @@ module Refinery
context "wiring up" do
before(:each) do
- @comment = Factory.create(:blog_comment)
+ @comment = FactoryGirl.create(:blog_comment)
end
it "saves" do
diff --git a/spec/models/refinery/blog_post_spec.rb b/spec/models/refinery/blog_post_spec.rb
index 2501a24..15f8593 100644
--- a/spec/models/refinery/blog_post_spec.rb
+++ b/spec/models/refinery/blog_post_spec.rb
@@ -2,19 +2,19 @@ require 'spec_helper'
module Refinery
describe BlogPost do
- let(:blog_post) { Factory.create(:blog_post) }
+ let(:blog_post) { FactoryGirl.create(:blog_post) }
describe "validations" do
it "requires title" do
- Factory.build(:blog_post, :title => "").should_not be_valid
+ FactoryGirl.build(:blog_post, :title => "").should_not be_valid
end
it "won't allow duplicate titles" do
- Factory.build(:blog_post, :title => blog_post.title).should_not be_valid
+ FactoryGirl.build(:blog_post, :title => blog_post.title).should_not be_valid
end
it "requires body" do
- Factory.build(:blog_post, :body => nil).should_not be_valid
+ FactoryGirl.build(:blog_post, :body => nil).should_not be_valid
end
end
@@ -25,7 +25,7 @@ module Refinery
end
it "destroys associated comments" do
- Factory.create(:blog_comment, :blog_post_id => blog_post.id)
+ FactoryGirl.create(:blog_comment, :blog_post_id => blog_post.id)
blog_post.destroy
BlogComment.find_by_blog_post_id(blog_post.id).should == nil
end
@@ -54,11 +54,11 @@ module Refinery
describe "by_archive scope" do
before do
- @blog_post1 = Factory.create(:blog_post, :published_at => Date.new(2011, 3, 11))
- @blog_post2 = Factory.create(:blog_post, :published_at => Date.new(2011, 3, 12))
+ @blog_post1 = FactoryGirl.create(:blog_post, :published_at => Date.new(2011, 3, 11))
+ @blog_post2 = FactoryGirl.create(:blog_post, :published_at => Date.new(2011, 3, 12))
#2 months before
- Factory.create(:blog_post, :published_at => Date.new(2011, 1, 10))
+ FactoryGirl.create(:blog_post, :published_at => Date.new(2011, 1, 10))
end
it "returns all posts from specified month" do
@@ -71,9 +71,9 @@ module Refinery
describe "all_previous scope" do
before do
- @blog_post1 = Factory.create(:blog_post, :published_at => Time.now - 2.months)
- @blog_post2 = Factory.create(:blog_post, :published_at => Time.now - 1.month)
- Factory.create(:blog_post, :published_at => Time.now)
+ @blog_post1 = FactoryGirl.create(:blog_post, :published_at => Time.now - 2.months)
+ @blog_post2 = FactoryGirl.create(:blog_post, :published_at => Time.now - 1.month)
+ FactoryGirl.create(:blog_post, :published_at => Time.now)
end
it "returns all posts from previous months" do
@@ -84,10 +84,10 @@ module Refinery
describe "live scope" do
before do
- @blog_post1 = Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => -2))
- @blog_post2 = Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => -1))
- Factory.create(:blog_post, :draft => true)
- Factory.create(:blog_post, :published_at => Time.now + 1.minute)
+ @blog_post1 = FactoryGirl.create(:blog_post, :published_at => Time.now.advance(:minutes => -2))
+ @blog_post2 = FactoryGirl.create(:blog_post, :published_at => Time.now.advance(:minutes => -1))
+ FactoryGirl.create(:blog_post, :draft => true)
+ FactoryGirl.create(:blog_post, :published_at => Time.now + 1.minute)
end
it "returns all posts which aren't in draft and pub date isn't in future" do
@@ -98,10 +98,10 @@ module Refinery
describe "uncategorized scope" do
before do
- @uncategorized_blog_post = Factory.create(:blog_post)
- @categorized_blog_post = Factory.create(:blog_post)
+ @uncategorized_blog_post = FactoryGirl.create(:blog_post)
+ @categorized_blog_post = FactoryGirl.create(:blog_post)
- @categorized_blog_post.categories << Factory.create(:blog_category)
+ @categorized_blog_post.categories << FactoryGirl.create(:blog_category)
end
it "returns uncategorized posts if they exist" do
@@ -112,22 +112,22 @@ module Refinery
describe "#live?" do
it "returns true if post is not in draft and it's published" do
- Factory.create(:blog_post).live?.should be_true
+ FactoryGirl.create(:blog_post).live?.should be_true
end
it "returns false if post is in draft" do
- Factory.create(:blog_post, :draft => true).live?.should be_false
+ FactoryGirl.create(:blog_post, :draft => true).live?.should be_false
end
it "returns false if post pub date is in future" do
- Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => 1)).live?.should be_false
+ FactoryGirl.create(:blog_post, :published_at => Time.now.advance(:minutes => 1)).live?.should be_false
end
end
describe "#next" do
before do
- Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => -1))
- @blog_post = Factory.create(:blog_post)
+ FactoryGirl.create(:blog_post, :published_at => Time.now.advance(:minutes => -1))
+ @blog_post = FactoryGirl.create(:blog_post)
end
it "returns next article when called on current article" do
@@ -137,8 +137,8 @@ module Refinery
describe "#prev" do
before do
- Factory.create(:blog_post)
- @blog_post = Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => -1))
+ FactoryGirl.create(:blog_post)
+ @blog_post = FactoryGirl.create(:blog_post, :published_at => Time.now.advance(:minutes => -1))
end
it "returns previous article when called on current article" do
@@ -148,9 +148,9 @@ module Refinery
describe "#category_ids=" do
before do
- @cat1 = Factory.create(:blog_category, :id => 1)
- @cat2 = Factory.create(:blog_category, :id => 2)
- @cat3 = Factory.create(:blog_category, :id => 3)
+ @cat1 = FactoryGirl.create(:blog_category, :id => 1)
+ @cat2 = FactoryGirl.create(:blog_category, :id => 2)
+ @cat3 = FactoryGirl.create(:blog_category, :id => 3)
blog_post.category_ids = [1,2,"","",3]
end
@@ -187,7 +187,7 @@ module Refinery
describe "custom teasers" do
it "should allow a custom teaser" do
- Factory.create(:blog_post, :custom_teaser => 'This is some custom content').should be_valid
+ FactoryGirl.create(:blog_post, :custom_teaser => 'This is some custom content').should be_valid
end
end
diff --git a/spec/requests/blog_categories_spec.rb b/spec/requests/blog_categories_spec.rb
index d18a552..a554891 100644
--- a/spec/requests/blog_categories_spec.rb
+++ b/spec/requests/blog_categories_spec.rb
@@ -5,8 +5,8 @@ describe "blog categories" do
context "has one category and post" do
before(:each) do
- @blog_post = Factory.create(:blog_post, :title => "Refinery CMS blog post")
- @blog_category = Factory.create(:blog_category, :title => "Video Games")
+ @blog_post = FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post")
+ @blog_category = FactoryGirl.create(:blog_category, :title => "Video Games")
@blog_post.categories << @blog_category
@blog_post.save!
end
diff --git a/spec/requests/blog_posts_spec.rb b/spec/requests/blog_posts_spec.rb
index d7d2a9f..ec84b90 100644
--- a/spec/requests/blog_posts_spec.rb
+++ b/spec/requests/blog_posts_spec.rb
@@ -22,7 +22,7 @@ describe "blog posts" do
context "when has tagged blog posts" do
before(:each) do
@tag_name = "chicago"
- @blog_post = Factory.create(:blog_post,
+ @blog_post = FactoryGirl.create(:blog_post,
:title => "I Love my city",
:tag_list => @tag_name)
tag = ::Refinery::BlogPost.tag_counts_on(:tags).first
diff --git a/spec/requests/manage_blog_posts_spec.rb b/spec/requests/manage_blog_posts_spec.rb
index 6d6f734..2a299d0 100644
--- a/spec/requests/manage_blog_posts_spec.rb
+++ b/spec/requests/manage_blog_posts_spec.rb
@@ -3,7 +3,7 @@ require "spec_helper"
describe "manage blog posts" do
login_refinery_user
- let!(:blog_category) { Factory.create(:blog_category, :title => "Video Games") }
+ let!(:blog_category) { FactoryGirl.create(:blog_category, :title => "Video Games") }
context "when no blog posts" do
before(:each) { Refinery::BlogPost.destroy_all }