update and import refinerycms migrations and seeds

update Guardfile, spec_helper, and support files to match those generated by refinerycms-testing
This commit is contained in:
Jamie Winsor 2011-09-02 13:34:06 -07:00
parent 1779274971
commit fc68f22858
11 changed files with 52 additions and 38 deletions

View file

@ -1,12 +1,4 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
guard 'rspec', :version => 2, :cli => "--format Fuubar --color --drb" do
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" }

View file

@ -4,7 +4,7 @@ class CreateRefinerycmsCoreSchema < ActiveRecord::Migration
create_table ::Slug.table_name, :force => true do |t|
t.string "name"
t.integer "sluggable_id"
t.integer "sequence", :default => 1, :null => false
t.integer "sequence", :default => 1, :null => false
t.string "sluggable_type", :limit => 40
t.string "scope", :limit => 40
t.datetime "created_at"

View file

@ -13,7 +13,9 @@ class TranslatePagePlugin < ActiveRecord::Migration
:title => :string,
:meta_keywords => :string,
:meta_description => :text,
:browser_title => :string
:browser_title => :string,
:custom_slug => :string,
:menu_title => :string
}, {
:migrate_data => true
})

View file

@ -1,30 +1,30 @@
class TranslateCustomTitleOnPages < ActiveRecord::Migration
def self.up
unless ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(:custom_title)
add_column ::Refinery::Page.translation_class.table_name, :custom_title, :string
unless ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(:menu_title)
add_column ::Refinery::Page.translation_class.table_name, :menu_title, :string
say_with_time("Re-save custom_title") do
say_with_time("Re-save menu_title") do
::Refinery::Page.all.each do |page|
say "updating custom_title field for page##{page.id}"
page.update_attribute(:custom_title, page.untranslated_attributes['custom_title'])
say "updating menu_title field for page##{page.id}"
page.update_attribute(:menu_title, page.untranslated_attributes['menu_title'])
end
end
else
say "Nothing done, ::Refinery::Page.translation_class table already includes a custom_title field"
say "Nothing done, ::Refinery::Page.translation_class table already includes a menu_title field"
end
::Refinery::Page.translation_class.reset_column_information
end
def self.down
say_with_time("Re-save custom_title") do
say_with_time("Re-save menu_title") do
::Refinery::Page.all.each do |page|
if page.attributes['custom_title'].nil?
say "Nothing done, page##{page.id} custom_title field is nil"
if page.attributes['menu_title'].nil?
say "Nothing done, page##{page.id} menu_title field is nil"
else
say "updating custom_title field for page #{page.id}"
say "updating menu_title field for page #{page.id}"
::Refinery::Page.update_all({
:custom_title => page.attributes['custom_title']
:menu_title => page.attributes['menu_title']
}, {
:id => page.id.to_s
})
@ -32,9 +32,9 @@ class TranslateCustomTitleOnPages < ActiveRecord::Migration
end
end
remove_column ::Refinery::Page.translation_class.table_name, :custom_title
remove_column ::Refinery::Page.translation_class.table_name, :menu_title
::Refinery::Page.translated_attribute_names.delete(:custom_title)
::Refinery::Page.translated_attribute_names.delete(:menu_title)
::Refinery::Page.translation_class.reset_column_information
end

View file

@ -0,0 +1,11 @@
class AddCustomSlugToRefineryPageTranslations < ActiveRecord::Migration
def up
if ::Refinery::Page::Translation.column_names.map(&:to_sym).exclude?(:custom_slug)
add_column ::Refinery::Page::Translation.table_name, :custom_slug, :string, :default => nil
end
end
def down
remove_column ::Refinery::Page::Translation.table_name, :custom_slug
end
end

View file

@ -0,0 +1,15 @@
class RenameCustomTitleToMenuTitleInRefineryPages < ActiveRecord::Migration
def up
if ::Refinery::Page::Translation.column_names.map(&:to_sym).include?(:custom_title)
rename_column ::Refinery::Page::Translation.table_name, :custom_title, :menu_title
end
remove_column ::Refinery::Page.table_name, :custom_title_type
end
def down
if ::Refinery::Page::Translation.column_names.map(&:to_sym).include?(:menu_title)
rename_column ::Refinery::Page::Translation.table_name, :menu_title, :custom_title
end
add_column ::Refinery::Page.table_name, :custom_title_type, :string
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110803223529) do
ActiveRecord::Schema.define(:version => 20110812055013) do
create_table "refinery_blog_categories", :force => true do |t|
t.string "title"
@ -95,7 +95,8 @@ ActiveRecord::Schema.define(:version => 20110803223529) do
t.integer "refinery_page_id"
t.string "locale"
t.string "title"
t.string "custom_title"
t.string "custom_slug"
t.string "menu_title"
t.datetime "created_at"
t.datetime "updated_at"
end
@ -112,7 +113,7 @@ ActiveRecord::Schema.define(:version => 20110803223529) do
t.string "link_url"
t.string "menu_match"
t.boolean "deletable", :default => true
t.string "custom_title_type", :default => "none"
t.string "custom_title"
t.boolean "draft", :default => false
t.boolean "skip_to_first_child", :default => false
t.integer "lft"

View file

@ -1,14 +1,6 @@
module Refinery
::Refinery::Page.reset_column_information
# Check whether all columns are applied yet by seo_meta.
unless !defined?(::SeoMeta) || ::SeoMeta.attributes.keys.all? { |k|
::Refinery::Page.translation_class.instance_methods.include?(k)
}
# Make pages model seo_meta because not all columns are accessible.
::Refinery::Page.translation_class.send :is_seo_meta
end
page_position = -1
unless ::Refinery::Page.where(:menu_match => "^/$").any?

View file

@ -12,6 +12,7 @@ def setup_environment
require 'rspec/rails'
require 'capybara/rspec'
require 'factory_girl'
require 'refinerycms-testing'
Rails.backtrace_cleaner.remove_silencers!
@ -23,6 +24,8 @@ def setup_environment
RSpec.configure do |config|
config.mock_with :rspec
config.use_transactional_fixtures = false
config.extend ActionController::Testing::Caching, :type => :controller
end
end

View file

@ -1,6 +1,4 @@
require 'refinery/testing/factories'
require 'refinery/testing/controller_macros'
require 'refinery/testing/request_macros'
require 'refinerycms-testing'
RSpec.configure do |config|
config.extend Refinery::Testing::ControllerMacros::Authentication, :type => :controller