From b2700960d8f9b479a3bc1cc2799599b2b187492e Mon Sep 17 00:00:00 2001 From: Marc Remolt Date: Fri, 12 Aug 2011 18:44:00 +0200 Subject: [PATCH] Updated to latest refinerycms(-blog) * bundle update * new migrations * fixed specs for new behaviour --- Gemfile | 2 +- Gemfile.lock | 126 +++++++++--------- Guardfile | 17 +-- lib/wordpress/post.rb | 10 +- refinerycms-wordpress-import.gemspec | 6 +- spec/dummy/config/environments/development.rb | 4 +- spec/dummy/config/environments/production.rb | 4 +- spec/dummy/config/environments/test.rb | 4 +- .../20110812162202_add_cached_slugs.rb | 11 ++ ...2203_add_custom_url_field_to_blog_posts.rb | 9 ++ ...4_add_custom_teaser_field_to_blog_posts.rb | 10 ++ spec/dummy/db/schema.rb | 6 +- spec/dummy/db/seeds/pages.rb | 9 ++ spec/lib/wordpress/post_spec.rb | 16 +-- 14 files changed, 139 insertions(+), 95 deletions(-) create mode 100644 spec/dummy/db/migrate/20110812162202_add_cached_slugs.rb create mode 100644 spec/dummy/db/migrate/20110812162203_add_custom_url_field_to_blog_posts.rb create mode 100644 spec/dummy/db/migrate/20110812162204_add_custom_teaser_field_to_blog_posts.rb diff --git a/Gemfile b/Gemfile index 1297d72..4b41b28 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "http://rubygems.org" -gem "rails", "3.0.7" +gem "rails", "3.0.9" #gem "capybara", ">= 1.0.0.beta1" gem "sqlite3" gem "rmagick" diff --git a/Gemfile.lock b/Gemfile.lock index 4a3fd55..b166e14 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,22 +1,22 @@ PATH remote: ./ specs: - refinerycms-wordpress-import (0.3.0) + refinerycms-wordpress-import (0.4.0) bundler (~> 1.0) nokogiri (~> 1.4.4) refinerycms (~> 1.0.0) - refinerycms-blog (~> 1.5.2) + refinerycms-blog (~> 1.6.2) GEM remote: http://rubygems.org/ specs: abstract (1.0.0) - actionmailer (3.0.7) - actionpack (= 3.0.7) - mail (~> 2.2.15) - actionpack (3.0.7) - activemodel (= 3.0.7) - activesupport (= 3.0.7) + actionmailer (3.0.9) + actionpack (= 3.0.9) + mail (~> 2.2.19) + actionpack (3.0.9) + activemodel (= 3.0.9) + activesupport (= 3.0.9) builder (~> 2.1.2) erubis (~> 2.6.6) i18n (~> 0.5.0) @@ -24,19 +24,19 @@ GEM rack-mount (~> 0.6.14) rack-test (~> 0.5.7) tzinfo (~> 0.3.23) - activemodel (3.0.7) - activesupport (= 3.0.7) + activemodel (3.0.9) + activesupport (= 3.0.9) builder (~> 2.1.2) i18n (~> 0.5.0) - activerecord (3.0.7) - activemodel (= 3.0.7) - activesupport (= 3.0.7) - arel (~> 2.0.2) + activerecord (3.0.9) + activemodel (= 3.0.9) + activesupport (= 3.0.9) + arel (~> 2.0.10) tzinfo (~> 0.3.23) - activeresource (3.0.7) - activemodel (= 3.0.7) - activesupport (= 3.0.7) - activesupport (3.0.7) + activeresource (3.0.9) + activemodel (= 3.0.9) + activesupport (= 3.0.9) + activesupport (3.0.9) acts-as-taggable-on (2.0.6) acts_as_indexed (0.7.3) arel (2.0.10) @@ -51,7 +51,7 @@ GEM orm_adapter (~> 0.0.3) warden (~> 1.0.3) diff-lcs (1.1.2) - dragonfly (0.9.4) + dragonfly (0.9.5) rack erubis (2.6.6) abstract (>= 1.0.0) @@ -68,7 +68,7 @@ GEM guard-bundler (0.1.3) bundler (>= 1.0.0) guard (>= 0.2.2) - guard-rspec (0.4.0) + guard-rspec (0.4.1) guard (>= 0.4.0) i18n (0.5.0) libnotify (0.5.7) @@ -88,70 +88,72 @@ GEM rack (>= 1.0.0) rack-test (0.5.7) rack (>= 1.0) - rails (3.0.7) - actionmailer (= 3.0.7) - actionpack (= 3.0.7) - activerecord (= 3.0.7) - activeresource (= 3.0.7) - activesupport (= 3.0.7) + rails (3.0.9) + actionmailer (= 3.0.9) + actionpack (= 3.0.9) + activerecord (= 3.0.9) + activeresource (= 3.0.9) + activesupport (= 3.0.9) bundler (~> 1.0) - railties (= 3.0.7) - railties (3.0.7) - actionpack (= 3.0.7) - activesupport (= 3.0.7) + railties (= 3.0.9) + railties (3.0.9) + actionpack (= 3.0.9) + activesupport (= 3.0.9) rake (>= 0.8.7) + rdoc (~> 3.4) thor (~> 0.14.4) rake (0.9.2) - refinerycms (1.0.0) + rdoc (3.9.2) + refinerycms (1.0.4) bundler (~> 1.0) - refinerycms-authentication (= 1.0.0) - refinerycms-base (= 1.0.0) - refinerycms-core (= 1.0.0) - refinerycms-dashboard (= 1.0.0) - refinerycms-images (= 1.0.0) - refinerycms-pages (= 1.0.0) - refinerycms-resources (= 1.0.0) - refinerycms-settings (= 1.0.0) - refinerycms-authentication (1.0.0) + refinerycms-authentication (= 1.0.4) + refinerycms-base (= 1.0.4) + refinerycms-core (= 1.0.4) + refinerycms-dashboard (= 1.0.4) + refinerycms-images (= 1.0.4) + refinerycms-pages (= 1.0.4) + refinerycms-resources (= 1.0.4) + refinerycms-settings (= 1.0.4) + refinerycms-authentication (1.0.4) devise (~> 1.3.0) friendly_id_globalize3 (~> 3.2.1) - refinerycms-core (= 1.0.0) - refinerycms-base (1.0.0) - refinerycms-blog (1.5.2) + refinerycms-core (= 1.0.4) + refinerycms-base (1.0.4) + refinerycms-blog (1.6.2) acts-as-taggable-on filters_spam (~> 0.2) - refinerycms-core (~> 1.0.0) + refinerycms-core (~> 1.0.3) seo_meta (~> 1.1.0) - refinerycms-core (1.0.0) + refinerycms-core (1.0.4) acts_as_indexed (~> 0.7) awesome_nested_set (~> 2.0) friendly_id_globalize3 (~> 3.2.1) globalize3 (~> 0.1) - rails (~> 3.0.7) - refinerycms-base (= 1.0.0) + rails (~> 3.0.9) + refinerycms-base (= 1.0.4) refinerycms-generators (~> 1.0) - refinerycms-settings (= 1.0.0) + refinerycms-settings (= 1.0.4) truncate_html (~> 0.5) - will_paginate (~> 3.0.pre) - refinerycms-dashboard (1.0.0) - refinerycms-core (= 1.0.0) - refinerycms-generators (1.0.2) - refinerycms-images (1.0.0) + will_paginate (= 3.0.pre2) + refinerycms-dashboard (1.0.4) + refinerycms-core (= 1.0.4) + refinerycms-generators (1.0.3) + refinerycms-images (1.0.4) dragonfly (~> 0.9.0) rack-cache (>= 0.5.3) - refinerycms-core (= 1.0.0) - refinerycms-pages (1.0.0) + refinerycms-core (= 1.0.4) + refinerycms-pages (1.0.4) awesome_nested_set (~> 2.0) friendly_id_globalize3 (~> 3.2.1) globalize3 (~> 0.1) - refinerycms-core (= 1.0.0) + refinerycms-core (= 1.0.4) seo_meta (~> 1.1) - refinerycms-resources (1.0.0) + refinerycms-resources (1.0.4) dragonfly (~> 0.9.0) rack-cache (>= 0.5.3) - refinerycms-core (= 1.0.0) - refinerycms-settings (1.0.0) - refinerycms-base (= 1.0.0) + refinerycms-core (= 1.0.4) + refinerycms-settings (1.0.4) + refinerycms-base (= 1.0.4) rmagick (2.13.1) rspec (2.6.0) rspec-core (~> 2.6.0) @@ -177,7 +179,7 @@ GEM tzinfo (0.3.29) warden (1.0.5) rack (>= 1.0) - will_paginate (3.0.pre4) + will_paginate (3.0.pre2) PLATFORMS ruby @@ -189,7 +191,7 @@ DEPENDENCIES guard-bundler guard-rspec libnotify - rails (= 3.0.7) + rails (= 3.0.9) refinerycms refinerycms-blog refinerycms-wordpress-import! diff --git a/Guardfile b/Guardfile index 7d89890..08b0f3b 100644 --- a/Guardfile +++ b/Guardfile @@ -1,6 +1,12 @@ # A sample Guardfile # More info at https://github.com/guard/guard#readme +guard 'bundler' do + watch('Gemfile') + # Uncomment next line if Gemfile contain `gemspec' command + watch(/^.+\.gemspec/) +end + guard 'rspec', :version => 2 do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } @@ -8,19 +14,8 @@ guard 'rspec', :version => 2 do # Rails example watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } watch(%r{^spec/support/(.+)\.rb$}) { "spec" } watch('spec/spec_helper.rb') { "spec" } - watch('config/routes.rb') { "spec/routing" } - watch('app/controllers/application_controller.rb') { "spec/controllers" } - # Capybara request specs - watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } end -guard 'bundler' do - watch('Gemfile') - # Uncomment next line if Gemfile contain `gemspec' command - watch(/^.+\.gemspec/) -end diff --git a/lib/wordpress/post.rb b/lib/wordpress/post.rb index 0e3e2d0..f082513 100644 --- a/lib/wordpress/post.rb +++ b/lib/wordpress/post.rb @@ -34,11 +34,11 @@ module Refinery user = ::User.find_by_username(creator) || ::User.first raise "Referenced User doesn't exist! Make sure the authors are imported first." \ unless user - + begin - post = ::BlogPost.new :title => title, :body => content_formatted, - :draft => draft?, :published_at => post_date, :created_at => post_date, - :author => user, :tag_list => tag_list + post = ::BlogPost.new :title => title, :body => content_formatted, + :draft => draft?, :published_at => post_date, :created_at => post_date, + :user_id => user.id, :tag_list => tag_list post.save! ::BlogPost.transaction do @@ -52,7 +52,7 @@ module Refinery comment.save end end - rescue ActiveRecord::RecordInvalid + rescue ActiveRecord::RecordInvalid # if the title has already been taken (WP allows duplicates here, # refinery doesn't) append the post_id to it, making it unique post.title = "#{title}-#{post_id}" diff --git a/refinerycms-wordpress-import.gemspec b/refinerycms-wordpress-import.gemspec index e1bac73..411879b 100644 --- a/refinerycms-wordpress-import.gemspec +++ b/refinerycms-wordpress-import.gemspec @@ -4,16 +4,16 @@ Gem::Specification.new do |s| s.name = "refinerycms-wordpress-import" s.summary = "Import WordPress XML dumps into refinerycms(-blog)." s.description = "This gem imports a WordPress XML dump into refinerycms (Page, User) and refinerycms-blog (BlogPost, BlogCategory, Tag, BlogComment)" - s.version = "0.3.0" + s.version = "0.4.0" s.date = "2011-06-13" s.authors = ['Marc Remolt'] s.email = 'marc.remolt@googlemail.com' s.homepage = 'https://github.com/mremolt/refinerycms-wordpress-import' - + s.add_dependency 'bundler', '~> 1.0' s.add_dependency 'refinerycms', '~> 1.0.0' - s.add_dependency 'refinerycms-blog', '~> 1.5.2' + s.add_dependency 'refinerycms-blog', '~> 1.6.2' s.add_dependency 'nokogiri', '~> 1.4.4' s.add_development_dependency 'rspec-rails' diff --git a/spec/dummy/config/environments/development.rb b/spec/dummy/config/environments/development.rb index ed94ce1..c401189 100644 --- a/spec/dummy/config/environments/development.rb +++ b/spec/dummy/config/environments/development.rb @@ -24,4 +24,6 @@ Dummy::Application.configure do config.action_dispatch.best_standards_support = :builtin end -Refinery.rescue_not_found = false \ No newline at end of file +Refinery.rescue_not_found = false# When true will use Amazon's Simple Storage Service on your production machine +# instead of the default file system for resources and images +Refinery.s3_backend = !(ENV['S3_KEY'].nil? || ENV['S3_SECRET'].nil?) diff --git a/spec/dummy/config/environments/production.rb b/spec/dummy/config/environments/production.rb index b8a419f..3584b4b 100644 --- a/spec/dummy/config/environments/production.rb +++ b/spec/dummy/config/environments/production.rb @@ -47,4 +47,6 @@ Dummy::Application.configure do # Send deprecation notices to registered listeners config.active_support.deprecation = :notify end -Refinery.rescue_not_found = true \ No newline at end of file +Refinery.rescue_not_found = true# When true will use Amazon's Simple Storage Service on your production machine +# instead of the default file system for resources and images +Refinery.s3_backend = !(ENV['S3_KEY'].nil? || ENV['S3_SECRET'].nil?) diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index 588e9b9..ffd5200 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -33,4 +33,6 @@ Dummy::Application.configure do # Print deprecation notices to the stderr config.active_support.deprecation = :stderr end -Refinery.rescue_not_found = false \ No newline at end of file +Refinery.rescue_not_found = false# When true will use Amazon's Simple Storage Service on your production machine +# instead of the default file system for resources and images +Refinery.s3_backend = !(ENV['S3_KEY'].nil? || ENV['S3_SECRET'].nil?) diff --git a/spec/dummy/db/migrate/20110812162202_add_cached_slugs.rb b/spec/dummy/db/migrate/20110812162202_add_cached_slugs.rb new file mode 100644 index 0000000..c189302 --- /dev/null +++ b/spec/dummy/db/migrate/20110812162202_add_cached_slugs.rb @@ -0,0 +1,11 @@ +class AddCachedSlugs < ActiveRecord::Migration + def self.up + add_column :blog_categories, :cached_slug, :string + add_column :blog_posts, :cached_slug, :string + end + + def self.down + remove_column :blog_categories, :cached_slug + remove_column :blog_posts, :cached_slug + end +end diff --git a/spec/dummy/db/migrate/20110812162203_add_custom_url_field_to_blog_posts.rb b/spec/dummy/db/migrate/20110812162203_add_custom_url_field_to_blog_posts.rb new file mode 100644 index 0000000..5a8901e --- /dev/null +++ b/spec/dummy/db/migrate/20110812162203_add_custom_url_field_to_blog_posts.rb @@ -0,0 +1,9 @@ +class AddCustomUrlFieldToBlogPosts < ActiveRecord::Migration + def self.up + add_column :blog_posts, :custom_url, :string + end + + def self.down + remove_column :blog_posts, :custom_url + end +end diff --git a/spec/dummy/db/migrate/20110812162204_add_custom_teaser_field_to_blog_posts.rb b/spec/dummy/db/migrate/20110812162204_add_custom_teaser_field_to_blog_posts.rb new file mode 100644 index 0000000..daa4d04 --- /dev/null +++ b/spec/dummy/db/migrate/20110812162204_add_custom_teaser_field_to_blog_posts.rb @@ -0,0 +1,10 @@ +class AddCustomTeaserFieldToBlogPosts < ActiveRecord::Migration + def self.up + add_column :blog_posts, :custom_teaser, :text + end + + def self.down + remove_column :blog_posts, :custom_teaser + end +end + diff --git a/spec/dummy/db/schema.rb b/spec/dummy/db/schema.rb index 5677db4..1c877ff 100644 --- a/spec/dummy/db/schema.rb +++ b/spec/dummy/db/schema.rb @@ -10,12 +10,13 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110602094445) do +ActiveRecord::Schema.define(:version => 20110812162204) do create_table "blog_categories", :force => true do |t| t.string "title" t.datetime "created_at" t.datetime "updated_at" + t.string "cached_slug" end add_index "blog_categories", ["id"], :name => "index_blog_categories_on_id" @@ -48,6 +49,9 @@ ActiveRecord::Schema.define(:version => 20110602094445) do t.datetime "created_at" t.datetime "updated_at" t.integer "user_id" + t.string "cached_slug" + t.string "custom_url" + t.text "custom_teaser" end add_index "blog_posts", ["id"], :name => "index_blog_posts_on_id" diff --git a/spec/dummy/db/seeds/pages.rb b/spec/dummy/db/seeds/pages.rb index 07cf55e..fe33e27 100644 --- a/spec/dummy/db/seeds/pages.rb +++ b/spec/dummy/db/seeds/pages.rb @@ -1,3 +1,12 @@ +::Page.reset_column_information +# Check whether all columns are applied yet by seo_meta. +unless !defined?(::SeoMeta) || ::SeoMeta.attributes.keys.all? { |k| + ::Page.translation_class.instance_methods.include?(k) +} + # Make pages model seo_meta because not all columns are accessible. + ::Page.translation_class.send :is_seo_meta +end + page_position = -1 home_page = Page.create(:title => "Home", diff --git a/spec/lib/wordpress/post_spec.rb b/spec/lib/wordpress/post_spec.rb index 4e3ae7d..ac3b4d8 100644 --- a/spec/lib/wordpress/post_spec.rb +++ b/spec/lib/wordpress/post_spec.rb @@ -63,6 +63,7 @@ describe Refinery::WordPress::Post, :type => :model do @comment.body.should == comment.content @comment.state.should == 'approved' @comment.created_at.should == comment.date + @comment.created_at.should == comment.date end end end @@ -79,16 +80,13 @@ describe Refinery::WordPress::Post, :type => :model do @post = post.to_refinery end - specify { BlogPost.should have(1).record } + specify { BlogPost.should have(1).record } - it "should copy the attributes from Refinery::WordPress::Post" do - @post.title.should == post.title - @post.body.should == post.content_formatted - @post.draft.should == post.draft? - @post.published_at.should == post.post_date - @post.created_at.should == post.post_date - @post.author.username.should == post.creator - end + specify { @post.title.should == post.title } + specify { @post.body.should == post.content_formatted } + specify { @post.draft.should == post.draft? } + specify { @post.published_at.should == post.post_date } + specify { @post.author.username.should == post.creator } it "should assign a category for each Refinery::WordPress::Category" do @post.categories.should have(post.categories.count).records