diff options
| -rw-r--r-- | features/category.feature | 2 | ||||
| -rw-r--r-- | features/support/factories/blog_comments.rb | 2 | ||||
| -rw-r--r-- | features/support/factories/blog_posts.rb | 2 | ||||
| -rw-r--r-- | features/support/step_definitions/category_steps.rb | 8 | ||||
| -rw-r--r-- | features/support/step_definitions/tags_steps.rb | 4 | ||||
| -rw-r--r-- | lib/gemspec.rb | 4 | ||||
| -rw-r--r-- | refinerycms-blog.gemspec | 3 | ||||
| -rw-r--r-- | spec/models/blog_category_spec.rb | 10 | ||||
| -rw-r--r-- | spec/models/blog_comment_spec.rb | 2 | ||||
| -rw-r--r-- | spec/models/blog_post_spec.rb | 74 | 
10 files changed, 55 insertions, 56 deletions
diff --git a/features/category.feature b/features/category.feature index 14ec93e..6af1075 100644 --- a/features/category.feature +++ b/features/category.feature @@ -19,5 +19,5 @@ Feature: Blog Post Categories      And I press "Save"      Then there should be 1 blog post -    And the blog post should have "1" category +    And the blog post should have 1 category      And the blog post should have the category "Videos"
\ No newline at end of file diff --git a/features/support/factories/blog_comments.rb b/features/support/factories/blog_comments.rb index af364be..9405c42 100644 --- a/features/support/factories/blog_comments.rb +++ b/features/support/factories/blog_comments.rb @@ -4,5 +4,5 @@ Factory.define(: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 +  f.association :post, :factory => :blog_post  end diff --git a/features/support/factories/blog_posts.rb b/features/support/factories/blog_posts.rb index 33f6b93..4584fec 100644 --- a/features/support/factories/blog_posts.rb +++ b/features/support/factories/blog_posts.rb @@ -1,6 +1,6 @@  require 'factory_girl' -Factory.define(:post, :class => BlogPost) do |f| +Factory.define(:blog_post, :class => BlogPost) 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 diff --git a/features/support/step_definitions/category_steps.rb b/features/support/step_definitions/category_steps.rb index 31176b4..891b5c0 100644 --- a/features/support/step_definitions/category_steps.rb +++ b/features/support/step_definitions/category_steps.rb @@ -1,11 +1,11 @@  Given /^there is a category titled "([^"]*)"$/ do |title| -  @category = Factory(:blog_category, :title => title) +  @category = Factory.create(:blog_category, :title => title)  end -Then /^the blog post should have "([^"]*)" category$/ do |num_category| -  BlogPost.last.categories.count.should == num_category +Then /^the blog post should have ([\d]*) categor[yies]{1,3}$/ do |num_category| +  BlogPost.last.categories.count.should == num_category.to_i  end -Then /^the blog post should have the category "([^"]*)"$/ do |category|  +Then /^the blog post should have the category "([^"]*)"$/ do |category|    BlogPost.last.categories.first.title.should == category  end
\ No newline at end of file diff --git a/features/support/step_definitions/tags_steps.rb b/features/support/step_definitions/tags_steps.rb index 7b895e5..8280474 100644 --- a/features/support/step_definitions/tags_steps.rb +++ b/features/support/step_definitions/tags_steps.rb @@ -1,9 +1,9 @@  Given /^there is a blog post titled "([^"]*)" and tagged "([^"]*)"$/ do |title, tag_name| -  @blog_post = Factory(:post, :title => title, :tag_list => tag_name) +  @blog_post = Factory.create(:blog_post, :title => title, :tag_list => tag_name)  end  When /^I visit the tagged posts page for "([^"]*)"$/ do |tag_name| -  @blog_post ||= Factory(:post, :tag_list => tag_name) +  @blog_post ||= Factory.create(:blog_post, :tag_list => tag_name)    tag = BlogPost.tag_counts_on(:tags).first    visit tagged_posts_path(tag.id, tag_name.parameterize)  end diff --git a/lib/gemspec.rb b/lib/gemspec.rb index 25f9157..9eca4f4 100644 --- a/lib/gemspec.rb +++ b/lib/gemspec.rb @@ -2,9 +2,7 @@  require File.expand_path('../refinery/blog/version', __FILE__)  version = ::Refinery::Blog::Version.to_s  raise "Could not get version so gemspec can not be built" if version.nil? -files = Dir.glob("**/*").flatten.reject do |file| -  file =~ /\.gem(spec)?$/ -end +files = Dir.glob("**/*").flatten  gemspec = <<EOF  Gem::Specification.new do |s| diff --git a/refinerycms-blog.gemspec b/refinerycms-blog.gemspec index 1059f7c..ac42170 100644 --- a/refinerycms-blog.gemspec +++ b/refinerycms-blog.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s|    s.name              = %q{refinerycms-blog}    s.version           = %q{1.6.2}    s.description       = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.} -  s.date              = %q{2011-06-27} +  s.date              = %q{2011-06-29}    s.summary           = %q{Ruby on Rails blogging engine for RefineryCMS.}    s.email             = %q{info@refinerycms.com}    s.homepage          = %q{http://refinerycms.com/blog} @@ -191,6 +191,7 @@ Gem::Specification.new do |s|      public/stylesheets/ui-lightness/images/ui-icons_ffffff_256x240.png      public/stylesheets/ui-lightness/jquery-ui-1.8.13.custom.css      readme.md +    refinerycms-blog.gemspec      spec      spec/models      spec/models/blog_category_spec.rb diff --git a/spec/models/blog_category_spec.rb b/spec/models/blog_category_spec.rb index 8ddec46..7792744 100644 --- a/spec/models/blog_category_spec.rb +++ b/spec/models/blog_category_spec.rb @@ -3,7 +3,7 @@ Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each  describe BlogCategory do    before(:each) do -    @blog_category = Factory(:blog_category) +    @blog_category = Factory.create(:blog_category)    end    describe "validations" do @@ -20,20 +20,20 @@ describe BlogCategory do      it "has a posts attribute" do        @blog_category.should respond_to(:posts)      end -     +      it "returns posts by published_at date in descending order" do        first_post = @blog_category.posts.create!({ :title => "Breaking News: Joe Sak is hot stuff you guys!!", :body => "True story.", :published_at => Time.now.yesterday }) -      latest_post = @blog_category.posts.create!({ :title => "parndt is p. okay", :body => "For a kiwi.", :published_at => Time.now }) +      latest_post = @blog_category.posts.create!({ :title => "parndt is p. okay", :body => "For a Kiwi.", :published_at => Time.now })        @blog_category.posts.first.should == latest_post      end -       +    end    describe "#post_count" do      it "returns post count in category" do        2.times do -        @blog_category.posts << Factory(:post) +        @blog_category.posts << Factory.create(:blog_post)        end        @blog_category.post_count.should == 2      end diff --git a/spec/models/blog_comment_spec.rb b/spec/models/blog_comment_spec.rb index a7c1d33..feb2860 100644 --- a/spec/models/blog_comment_spec.rb +++ b/spec/models/blog_comment_spec.rb @@ -6,7 +6,7 @@ describe BlogComment do    context "wiring up" do      before(:each) do -      @comment = Factory(:blog_comment) +      @comment = Factory.create(:blog_comment)      end      it "saves" do diff --git a/spec/models/blog_post_spec.rb b/spec/models/blog_post_spec.rb index 123fe9d..5642446 100644 --- a/spec/models/blog_post_spec.rb +++ b/spec/models/blog_post_spec.rb @@ -2,19 +2,19 @@ require 'spec_helper'  Dir[File.expand_path('../../../features/support/factories/*.rb', __FILE__)].each{|factory| require factory}  describe BlogPost do -  let(:blog_post ) { Factory :post } -   +  let(:blog_post ) { Factory.create(:blog_post) } +    describe "validations" do      it "requires title" do -      Factory.build(:post, :title => "").should_not be_valid +      Factory.build(:blog_post, :title => "").should_not be_valid      end      it "won't allow duplicate titles" do -      Factory.build(:post, :title => blog_post.title).should_not be_valid +      Factory.build(:blog_post, :title => blog_post.title).should_not be_valid      end      it "requires body" do -      Factory.build(:post, :body => nil).should_not be_valid +      Factory.build(:blog_post, :body => nil).should_not be_valid      end    end @@ -25,7 +25,7 @@ describe BlogPost do      end      it "destroys associated comments" do -      Factory(:blog_comment, :blog_post_id => blog_post.id) +      Factory.create(:blog_comment, :blog_post_id => blog_post.id)        blog_post.destroy        BlogComment.find_by_blog_post_id(blog_post.id).should == nil      end @@ -36,16 +36,16 @@ describe BlogPost do        blog_post.should respond_to(:categories)      end    end -   +    describe "tags" do      it "acts as taggable" do        blog_post.should respond_to(:tag_list) -       +        #the factory has default tags, including 'chicago'        blog_post.tag_list.should include("chicago")      end    end -   +    describe "authors" do      it "are authored" do        BlogPost.instance_methods.map(&:to_sym).should include(:author) @@ -54,11 +54,11 @@ describe BlogPost do    describe "by_archive scope" do      before do -      @blog_post1 = Factory(:post, :published_at => Date.new(2011, 3, 11)) -      @blog_post2 = Factory(:post, :published_at => Date.new(2011, 3, 12)) -       +      @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)) +        #2 months before -      Factory(:post, :published_at => Date.new(2011, 1, 10)) +      Factory.create(:blog_post, :published_at => Date.new(2011, 1, 10))      end      it "returns all posts from specified month" do @@ -71,9 +71,9 @@ describe BlogPost do    describe "all_previous scope" do      before do -      @blog_post1 = Factory(:post, :published_at => Time.now - 2.months) -      @blog_post2 = Factory(:post, :published_at => Time.now - 1.month) -      Factory :post, :published_at => Time.now +      @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)      end      it "returns all posts from previous months" do @@ -84,10 +84,10 @@ describe BlogPost do    describe "live scope" do      before do -      @blog_post1 = Factory(:post, :published_at => Time.now.advance(:minutes => -2)) -      @blog_post2 = Factory(:post, :published_at => Time.now.advance(:minutes => -1)) -      Factory(:post, :draft => true) -      Factory(:post, :published_at => Time.now + 1.minute) +      @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)      end      it "returns all posts which aren't in draft and pub date isn't in future" do @@ -98,10 +98,10 @@ describe BlogPost do    describe "uncategorized scope" do      before do -      @uncategorized_blog_post = Factory(:post) -      @categorized_blog_post = Factory(:post) +      @uncategorized_blog_post = Factory.create(:blog_post) +      @categorized_blog_post = Factory.create(:blog_post) -      @categorized_blog_post.categories << Factory(:blog_category) +      @categorized_blog_post.categories << Factory.create(:blog_category)      end      it "returns uncategorized posts if they exist" do @@ -112,22 +112,22 @@ describe BlogPost do    describe "#live?" do      it "returns true if post is not in draft and it's published" do -      Factory(:post).live?.should be_true +      Factory.create(:blog_post).live?.should be_true      end      it "returns false if post is in draft" do -      Factory(:post, :draft => true).live?.should be_false +      Factory.create(:blog_post, :draft => true).live?.should be_false      end      it "returns false if post pub date is in future" do -      Factory(:post, :published_at => Time.now.advance(:minutes => 1)).live?.should be_false +      Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => 1)).live?.should be_false      end    end    describe "#next" do      before do -      Factory(:post, :published_at => Time.now.advance(:minutes => -1)) -      @blog_post = Factory(:post) +      Factory.create(:blog_post, :published_at => Time.now.advance(:minutes => -1)) +      @blog_post = Factory.create(:blog_post)      end      it "returns next article when called on current article" do @@ -137,8 +137,8 @@ describe BlogPost do    describe "#prev" do      before do -      Factory(:post) -      @blog_post = Factory(:post, :published_at => Time.now.advance(:minutes => -1)) +      Factory.create(:blog_post) +      @blog_post = Factory.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 @@ describe BlogPost do    describe "#category_ids=" do      before do -      @cat1 = Factory(:blog_category, :id => 1) -      @cat2 = Factory(:blog_category, :id => 2) -      @cat3 = Factory(:blog_category, :id => 3) +      @cat1 = Factory.create(:blog_category, :id => 1) +      @cat2 = Factory.create(:blog_category, :id => 2) +      @cat3 = Factory.create(:blog_category, :id => 3)        blog_post.category_ids = [1,2,"","",3]      end @@ -168,7 +168,7 @@ describe BlogPost do        before do          RefinerySetting.set(:comments_allowed, { :scoping => 'blog', :value => true })        end -       +        it "should be true" do          BlogPost.comments_allowed?.should be_true        end @@ -178,16 +178,16 @@ describe BlogPost do        before do          RefinerySetting.set(:comments_allowed, { :scoping => 'blog', :value => false })        end -       +        it "should be false" do          BlogPost.comments_allowed?.should be_false        end      end    end -   +    describe "custom teasers" do      it "should allow a custom teaser" do -      Factory.build(:blog_post, :custom_teaser => 'This is some custom content').should be_valid +      Factory.create(:blog_post, :custom_teaser => 'This is some custom content').should be_valid      end    end  end  | 
