Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

refactor engine testing scenario

Engine is now tested standalone by leveraging a dummy rails app
Enable Guard for speedy testing
Move factories to the more standard location `spec/factories/*`
Update README with a Testing section
Rename migrations to contain datetimestamps for their version to fix migration order issues when migrating the dummy application
  • Loading branch information...
commit 21b19db5a30fcb6db83f4ac9302cc94c6320a0db 1 parent 3454a9c
@reset reset authored
Showing with 2,208 additions and 64 deletions.
  1. +3 −0  .gitignore
  2. +2 −0  .rspec
  3. +8 −0 Gemfile
  4. +34 −0 Guardfile
  5. +26 −0 Rakefile
  6. 0  app/assets/images/refinerycms-blog/.gitkeep
  7. 0  app/assets/javascripts/refinerycms-blog/.gitkeep
  8. 0  app/assets/stylesheets/refinerycms-blog/.gitkeep
  9. 0  app/controllers/.gitkeep
  10. 0  app/helpers/.gitkeep
  11. 0  app/models/.gitkeep
  12. 0  app/views/.gitkeep
  13. +10 −0 config/cucumber.yml
  14. +3 −0  config/environment.rb
  15. +1 −1  db/migrate/{1_create_blog_structure.rb → 20110803223522_create_blog_structure.rb}
  16. 0  db/migrate/{2_add_user_id_to_blog_posts.rb → 20110803223523_add_user_id_to_blog_posts.rb}
  17. 0  db/migrate/{3_acts_as_taggable_on_migration.rb → 20110803223524_acts_as_taggable_on_migration.rb}
  18. 0  db/migrate/{4_create_seo_meta_for_blog.rb → 20110803223525_create_seo_meta_for_blog.rb}
  19. 0  db/migrate/{5_add_cached_slugs.rb → 20110803223526_add_cached_slugs.rb}
  20. 0  ...grate/{6_add_custom_url_field_to_blog_posts.rb → 20110803223527_add_custom_url_field_to_blog_posts.rb}
  21. 0  ...{7_add_custom_teaser_field_to_blog_posts.rb → 20110803223528_add_custom_teaser_field_to_blog_posts.rb}
  22. 0  ...grate/{8_add_primary_key_to_categorizations.rb → 20110803223529_add_primary_key_to_categorizations.rb}
  23. 0  features/{support → }/step_definitions/authors_steps.rb
  24. 0  features/{support → }/step_definitions/category_steps.rb
  25. 0  features/{support → }/step_definitions/tags_steps.rb
  26. +42 −0 features/step_definitions/user_steps.rb
  27. +196 −0 features/step_definitions/web_steps.rb
  28. +50 −0 features/support/env.rb
  29. +14 −20 features/support/paths.rb
  30. +39 −0 features/support/selectors.rb
  31. +21 −0 lib/refinery/blog/engine.rb
  32. +8 −20 lib/refinerycms-blog.rb
  33. +16 −1 readme.md
  34. +13 −0 refinerycms-blog.gemspec
  35. +10 −0 script/cucumber
  36. +6 −0 script/rails
  37. +77 −0 spec/dummy/.gitignore
  38. +7 −0 spec/dummy/Rakefile
  39. +7 −0 spec/dummy/app/assets/javascripts/admin.js
  40. +9 −0 spec/dummy/app/assets/javascripts/application.js
  41. +1 −0  spec/dummy/app/assets/stylesheets/application.css
  42. +1 −0  spec/dummy/app/assets/stylesheets/application.css.backup
  43. +4 −0 spec/dummy/app/assets/stylesheets/formatting.css
  44. +4 −0 spec/dummy/app/assets/stylesheets/home.css
  45. +4 −0 spec/dummy/app/assets/stylesheets/theme.css
  46. +3 −0  spec/dummy/app/controllers/application_controller.rb
  47. +2 −0  spec/dummy/app/helpers/application_helper.rb
  48. 0  spec/dummy/app/mailers/.gitkeep
  49. 0  spec/dummy/app/models/.gitkeep
  50. +14 −0 spec/dummy/app/views/layouts/application.html.erb.backup
  51. +25 −0 spec/dummy/app/views/sitemap/index.xml.builder
  52. +17 −0 spec/dummy/autotest/autotest.rb
  53. +2 −0  spec/dummy/autotest/discover.rb
  54. +4 −0 spec/dummy/config.ru
  55. +42 −0 spec/dummy/config/application.rb
  56. +10 −0 spec/dummy/config/boot.rb
  57. +25 −0 spec/dummy/config/database.yml
  58. +20 −0 spec/dummy/config/database.yml.mysql
  59. +55 −0 spec/dummy/config/database.yml.postgresql
  60. +26 −0 spec/dummy/config/database.yml.sqlite3
  61. +5 −0 spec/dummy/config/environment.rb
  62. +31 −0 spec/dummy/config/environments/development.rb
  63. +55 −0 spec/dummy/config/environments/production.rb
  64. +43 −0 spec/dummy/config/environments/test.rb
  65. +7 −0 spec/dummy/config/initializers/backtrace_silencers.rb
  66. +144 −0 spec/dummy/config/initializers/devise.rb
  67. +10 −0 spec/dummy/config/initializers/inflections.rb
  68. +5 −0 spec/dummy/config/initializers/mime_types.rb
  69. +7 −0 spec/dummy/config/initializers/secret_token.rb
  70. +8 −0 spec/dummy/config/initializers/session_store.rb
  71. +12 −0 spec/dummy/config/initializers/wrap_parameters.rb
  72. +5 −0 spec/dummy/config/locales/en.yml
  73. +58 −0 spec/dummy/config/routes.rb
  74. +23 −0 spec/dummy/db/migrate/20110802081556_create_refinerycms_core_schema.rb
  75. +13 −0 spec/dummy/db/migrate/20110802081557_add_locale_to_slugs.rb
  76. +24 −0 spec/dummy/db/migrate/20110802081558_create_refinerycms_settings_schema.rb
  77. +9 −0 spec/dummy/db/migrate/20110802081559_add_value_type_to_refinery_settings.rb
  78. +48 −0 spec/dummy/db/migrate/20110802081560_create_refinerycms_authentication_schema.rb
  79. +11 −0 spec/dummy/db/migrate/20110802081561_add_missing_indexes_to_roles_users.rb
  80. +31 −0 spec/dummy/db/migrate/20110802081562_change_to_devise_users_table.rb
  81. +5 −0 spec/dummy/db/migrate/20110802081563_add_remember_created_at_to_users.rb
  82. +13 −0 spec/dummy/db/migrate/20110802081564_remove_password_salt_from_users.rb
  83. +23 −0 spec/dummy/db/migrate/20110802081565_create_refinerycms_images_schema.rb
  84. +56 −0 spec/dummy/db/migrate/20110802081566_create_refinerycms_pages_schema.rb
  85. +38 −0 spec/dummy/db/migrate/20110802081567_translate_page_plugin.rb
  86. +11 −0 spec/dummy/db/migrate/20110802081568_remove_cached_slug_from_pages.rb
  87. +26 −0 spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb
  88. +13 −0 spec/dummy/db/migrate/20110802081570_remove_translated_fields_from_pages.rb
  89. +86 −0 spec/dummy/db/migrate/20110802081571_create_seo_meta.rb
  90. +11 −0 spec/dummy/db/migrate/20110802081572_create_add_template_columns.rb
  91. +21 −0 spec/dummy/db/migrate/20110802081573_create_refinerycms_resources_schema.rb
  92. +239 −0 spec/dummy/db/schema.rb
  93. +5 −0 spec/dummy/db/seeds.rb
  94. +63 −0 spec/dummy/db/seeds/pages.rb
  95. 0  spec/dummy/lib/assets/.gitkeep
  96. 0  spec/dummy/log/.gitkeep
  97. +26 −0 spec/dummy/public/404.html
  98. +26 −0 spec/dummy/public/422.html
  99. +26 −0 spec/dummy/public/500.html
  100. 0  spec/dummy/public/favicon.ico
  101. +6 −0 spec/dummy/script/rails
  102. 0  spec/{support/refinery → }/factories/blog_categories.rb
  103. 0  spec/{support/refinery → }/factories/blog_comments.rb
  104. 0  spec/{support/refinery → }/factories/blog_posts.rb
  105. +27 −0 spec/factories/user.rb
  106. +2 −2 spec/models/refinery/blog_post_spec.rb
  107. +2 −0  spec/rcov.opts
  108. +1 −3 spec/requests/blog_categories_spec.rb
  109. +16 −16 spec/requests/blog_posts_spec.rb
  110. +8 −1 spec/requests/manage_blog_posts_spec.rb
  111. +48 −0 spec/spec_helper.rb
View
3  .gitignore
@@ -42,3 +42,6 @@ nbproject
# Capybara Bug
capybara-*html
+
+.rvmrc
+Gemfile.lock
View
2  .rspec
@@ -0,0 +1,2 @@
+--color spec
+--drb
View
8 Gemfile
@@ -0,0 +1,8 @@
+source "http://rubygems.org"
+
+## Uncomment the following lines to develop against a local clone of refinery
+# gem 'refinerycms', :path => '~/Code/refinerycms'
+# gem 'refinerycms-generators', :path => '~/Code/refinerycms-generators'
+# gem 'seo_meta', :git => 'git://github.com/parndt/seo_meta.git'
+
+gemspec
View
34 Guardfile
@@ -0,0 +1,34 @@
+# 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
+ 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 'cucumber' do
+ watch(%r{^features/.+\.feature$})
+ watch(%r{^features/support/.+$}) { 'features' }
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
+end
+
+guard 'spork', :wait => 60, :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
+ watch('config/application.rb')
+ watch('config/environment.rb')
+ watch(%r{^config/environments/.+\.rb$})
+ watch(%r{^config/initializers/.+\.rb$})
+ watch('spec/spec_helper.rb')
+end
View
26 Rakefile
@@ -0,0 +1,26 @@
+#!/usr/bin/env rake
+begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+begin
+ require 'rdoc/task'
+rescue LoadError
+ require 'rdoc/rdoc'
+ require 'rake/rdoctask'
+ RDoc::Task = Rake::RDocTask
+end
+
+RDoc::Task.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'RefinerycmsBlog'
+ rdoc.options << '--line-numbers'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
+load 'rails/tasks/engine.rake'
+
+Bundler::GemHelper.install_tasks
View
0  app/assets/images/refinerycms-blog/.gitkeep
No changes.
View
0  app/assets/javascripts/refinerycms-blog/.gitkeep
No changes.
View
0  app/assets/stylesheets/refinerycms-blog/.gitkeep
No changes.
View
0  app/controllers/.gitkeep
No changes.
View
0  app/helpers/.gitkeep
No changes.
View
0  app/models/.gitkeep
No changes.
View
0  app/views/.gitkeep
No changes.
View
10 config/cucumber.yml
@@ -0,0 +1,10 @@
+<%
+ENV["RAILS_ENV"] ||= "test"
+require ::File.expand_path('../spec/dummy/config/environment', __FILE__)
+rerun = IO.read('rerun.txt') if File.file?('rerun.txt')
+rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
+std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip -r features"
+%>
+default: <%= std_opts %>
+wip: --tags @wip:3 --wip features
+rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
View
3  config/environment.rb
@@ -0,0 +1,3 @@
+# TODO: Remove this when you figure out how to get Cucumber to look for the
+# environment file in the dummy app instead of within the project root
+require File.expand_path('../../spec/dummy/config/environment', __FILE__)
View
2  db/migrate/1_create_blog_structure.rb → db/migrate/20110803223522_create_blog_structure.rb
@@ -37,7 +37,7 @@ def up
add_index Refinery::Categorization.table_name, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp'
- load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s)
+ load(File.expand_path('../../seeds/refinerycms_blog.rb', __FILE__))
end
def down
View
0  db/migrate/2_add_user_id_to_blog_posts.rb → ...grate/20110803223523_add_user_id_to_blog_posts.rb
File renamed without changes
View
0  db/migrate/3_acts_as_taggable_on_migration.rb → ...e/20110803223524_acts_as_taggable_on_migration.rb
File renamed without changes
View
0  db/migrate/4_create_seo_meta_for_blog.rb → ...igrate/20110803223525_create_seo_meta_for_blog.rb
File renamed without changes
View
0  db/migrate/5_add_cached_slugs.rb → db/migrate/20110803223526_add_cached_slugs.rb
File renamed without changes
View
0  db/migrate/6_add_custom_url_field_to_blog_posts.rb → ...10803223527_add_custom_url_field_to_blog_posts.rb
File renamed without changes
View
0  ...igrate/7_add_custom_teaser_field_to_blog_posts.rb → ...03223528_add_custom_teaser_field_to_blog_posts.rb
File renamed without changes
View
0  db/migrate/8_add_primary_key_to_categorizations.rb → ...10803223529_add_primary_key_to_categorizations.rb
File renamed without changes
View
0  features/support/step_definitions/authors_steps.rb → features/step_definitions/authors_steps.rb
File renamed without changes
View
0  features/support/step_definitions/category_steps.rb → features/step_definitions/category_steps.rb
File renamed without changes
View
0  features/support/step_definitions/tags_steps.rb → features/step_definitions/tags_steps.rb
File renamed without changes
View
42 features/step_definitions/user_steps.rb
@@ -0,0 +1,42 @@
+def login(options = {})
+ options = {:user => @refinery_user}.merge(options)
+ visit new_refinery_user_session_path
+ fill_in("refinery_user_login", :with => options[:user].email)
+ fill_in("refinery_user_password", :with => 'greenandjuicy')
+ click_button("submit_button")
+end
+
+Given /^I am a logged in refinery user$/i do
+ @refinery_user ||= Factory(:refinery_user)
+ login(:user => @refinery_user)
+end
+
+Given /^I am a logged in refinery translator$/i do
+ @refinery_translator ||= Factory(:refinery_translator)
+ login(:user => @refinery_translator)
+end
+
+Given /^I am a logged in customer$/i do
+ @user ||= Factory(:user)
+ login(:user => @user)
+end
+
+Given /^A Refinery user exists$/i do
+ @refinery_user ||= Factory(:refinery_user)
+end
+
+Given /^I have a user named "(.*)"$/ do |name|
+ @user = Factory(:user, :username => name)
+end
+
+Given /^I have a refinery user named "(.*)"$/i do |name|
+ @refinery_user = Factory(:refinery_user, :username => name)
+end
+
+Given /^I have no users$/ do
+ ::Refinery::User.delete_all
+end
+
+Then /^I should have ([0-9]+) users?$/ do |count|
+ ::Refinery::User.count.should == count.to_i
+end
View
196 features/step_definitions/web_steps.rb
@@ -0,0 +1,196 @@
+# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
+# It is recommended to regenerate this file in the future when you upgrade to a
+# newer version of cucumber-rails. Consider adding your own code to a new file
+# instead of editing this one. Cucumber will automatically load all features/**/*.rb
+# files.
+
+require 'uri'
+require 'cgi'
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
+
+module WithinHelpers
+ def with_scope(locator)
+ locator ? within(*selector_for(locator)) { yield } : yield
+ end
+end
+World(WithinHelpers)
+
+# Single-line step scoper
+When /^(.*) within (.*[^:])$/ do |step, parent|
+ with_scope(parent) { When step }
+end
+
+# Multi-line step scoper
+When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
+ with_scope(parent) { When "#{step}:", table_or_string }
+end
+
+Given /^(?:|I )am on (.+)$/ do |page_name|
+ visit path_to(page_name)
+end
+
+When /^(?:|I )go to (.+)$/ do |page_name|
+ visit path_to(page_name)
+end
+
+When /^(?:|I )press "([^"]*)"$/ do |button|
+ click_button(button)
+end
+
+When /^(?:|I )follow "([^"]*)"$/ do |link|
+ click_link(link)
+end
+
+When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
+ fill_in(field, :with => value)
+end
+
+When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
+ fill_in(field, :with => value)
+end
+
+# Use this to fill in an entire form with data from a table. Example:
+#
+# When I fill in the following:
+# | Account Number | 5002 |
+# | Expiry date | 2009-11-01 |
+# | Note | Nice guy |
+# | Wants Email? | |
+#
+# TODO: Add support for checkbox, select og option
+# based on naming conventions.
+#
+When /^(?:|I )fill in the following:$/ do |fields|
+ fields.rows_hash.each do |name, value|
+ When %{I fill in "#{name}" with "#{value}"}
+ end
+end
+
+When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
+ select(value, :from => field)
+end
+
+When /^(?:|I )check "([^"]*)"$/ do |field|
+ check(field)
+end
+
+When /^(?:|I )uncheck "([^"]*)"$/ do |field|
+ uncheck(field)
+end
+
+When /^(?:|I )choose "([^"]*)"$/ do |field|
+ choose(field)
+end
+
+When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
+ attach_file(field, File.expand_path(path))
+end
+
+Then /^(?:|I )should see "([^"]*)"$/ do |text|
+ if page.respond_to? :should
+ page.should have_content(text)
+ else
+ assert page.has_content?(text)
+ end
+end
+
+Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
+ regexp = Regexp.new(regexp)
+
+ if page.respond_to? :should
+ page.should have_xpath('//*', :text => regexp)
+ else
+ assert page.has_xpath?('//*', :text => regexp)
+ end
+end
+
+Then /^(?:|I )should not see "([^"]*)"$/ do |text|
+ if page.respond_to? :should
+ page.should have_no_content(text)
+ else
+ assert page.has_no_content?(text)
+ end
+end
+
+Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
+ regexp = Regexp.new(regexp)
+
+ if page.respond_to? :should
+ page.should have_no_xpath('//*', :text => regexp)
+ else
+ assert page.has_no_xpath?('//*', :text => regexp)
+ end
+end
+
+Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
+ with_scope(parent) do
+ field = find_field(field)
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
+ if field_value.respond_to? :should
+ field_value.should =~ /#{value}/
+ else
+ assert_match(/#{value}/, field_value)
+ end
+ end
+end
+
+Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
+ with_scope(parent) do
+ field = find_field(field)
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
+ if field_value.respond_to? :should_not
+ field_value.should_not =~ /#{value}/
+ else
+ assert_no_match(/#{value}/, field_value)
+ end
+ end
+end
+
+Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
+ with_scope(parent) do
+ field_checked = find_field(label)['checked']
+ if field_checked.respond_to? :should
+ field_checked.should be_true
+ else
+ assert field_checked
+ end
+ end
+end
+
+Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
+ with_scope(parent) do
+ field_checked = find_field(label)['checked']
+ if field_checked.respond_to? :should
+ field_checked.should be_false
+ else
+ assert !field_checked
+ end
+ end
+end
+
+Then /^(?:|I )should be on (.+)$/ do |page_name|
+ current_path = URI.parse(current_url).path
+ if current_path.respond_to? :should
+ current_path.should == path_to(page_name)
+ else
+ assert_equal path_to(page_name), current_path
+ end
+end
+
+Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
+ query = URI.parse(current_url).query
+ actual_params = query ? CGI.parse(query) : {}
+ expected_params = {}
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
+
+ if actual_params.respond_to? :should
+ actual_params.should == expected_params
+ else
+ assert_equal expected_params, actual_params
+ end
+end
+
+Then /^show me the page$/ do
+ save_and_open_page
+end
View
50 features/support/env.rb
@@ -0,0 +1,50 @@
+require 'rubygems'
+require 'bundler/setup'
+require 'spork'
+
+Spork.prefork do
+ require 'cucumber/rails'
+ require 'capybara/rails'
+ require 'capybara/cucumber'
+ require 'capybara/session'
+
+ require 'factory_girl'
+ require 'database_cleaner'
+ require 'database_cleaner/cucumber'
+
+ Dir[File.expand_path("../../../spec/factories/*.rb", __FILE__)].each {|f| require f}
+
+ include ::Devise::Controllers::UrlHelpers
+
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
+ # order to ease the transition to Capybara we set the default here. If you'd
+ # prefer to use XPath just remove this line and adjust any selectors in your
+ # steps to use the XPath syntax.
+ Capybara.default_selector = :css
+
+ # By default, any exception happening in your Rails application will bubble up
+ # to Cucumber so that your scenario will fail. This is a different from how
+ # your application behaves in the production environment, where an error page will
+ # be rendered instead.
+ #
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
+ # exceptions and display an error page (just like when the app is running in production).
+ # Typical scenarios where you want to do this is when you test your error pages.
+ # There are two ways to allow Rails to rescue exceptions:
+ #
+ # 1) Tag your scenario (or feature) with @allow-rescue
+ #
+ # 2) Set the value below to true. Beware that doing this globally is not
+ # recommended as it will mask a lot of errors for you!
+ #
+ ActionController::Base.allow_rescue = false
+
+ DatabaseCleaner.strategy = :truncation
+
+ Before { DatabaseCleaner.start }
+ After { DatabaseCleaner.clean }
+end
+
+Spork.each_run do
+ # This code will be run each time you run your specs.
+end
View
34 features/support/paths.rb
@@ -1,24 +1,18 @@
-module NavigationHelpers
- module Refinery
- module Blog
- def path_to(page_name)
- case page_name
- when /the list of blog posts/
- refinery_admin_blog_posts_path
- when /the new blog posts? form/
- new_refinery_admin_blog_post_path
- else
- begin
- if page_name =~ /the blog post titled "?([^\"]*)"?/ and (page = BlogPost.find_by_title($1)).present?
- self.url_for(page.url)
- else
- nil
- end
- rescue
- nil
- end
- end
+def path_to(page_name)
+ case page_name
+ when /the list of blog posts/
+ refinery_admin_blog_posts_path
+ when /the new blog posts? form/
+ new_refinery_admin_blog_post_path
+ else
+ begin
+ if page_name =~ /the blog post titled "?([^\"]*)"?/ and (page = BlogPost.find_by_title($1)).present?
+ self.url_for(page.url)
+ else
+ nil
end
+ rescue
+ nil
end
end
end
View
39 features/support/selectors.rb
@@ -0,0 +1,39 @@
+module HtmlSelectorsHelpers
+ # Maps a name to a selector. Used primarily by the
+ #
+ # When /^(.+) within (.+)$/ do |step, scope|
+ #
+ # step definitions in web_steps.rb
+ #
+ def selector_for(locator)
+ case locator
+
+ when "the page"
+ "html > body"
+
+ # Add more mappings here.
+ # Here is an example that pulls values out of the Regexp:
+ #
+ # when /^the (notice|error|info) flash$/
+ # ".flash.#{$1}"
+
+ # You can also return an array to use a different selector
+ # type, like:
+ #
+ # when /the header/
+ # [:xpath, "//header"]
+
+ # This allows you to provide a quoted selector as the scope
+ # for "within" steps as was previously the default for the
+ # web steps:
+ when /^"(.+)"$/
+ $1
+
+ else
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
+ "Now, go and add a mapping in #{__FILE__}"
+ end
+ end
+end
+
+World(HtmlSelectorsHelpers)
View
21 lib/refinery/blog/engine.rb
@@ -0,0 +1,21 @@
+module Refinery
+ module Blog
+ class Engine < Rails::Engine
+ config.to_prepare do
+ require 'refinery/blog/tabs'
+ end
+
+ initializer "init plugin", :after => :set_routes_reloader do |app|
+ Refinery::Plugin.register do |plugin|
+ plugin.pathname = root
+ plugin.name = "refinerycms_blog"
+ plugin.url = app.routes.url_helpers.refinery_admin_blog_posts_path
+ plugin.menu_match = /^\/refinery\/blog\/?(posts|comments|categories)?/
+ plugin.activity = {
+ :class => Refinery::BlogPost
+ }
+ end
+ end
+ end
+ end
+end
View
28 lib/refinerycms-blog.rb
@@ -1,10 +1,14 @@
+require 'rubygems'
+require 'bundler'
+Bundler.require
+
require 'filters_spam'
require File.expand_path('../generators/blog_generator', __FILE__)
module Refinery
module Blog
- autoload :Version, File.expand_path('../refinery/blog/version', __FILE__)
- autoload :Tab, File.expand_path("../refinery/blog/tabs", __FILE__)
+ autoload :Version, 'refinery/blog/version'
+ autoload :Tab, 'refinery/blog/tabs'
class << self
attr_accessor :root
@@ -16,23 +20,7 @@ def version
::Refinery::Blog::Version.to_s
end
end
-
- class Engine < Rails::Engine
- config.to_prepare do
- require File.expand_path('../refinery/blog/tabs', __FILE__)
- end
-
- initializer "init plugin", :after => :set_routes_reloader do |app|
- Refinery::Plugin.register do |plugin|
- plugin.pathname = root
- plugin.name = "refinerycms_blog"
- plugin.url = app.routes.url_helpers.refinery_admin_blog_posts_path
- plugin.menu_match = /^\/refinery\/blog\/?(posts|comments|categories)?/
- plugin.activity = {
- :class => Refinery::BlogPost
- }
- end
- end
- end if defined?(Rails::Engine)
end
end
+
+require 'refinery/blog/engine' if defined?(Rails)
View
17 readme.md
@@ -27,4 +27,19 @@ Next, to install the blog plugin run:
Finally migrate your database and you're done.
- rake db:migrate
+ rake db:migrate
+
+## Developing & Contributing
+
+### Testing
+
+Setup the test environment
+
+ $ bundle install
+ $ bundle exec rake app:db:migrate
+ $ bundle exec rake app:db:test:prepare
+
+Run the test suite with [Guard](https://github.com/guard/guard)
+
+ $ bundle exec guard start
+
View
13 refinerycms-blog.gemspec
@@ -16,7 +16,20 @@ Gem::Specification.new do |s|
s.add_dependency 'seo_meta', '~> 1.1.0'
# Development dependencies
+ s.add_development_dependency 'rake', '~> 0.9.2'
+ s.add_development_dependency 'rails', '3.1.0.rc5'
s.add_development_dependency 'factory_girl'
+ s.add_development_dependency 'sqlite3'
+ s.add_development_dependency 'rspec'
+ s.add_development_dependency 'rspec-rails', '2.6.1.beta1'
+ s.add_development_dependency 'capybara'
+ s.add_development_dependency 'cucumber-rails'
+ s.add_development_dependency 'spork', '0.9.0.rc9'
+ s.add_development_dependency 'guard-spork'
+ s.add_development_dependency 'guard-rspec'
+ s.add_development_dependency 'guard-cucumber'
+ s.add_development_dependency 'rb-fsevent'
+ s.add_development_dependency 'database_cleaner'
s.files = %w(
app
View
10 script/cucumber
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+
+vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
+if vendored_cucumber_bin
+ load File.expand_path(vendored_cucumber_bin)
+else
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
+ require 'cucumber'
+ load Cucumber::BINARY
+end
View
6 script/rails
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+#!/usr/bin/env ruby
+# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
+
+ENGINE_PATH = File.expand_path('../..', __FILE__)
+load File.expand_path('../../spec/dummy/script/rails', __FILE__)
View
77 spec/dummy/.gitignore
@@ -0,0 +1,77 @@
+# Rails
+.bundle
+db/*.sqlite3
+db/*.sqlite3-journal
+*.log
+tmp
+tmp/**/*
+
+# Documentation
+doc/api
+doc/app
+.yardoc
+.yardopts
+coverage
+
+# Public Uploads
+public/system/*
+public/themes/*
+
+# Public Cache
+public/javascripts/cache
+public/stylesheets/cache
+
+# Vendor Cache
+vendor/cache
+
+# Acts as Indexed
+index/**/*
+
+# Refinery Specific
+*.tmproj
+*.autobackupbyrefinery.*
+refinerycms-*.gem
+.autotest
+
+# Mac
+.DS_Store
+
+# Windows
+Thumbs.db
+
+# NetBeans
+nbproject
+
+# Eclipse
+.project
+
+# Redcar
+.redcar
+
+# Rubinius
+*.rbc
+
+# Vim
+*.swp
+*.swo
+
+# RubyMine
+.idea
+
+# E-texteditor
+.eprj
+
+# Backup
+*~
+
+# Capybara Bug
+capybara-*html
+
+# sass
+.sass-cache
+.sass-cache/*
+
+#rvm
+.rvmrc
+.rvmrc.*
+
View
7 spec/dummy/Rakefile
@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+Dummy::Application.load_tasks
View
7 spec/dummy/app/assets/javascripts/admin.js
@@ -0,0 +1,7 @@
+// Use this to customize the wymeditor boot process
+// Just mirror the options specified in boot_wym.js with the new options here.
+// This will completely override anything specified in boot_wym.js for that key.
+// e.g. skin: 'something_else'
+var custom_wymeditor_boot_options = {
+
+};
View
9 spec/dummy/app/assets/javascripts/application.js
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
View
1  spec/dummy/app/assets/stylesheets/application.css
@@ -0,0 +1 @@
+
View
1  spec/dummy/app/assets/stylesheets/application.css.backup
@@ -0,0 +1 @@
+
View
4 spec/dummy/app/assets/stylesheets/formatting.css
@@ -0,0 +1,4 @@
+/*
+ Override default refinery formatting below.
+ Formatting applies to backend WYSIWYG editors and all frontend.
+*/
View
4 spec/dummy/app/assets/stylesheets/home.css
@@ -0,0 +1,4 @@
+/*
+ Override default refinery homepage styles here.
+ These only apply to the homepage of your site.
+*/
View
4 spec/dummy/app/assets/stylesheets/theme.css
@@ -0,0 +1,4 @@
+/*
+ Override default refinery 'theme' styles here.
+ These only apply when using custom WYMeditor CSS.
+*/
View
3  spec/dummy/app/controllers/application_controller.rb
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
View
2  spec/dummy/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
View
0  spec/dummy/app/mailers/.gitkeep
No changes.
View
0  spec/dummy/app/models/.gitkeep
No changes.
View
14 spec/dummy/app/views/layouts/application.html.erb.backup
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Dummy</title>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>
View
25 spec/dummy/app/views/sitemap/index.xml.builder
@@ -0,0 +1,25 @@
+xml.instruct!
+
+xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
+
+ @locales.each do |locale|
+ ::I18n.locale = locale
+ ::Refinery::Page.live.in_menu.includes(:parts).each do |page|
+ # exclude sites that are external to our own domain.
+ page_url = if page.url.is_a?(Hash)
+ # This is how most pages work without being overriden by link_url
+ page.url.merge({:only_path => false})
+ elsif page.url.to_s !~ /^http/
+ # handle relative link_url addresses.
+ [request.protocol, request.host_with_port, page.url].join
+ end
+
+ # Add XML entry only if there is a valid page_url found above.
+ xml.url do
+ xml.loc url_for(page_url)
+ xml.lastmod page.updated_at.to_date
+ end if page_url.present? and page.show_in_menu?
+ end
+ end
+
+end
View
17 spec/dummy/autotest/autotest.rb
@@ -0,0 +1,17 @@
+### uncomment any of the following requires applicable for your system
+### and then copy this to .autotest if you are using the ZenTest autotest.
+# require "autotest/restart"
+# require "test_notifier/runner/autotest"
+# require "redgreen/autotest"
+# require "autotest/timestamp"
+
+# adds exceptions from .gitignore file, please modify exceptions there!
+imported_exceptions = IO.readlines('.gitignore').inject([]) do |acc, line|
+ acc << line.strip if line.to_s[0] != '#' && line.strip != ''; acc
+end
+
+Autotest.add_hook :initialize do |autotest|
+ imported_exceptions.each do |exception|
+ autotest.add_exception(exception)
+ end
+end
View
2  spec/dummy/autotest/discover.rb
@@ -0,0 +1,2 @@
+Autotest.add_discovery { "rails" }
+Autotest.add_discovery { "rspec2" }
View
4 spec/dummy/config.ru
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Dummy::Application
View
42 spec/dummy/config/application.rb
@@ -0,0 +1,42 @@
+require File.expand_path('../boot', __FILE__)
+
+require 'rails/all'
+
+Bundler.require
+require "refinerycms-blog"
+
+module Dummy
+ class Application < Rails::Application
+ # Settings in config/environments/* take precedence over those specified here.
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory are automatically loaded.
+
+ # Custom directories with classes and modules you want to be autoloadable.
+ # config.autoload_paths += %W(#{config.root}/extras)
+
+ # Only load the plugins named here, in the order given (default is alphabetical).
+ # :all can be used as a placeholder for all plugins not explicitly named.
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+ # Activate observers that should always be running.
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
+ # config.time_zone = 'Central Time (US & Canada)'
+
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
+ # config.i18n.default_locale = :de
+
+ # Configure the default encoding used in templates for Ruby 1.9.
+ config.encoding = "utf-8"
+
+ # Configure sensitive parameters which will be filtered from the log file.
+ config.filter_parameters += [:password]
+
+ # Enable the asset pipeline
+ config.assets.enabled = true
+ end
+end
+
View
10 spec/dummy/config/boot.rb
@@ -0,0 +1,10 @@
+require 'rubygems'
+gemfile = File.expand_path('../../../../Gemfile', __FILE__)
+
+if File.exist?(gemfile)
+ ENV['BUNDLE_GEMFILE'] = gemfile
+ require 'bundler'
+ Bundler.setup
+end
+
+$:.unshift File.expand_path('../../../../lib', __FILE__)
View
25 spec/dummy/config/database.yml
@@ -0,0 +1,25 @@
+# SQLite version 3.x
+# gem install sqlite3
+#
+# Ensure the SQLite 3 gem is defined in your Gemfile
+# gem 'sqlite3'
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: sqlite3
+ database: db/test.sqlite3
+ pool: 5
+ timeout: 5000
+
+production:
+ adapter: sqlite3
+ database: db/production.sqlite3
+ pool: 5
+ timeout: 5000
View
20 spec/dummy/config/database.yml.mysql
@@ -0,0 +1,20 @@
+development: &development
+ adapter: mysql2
+ host: localhost
+ username: root
+ password:
+ database: your_local_database
+
+test: &test
+ adapter: mysql2
+ host: localhost
+ username: root
+ password:
+ database: your_test_database
+
+production: &production
+ adapter: mysql2
+ host: localhost
+ database: your_production_database
+ username: your_production_database_login
+ password: your_production_database_password
View
55 spec/dummy/config/database.yml.postgresql
@@ -0,0 +1,55 @@
+# PostgreSQL. Versions 7.4 and 8.x are supported.
+#
+# Install the pg driver:
+# gem install pg
+# On Mac OS X with macports:
+# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
+# On Windows:
+# gem install pg
+# Choose the win32 build.
+# Install PostgreSQL and put its /bin directory on your path.
+#
+# Configure Using Gemfile
+# gem 'pg'
+#
+development:
+ adapter: postgresql
+ encoding: unicode
+ database: refinery_database_development
+ pool: 5
+ username: postgres
+ password: postgres
+
+ # Connect on a TCP socket. Omitted by default since the client uses a
+ # domain socket that doesn't need configuration. Windows does not have
+ # domain sockets, so uncomment these lines.
+ #host: localhost
+ #port: 5432
+
+ # Schema search path. The server defaults to $user,public
+ #schema_search_path: myapp,sharedapp,public
+
+ # Minimum log levels, in increasing order:
+ # debug5, debug4, debug3, debug2, debug1,
+ # log, notice, warning, error, fatal, and panic
+ # The server defaults to notice.
+ #min_messages: warning
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+ adapter: postgresql
+ encoding: unicode
+ database: refinery_database_test
+ pool: 5
+ username: postgres
+ password: postgres
+
+production:
+ adapter: postgresql
+ encoding: unicode
+ database: refinery_database_production
+ pool: 5
+ username: postgres
+ password: postgres
View
26 spec/dummy/config/database.yml.sqlite3
@@ -0,0 +1,26 @@
+# SQLite version 3.x
+development:
+ adapter: <%= "jdbc" if defined?(JRUBY_PLATFORM) %>sqlite3
+ database: db/development.sqlite3
+ timeout: 5000
+
+# Warning: The database defined as 'test' will be erased and
+# re-generated from your development database when you run 'rake'.
+# Do not set this db to the same as development or production.
+test:
+ adapter: <%= "jdbc" if defined?(JRUBY_PLATFORM) %>sqlite3
+ database: db/test.sqlite3
+ timeout: 5000
+
+# Warning: The database defined as 'cucumber' will be erased and
+# re-generated from your development database when you run 'rake'.
+# Do not set this db to the same as development or production.
+cucumber:
+ adapter: <%= "jdbc" if defined?(JRUBY_PLATFORM) %>sqlite3
+ database: db/cucumber.sqlite3
+ timeout: 5000
+
+production:
+ adapter: <%= "jdbc" if defined?(JRUBY_PLATFORM) %>sqlite3
+ database: db/production.sqlite3
+ timeout: 5000
View
5 spec/dummy/config/environment.rb
@@ -0,0 +1,5 @@
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+Dummy::Application.initialize!
View
31 spec/dummy/config/environments/development.rb
@@ -0,0 +1,31 @@
+Dummy::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # In the development environment your application's code is reloaded on
+ # every request. This slows down response time but is perfect for development
+ # since you don't have to restart the web server when you make code changes.
+ config.cache_classes = false
+
+ # Log error messages when you accidentally call methods on nil.
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Don't care if the mailer can't send
+ config.action_mailer.raise_delivery_errors = false
+
+ # Print deprecation notices to the Rails logger
+ config.active_support.deprecation = :log
+
+ # Only use best-standards-support built into browsers
+ config.action_dispatch.best_standards_support = :builtin
+
+ # Do not compress assets
+ config.assets.compress = false
+end
+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?)
View
55 spec/dummy/config/environments/production.rb
@@ -0,0 +1,55 @@
+Dummy::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # Code is not reloaded between requests
+ config.cache_classes = true
+
+ # Full error reports are disabled and caching is turned on
+ config.consider_all_requests_local = false
+ config.action_controller.perform_caching = true
+
+ # Disable Rails's static asset server (Apache or nginx will already do this)
+ config.serve_static_assets = true # Refinery CMS requires this to be true
+
+ # Compress JavaScripts and CSS
+ config.assets.compress = true
+
+ # Specifies the header that your server uses for sending files
+ # (comment out if your front-end server doesn't support this)
+ config.action_dispatch.x_sendfile_header = "X-Sendfile" # Use 'X-Accel-Redirect' for nginx
+
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+ # config.force_ssl = true
+
+ # See everything in the log (default is :info)
+ # config.log_level = :debug
+
+ # Use a different logger for distributed setups
+ # config.logger = SyslogLogger.new
+
+ # Use a different cache store in production
+ # config.cache_store = :mem_cache_store
+
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
+ # config.action_controller.asset_host = "http://assets.example.com"
+
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
+ # config.assets.precompile += %w( search.js )
+
+ # Disable delivery errors, bad email addresses will be ignored
+ # config.action_mailer.raise_delivery_errors = false
+
+ # Enable threaded mode
+ # config.threadsafe!
+
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+ # the I18n.default_locale when a translation can not be found)
+ config.i18n.fallbacks = true
+
+ # Send deprecation notices to registered listeners
+ config.active_support.deprecation = :notify
+end
+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?)
View
43 spec/dummy/config/environments/test.rb
@@ -0,0 +1,43 @@
+Dummy::Application.configure do
+ # Settings specified here will take precedence over those in config/application.rb
+
+ # The test environment is used exclusively to run your application's
+ # test suite. You never need to work with it otherwise. Remember that
+ # your test database is "scratch space" for the test suite and is wiped
+ # and recreated between test runs. Don't rely on the data there!
+ config.cache_classes = false
+
+ # Configure static asset server for tests with Cache-Control for performance
+ config.serve_static_assets = true
+ config.static_cache_control = "public, max-age=3600"
+
+ # Log error messages when you accidentally call methods on nil
+ config.whiny_nils = true
+
+ # Show full error reports and disable caching
+ config.consider_all_requests_local = true
+ config.action_controller.perform_caching = false
+
+ # Raise exceptions instead of rendering exception templates
+ config.action_dispatch.show_exceptions = false
+
+ # Disable request forgery protection in test environment
+ config.action_controller.allow_forgery_protection = false
+
+ # Tell Action Mailer not to deliver emails to the real world.
+ # The :test delivery method accumulates sent emails in the
+ # ActionMailer::Base.deliveries array.
+ config.action_mailer.delivery_method = :test
+
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
+ # like if you have constraints or database-specific column types
+ # config.active_record.schema_format = :sql
+
+ # Print deprecation notices to the stderr
+ config.active_support.deprecation = :stderr
+end
+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?)
View
7 spec/dummy/config/initializers/backtrace_silencers.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!
View
144 spec/dummy/config/initializers/devise.rb
@@ -0,0 +1,144 @@
+require 'devise'
+
+# Use this hook to configure devise mailer, warden hooks and so forth. The first
+# four configuration values can also be set straight in your models.
+::Devise.setup do |config|
+ # ==> Mailer Configuration
+ # Configure the e-mail address which will be shown in DeviseMailer.
+ # config.mailer_sender = "please-change-me@config-initializers-devise.com"
+
+ # Configure the class responsible to send e-mails.
+ # config.mailer = "::Devise::Mailer"
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating an user. By default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating an user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ config.authentication_keys = [ :login ]
+
+ # Tell if authentication through request.params is enabled. True by default.
+ # config.params_authenticatable = true
+
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
+ # config.http_authenticatable = false
+
+ # Set this to true to use Basic Auth for AJAX requests. True by default.
+ # config.http_authenticatable_on_xhr = true
+
+ # The realm used in Http Basic Authentication
+ # config.http_authentication_realm = "Application"
+
+ # ==> Configuration for :database_authenticatable
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
+ # using other encryptors, it sets how many times you want the password re-encrypted.
+ # config.stretches = 20
+
+ # Define which will be the encryption algorithm. Devise also supports encryptors
+ # from others authentication tools as :clearance_sha1, :authlogic_sha512 (then
+ # you should set stretches above to 20 for default behavior) and :restful_authentication_sha1
+ # (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
+ # config.encryptor = :bcrypt
+
+ # Setup a pepper to generate the encrypted password.
+ # config.pepper = "2e20a8abdd34d729ba6d05f679e513cfea9fbb1e83c81f84b29e9e4fdbd4ee59b56a32200064082a15a72b05a4d4a6a2c3784a09c0554b3a47a67cc8333ccbc7"
+
+ # ==> Configuration for :confirmable
+ # The time you want to give your user to confirm his account. During this time
+ # he will be able to access your application without confirming. Default is nil.
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
+ # You can use this to let your user access some features of your application
+ # without confirming the account, but blocking it after a certain period
+ # (ie 2 days).
+ # config.confirm_within = 2.days
+
+ # ==> Configuration for :rememberable
+ # The time the user will be remembered without asking for credentials again.
+ # config.remember_for = 2.weeks
+
+ # If true, a valid remember token can be re-used between multiple browsers.
+ # config.remember_across_browsers = true
+
+ # If true, extends the user's remember period when remembered via cookie.
+ # config.extend_remember_period = false
+
+ # ==> Configuration for :validatable
+ # Range for password length
+ config.password_length = 4..20
+
+ # Regex to use to validate the email address
+ # config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
+
+ # ==> Configuration for :timeoutable
+ # The time you want to timeout the user session without activity. After this
+ # time the user will be asked for credentials again.
+ # config.timeout_in = 10.minutes
+
+ # ==> Configuration for :lockable
+ # Defines which strategy will be used to lock an account.
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+ # :none = No lock strategy. You should handle locking by yourself.
+ # config.lock_strategy = :failed_attempts
+
+ # Defines which strategy will be used to unlock an account.
+ # :email = Sends an unlock link to the user email
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :both = Enables both strategies
+ # :none = No unlock strategy. You should handle unlocking by yourself.
+ # config.unlock_strategy = :both
+
+ # Number of authentication tries before locking an account if lock_strategy
+ # is failed attempts.
+ # config.maximum_attempts = 20
+
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
+ # config.unlock_in = 1.hour
+
+ # ==> Configuration for :token_authenticatable
+ # Defines name of the authentication token params key
+ # config.token_authentication_key = :auth_token
+
+ # ==> Scopes configuration
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
+ # "users/sessions/new". It's turned off by default because it's slower if you
+ # are using only default views.
+ # config.scoped_views = true
+
+ # Configure the default scope given to Warden. By default it's the first
+ # devise role declared in your routes.
+ # config.default_scope = :user
+
+ # Configure sign_out behavior.
+ # By default sign_out is scoped (i.e. /users/sign_out affects only :user scope).
+ # In case of sign_out_all_scopes set to true any logout action will sign out all active scopes.
+ # config.sign_out_all_scopes = false
+
+ # ==> Navigation configuration
+ # Lists the formats that should be treated as navigational. Formats like
+ # :html, should redirect to the sign in page when the user does not have
+ # access, but formats like :xml or :json, should return 401.
+ # If you have any extra navigational formats, like :iphone or :mobile, you
+ # should add them to the navigational formats lists. Default is [:html]
+ # config.navigational_formats = [:html, :iphone]
+
+ # ==> Warden configuration
+ # If you want to use other strategies, that are not (yet) supported by Devise,
+ # you can configure them inside the config.warden block. The example below
+ # allows you to setup OAuth, using http://github.com/roman/warden_oauth
+ #
+ # config.warden do |manager|
+ # manager.oauth(:twitter) do |twitter|
+ # twitter.consumer_secret = <YOUR CONSUMER SECRET>
+ # twitter.consumer_key = <YOUR CONSUMER KEY>
+ # twitter.options :site => 'http://twitter.com'
+ # end
+ # manager.default_strategies(:scope => :user).unshift :twitter_oauth
+ # end
+end
View
10 spec/dummy/config/initializers/inflections.rb
@@ -0,0 +1,10 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+# inflect.plural /^(ox)$/i, '\1en'
+# inflect.singular /^(ox)en/i, '\1'
+# inflect.irregular 'person', 'people'
+# inflect.uncountable %w( fish sheep )
+# end
View
5 spec/dummy/config/initializers/mime_types.rb
@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone
View
7 spec/dummy/config/initializers/secret_token.rb
@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+Dummy::Application.config.secret_token = '75470fb2f9c361e0509af41d5835fdb3fee2e588a44c68596c6201976f994e0689c434b6e8360dbc45c0d424c1811a5cf1e3f4f0550be9b784fed60fb4e5d29d'
View
8 spec/dummy/config/initializers/session_store.rb
@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+# Dummy::Application.config.session_store :active_record_store
View
12 spec/dummy/config/initializers/wrap_parameters.rb
@@ -0,0 +1,12 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActionController::Base.wrap_parameters format: [:json]
+
+# Disable root element in JSON by default.
+if defined?(ActiveRecord)
+ ActiveRecord::Base.include_root_in_json = false
+end
View
5 spec/dummy/config/locales/en.yml
@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+ hello: "Hello world"
View
58 spec/dummy/config/routes.rb
@@ -0,0 +1,58 @@
+Dummy::Application.routes.draw do
+ # The priority is based upon order of creation:
+ # first created -> highest priority.
+
+ # Sample of regular route:
+ # match 'products/:id' => 'catalog#view'
+ # Keep in mind you can assign values other than :controller and :action
+
+ # Sample of named route:
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
+ # This route can be invoked with purchase_url(:id => product.id)
+
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
+ # resources :products
+
+ # Sample resource route with options:
+ # resources :products do
+ # member do
+ # get 'short'
+ # post 'toggle'
+ # end
+ #
+ # collection do
+ # get 'sold'
+ # end
+ # end
+
+ # Sample resource route with sub-resources:
+ # resources :products do
+ # resources :comments, :sales
+ # resource :seller
+ # end
+
+ # Sample resource route with more complex sub-resources
+ # resources :products do
+ # resources :comments
+ # resources :sales do
+ # get 'recent', :on => :collection
+ # end
+ # end
+
+ # Sample resource route within a namespace:
+ # namespace :admin do
+ # # Directs /admin/products/* to Admin::ProductsController
+ # # (app/controllers/admin/products_controller.rb)
+ # resources :products
+ # end
+
+ # You can have the root of your site routed with "root"
+ # just remember to delete public/index.html.
+ # root :to => 'welcome#index'
+
+ # See how all your routes lay out with "rake routes"
+
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
+ # Note: This route will make all actions in every controller accessible via GET requests.
+ # match ':controller(/:action(/:id(.:format)))'
+end
View
23 spec/dummy/db/migrate/20110802081556_create_refinerycms_core_schema.rb
@@ -0,0 +1,23 @@
+class CreateRefinerycmsCoreSchema < ActiveRecord::Migration
+ def self.up
+ create_table ::Slug.table_name, :force => true do |t|
+ t.string "name"
+ t.integer "sluggable_id"
+ t.integer "sequence", :default => 1, :null => false
+ t.string "sluggable_type", :limit => 40
+ t.string "scope", :limit => 40
+ t.datetime "created_at"
+ end
+
+ add_index ::Slug.table_name, ["name", "sluggable_type", "scope", "sequence"], :name => "index_#{::Slug.table_name}_on_n_s_s_and_s", :unique => true
+ add_index ::Slug.table_name, ["sluggable_id"], :name => "index_#{::Slug.table_name}_on_sluggable_id"
+ end
+
+ def self.down
+ [::Slug].reject{|m|
+ !(defined?(m) and m.respond_to?(:table_name))
+ }.each do |model|
+ drop_table model.table_name
+ end
+ end
+end
View
13 spec/dummy/db/migrate/20110802081557_add_locale_to_slugs.rb
@@ -0,0 +1,13 @@
+class AddLocaleToSlugs < ActiveRecord::Migration
+ def self.up
+ add_column ::Slug.table_name, :locale, :string
+
+ add_index ::Slug.table_name, :locale
+ end
+
+ def self.down
+ remove_column ::Slug.table_name, :locale
+
+ remove_index ::Slug.table_name, :locale
+ end
+end
View
24 spec/dummy/db/migrate/20110802081558_create_refinerycms_settings_schema.rb
@@ -0,0 +1,24 @@
+class CreateRefinerycmsSettingsSchema < ActiveRecord::Migration
+ def self.up
+ create_table ::Refinery::Setting.table_name, :force => true do |t|
+ t.string "name"
+ t.text "value"
+ t.boolean "destroyable", :default => true
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "scoping"
+ t.boolean "restricted", :default => false
+ t.string "callback_proc_as_string"
+ end
+
+ add_index ::Refinery::Setting.table_name, ["name"], :name => "index_#{::Refinery::Setting.table_name}_on_name"
+ end
+
+ def self.down
+ [::Refinery::Setting].reject{|m|
+ !(defined?(m) and m.respond_to?(:table_name))
+ }.each do |model|
+ drop_table model.table_name
+ end
+ end
+end
View
9 spec/dummy/db/migrate/20110802081559_add_value_type_to_refinery_settings.rb
@@ -0,0 +1,9 @@
+class AddValueTypeToRefinerySettings < ActiveRecord::Migration
+ def self.up
+ add_column ::Refinery::Setting.table_name, :form_value_type, :string
+ end
+
+ def self.down
+ remove_column ::Refinery::Setting.table_name, :form_value_type
+ end
+end
View
48 spec/dummy/db/migrate/20110802081560_create_refinerycms_authentication_schema.rb
@@ -0,0 +1,48 @@
+class CreateRefinerycmsAuthenticationSchema < ActiveRecord::Migration
+ def self.up
+ # Postgres apparently requires the roles_users table to exist before creating the roles table.
+ create_table ::Refinery::RolesUsers.table_name, :id => false, :force => true do |t|
+ t.integer "user_id"
+ t.integer "role_id"
+ end unless ::Refinery::RolesUsers.table_exists?
+
+ create_table ::Refinery::Role.table_name, :force => true do |t|
+ t.string "title"
+ end unless ::Refinery::Role.table_exists?
+
+ unless ::Refinery::UserPlugin.table_exists?
+ create_table ::Refinery::UserPlugin.table_name, :force => true do |t|
+ t.integer "user_id"
+ t.string "name"
+ t.integer "position"
+ end
+
+ add_index ::Refinery::UserPlugin.table_name, ["name"], :name => "index_#{::Refinery::UserPlugin.table_name}_on_title"
+ add_index ::Refinery::UserPlugin.table_name, ["user_id", "name"], :name => "index_unique_#{::Refinery::UserPlugin.table_name}", :unique => true
+
+ end
+
+ unless ::Refinery::User.table_exists?
+ create_table ::Refinery::User.table_name, :force => true do |t|
+ t.string "login", :null => false
+ t.string "email", :null => false
+ t.string "crypted_password", :null => false
+ t.string "password_salt", :null => false
+ t.string "persistence_token"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "perishable_token"
+ end
+
+ add_index ::Refinery::User.table_name, ["id"], :name => "index_#{::Refinery::User.table_name}_on_id"
+ end
+ end
+
+ def self.down
+ [::User].reject{|m|
+ !(defined?(m) and m.respond_to?(:table_name))
+ }.each do |model|
+ drop_table model.table_name if model.table_exists? if model.table_exists?
+ end
+ end
+end
View
11 spec/dummy/db/migrate/20110802081561_add_missing_indexes_to_roles_users.rb
@@ -0,0 +1,11 @@
+class AddMissingIndexesToRolesUsers < ActiveRecord::Migration
+ def self.up
+ add_index ::Refinery::RolesUsers.table_name, [:role_id, :user_id]
+ add_index ::Refinery::RolesUsers.table_name, [:user_id, :role_id]
+ end
+
+ def self.down
+ remove_index ::Refinery::RolesUsers.table_name, :column => [:role_id, :user_id]
+ remove_index ::Refinery::RolesUsers.table_name, :column => [:user_id, :role_id]
+ end
+end
View
31 spec/dummy/db/migrate/20110802081562_change_to_devise_users_table.rb
@@ -0,0 +1,31 @@
+class ChangeToDeviseUsersTable < ActiveRecord::Migration
+ def self.up
+ add_column ::Refinery::User.table_name, :current_sign_in_at, :datetime
+ add_column ::Refinery::User.table_name, :last_sign_in_at, :datetime
+ add_column ::Refinery::User.table_name, :current_sign_in_ip, :string
+ add_column ::Refinery::User.table_name, :last_sign_in_ip, :string
+ add_column ::Refinery::User.table_name, :sign_in_count, :integer
+ add_column ::Refinery::User.table_name, :remember_token, :string
+ add_column ::Refinery::User.table_name, :reset_password_token, :string
+
+ rename_column ::Refinery::User.table_name, :crypted_password, :encrypted_password
+ rename_column ::Refinery::User.table_name, :login, :username
+
+ ::Refinery::User.reset_column_information
+ end
+
+ def self.down
+ remove_column ::Refinery::User.table_name, :current_sign_in_at
+ remove_column ::Refinery::User.table_name, :last_sign_in_at
+ remove_column ::Refinery::User.table_name, :current_sign_in_ip
+ remove_column ::Refinery::User.table_name, :last_sign_in_ip
+ remove_column ::Refinery::User.table_name, :sign_in_count
+ remove_column ::Refinery::User.table_name, :remember_token
+ remove_column ::Refinery::User.table_name, :reset_password_token
+
+ rename_column ::Refinery::User.table_name, :encrypted_password, :crypted_password
+ rename_column ::Refinery::User.table_name, :username, :login
+
+ ::Refinery::User.reset_column_information
+ end
+end
View
5 spec/dummy/db/migrate/20110802081563_add_remember_created_at_to_users.rb
@@ -0,0 +1,5 @@
+class AddRememberCreatedAtToUsers < ActiveRecord::Migration
+ def change
+ add_column ::Refinery::User.table_name, :remember_created_at, :datetime
+ end
+end
View
13 spec/dummy/db/migrate/20110802081564_remove_password_salt_from_users.rb
@@ -0,0 +1,13 @@
+class RemovePasswordSaltFromUsers < ActiveRecord::Migration
+ def self.up
+ remove_column ::Refinery::User.table_name, :password_salt
+ # Make the current password invalid :(
+ ::Refinery::User.all.each do |u|
+ u.update_attribute(:encrypted_password, u.encrypted_password[29..-1])
+ end
+ end
+
+ def self.down
+ add_column ::Refinery::User.table_name, :password_salt, :string
+ end
+end
View
23 spec/dummy/db/migrate/20110802081565_create_refinerycms_images_schema.rb
@@ -0,0 +1,23 @@
+class CreateRefinerycmsImagesSchema < ActiveRecord::Migration
+ def self.up
+ create_table ::Refinery::Image.table_name, :force => true do |t|
+ t.string "image_mime_type"
+ t.string "image_name"
+ t.integer "image_size"
+ t.integer "image_width"
+ t.integer "image_height"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "image_uid"
+ t.string "image_ext"
+ end unless ::Refinery::Image.table_exists?
+ end
+
+ def self.down
+ [::Image].reject{|m|
+ !(defined?(m) and m.respond_to?(:table_name))
+ }.each do |model|
+ drop_table model.table_name if model.table_exists?
+ end
+ end
+end
View
56 spec/dummy/db/migrate/20110802081566_create_refinerycms_pages_schema.rb
@@ -0,0 +1,56 @@
+class CreateRefinerycmsPagesSchema < ActiveRecord::Migration
+ def self.up
+ unless ::Refinery::PagePart.table_exists?
+ create_table ::Refinery::PagePart.table_name, :force => true do |t|
+ t.integer "refinery_page_id"
+ t.string "title"
+ t.text "body"
+ t.integer "position"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index ::Refinery::PagePart.table_name, ["id"], :name => "index_#{::Refinery::PagePart.table_name}_on_id"
+ add_index ::Refinery::PagePart.table_name, ["refinery_page_id"], :name => "index_#{::Refinery::PagePart.table_name}_on_page_id"
+ end
+
+ unless ::Refinery::Page.table_exists?
+ create_table ::Refinery::Page.table_name, :force => true do |t|
+ t.string "title"
+ t.integer "parent_id"
+ t.integer "position"
+ t.string "path"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "meta_keywords"
+ t.text "meta_description"
+ t.boolean "show_in_menu", :default => true
+ t.string "link_url"
+ t.string "menu_match"
+ t.boolean "deletable", :default => true
+ t.string "custom_title"
+ t.string "custom_title_type", :default => "none"
+ t.boolean "draft", :default => false
+ t.string "browser_title"
+ t.boolean "skip_to_first_child", :default => false
+ t.integer "lft"
+ t.integer "rgt"
+ t.integer "depth"
+ end
+
+ add_index ::Refinery::Page.table_name, ["depth"], :name => "index_#{::Refinery::Page.table_name}_on_depth"
+ add_index ::Refinery::Page.table_name, ["id"], :name => "index_#{::Refinery::Page.table_name}_on_id"
+ add_index ::Refinery::Page.table_name, ["lft"], :name => "index_#{::Refinery::Page.table_name}_on_lft"
+ add_index ::Refinery::Page.table_name, ["parent_id"], :name => "index_#{::Refinery::Page.table_name}_on_parent_id"
+ add_index ::Refinery::Page.table_name, ["rgt"], :name => "index_#{::Refinery::Page.table_name}_on_rgt"
+ end
+ end
+
+ def self.down
+ [::Page, ::Refinery::PagePart].reject{|m|
+ !(defined?(m) and m.respond_to?(:table_name))
+ }.each do |model|
+ drop_table model.table_name if model.table_exists?
+ end
+ end
+end
View
38 spec/dummy/db/migrate/20110802081567_translate_page_plugin.rb
@@ -0,0 +1,38 @@
+class TranslatePagePlugin < ActiveRecord::Migration
+ def self.up
+ say_with_time("Creating ::Refinery::PagePart translation table") do
+ ::Refinery::PagePart.create_translation_table!({
+ :body => :text
+ }, {
+ :migrate_data => true
+ })
+ end
+
+ say_with_time("Creating ::Refinery::Page translation table") do
+ ::Refinery::Page.create_translation_table!({
+ :title => :string,
+ :meta_keywords => :string,
+ :meta_description => :text,
+ :browser_title => :string
+ }, {
+ :migrate_data => true
+ })
+ end
+
+ puts "seeds pages"
+ if (seed_file = Rails.root.join('db', 'seeds', 'pages.rb')).file?
+ load seed_file.to_s unless ::Refinery::Page.where(:link_url => '/').any?
+ end
+
+ say_with_time("Updating slugs") do
+ ::Slug.update_all(:locale => I18n.locale)
+ end
+ end
+
+ def self.down
+ say_with_time("Dropping ::Refinery::Page and ::Refinery::PagePart translation tables") do
+ ::Refinery::Page.drop_translation_table! :migrate_data => true
+ ::Refinery::PagePart.drop_translation_table! :migrate_data => true
+ end
+ end
+end
View
11 spec/dummy/db/migrate/20110802081568_remove_cached_slug_from_pages.rb
@@ -0,0 +1,11 @@
+class RemoveCachedSlugFromPages < ActiveRecord::Migration
+ def self.up
+ if ::Refinery::Page.column_names.map(&:to_s).include?('cached_slug')
+ remove_column ::Refinery::Page.table_name, :cached_slug
+ end
+ end
+
+ def self.down
+ # Don't add this column back, it breaks stuff.
+ end
+end
View
26 spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb
@@ -0,0 +1,26 @@
+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
+
+ # Re-save custom_title
+ ::Refinery::Page.all.each do |page|
+ page.update_attribute(:custom_title, page.untranslated_attributes['custom_title'])
+ end
+
+ end
+ end
+
+ def self.down
+ # Re-save custom_title
+ ::Refinery::Page.all.each do |page|
+ ::Refinery::Page.update_all({
+ :custom_title => page.attributes['custom_title']
+ }, {
+ :id => page.id.to_s
+ }) unless page.attributes['custom_title'].nil?
+ end
+
+ remove_column ::Refinery::Page.translation_class.table_name, :custom_title
+ end
+end
View
13 spec/dummy/db/migrate/20110802081570_remove_translated_fields_from_pages.rb
@@ -0,0 +1,13 @@
+class RemoveTranslatedFieldsFromPages < ActiveRecord::Migration
+ def self.up
+ ::Refinery::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
+ remove_column ::Refinery::Page.table_name, column_name if ::Refinery::Page.column_names.map(&:to_sym).include?(column_name)
+ end
+ end
+
+ def self.down
+ ::Refinery::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
+ add_column ::Refinery::Page.table_name, column_name, Page::Translation.columns.detect{|c| c.name.to_sym == column_name}.type
+ end
+ end
+end
View
86 spec/dummy/db/migrate/20110802081571_create_seo_meta.rb
@@ -0,0 +1,86 @@
+class CreateSeoMeta < ActiveRecord::Migration
+
+ def self.up
+ create_table :seo_meta do |t|
+ t.integer :seo_meta_id
+ t.string :seo_meta_type
+
+ t.string :browser_title
+ t.string :meta_keywords
+ t.text :meta_description
+
+ t.timestamps
+ end
+
+ add_index :seo_meta, :id
+ add_index :seo_meta, [:seo_meta_id, :seo_meta_type]
+
+ # Grab the attributes of the records that currently exist
+ existing_translations = ::Refinery::Page.translation_class.all.map(&:attributes)
+
+ # Remove columns
+ ::SeoMeta.attributes.keys.each do |field|
+ if ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(field)
+ remove_column ::Refinery::Page.translation_class.table_name, field
+ end
+ end
+
+ # Reset column information because otherwise the old columns will still exist.
+ ::Refinery::Page.translation_class.reset_column_information
+
+ # Re-attach seo_meta
+ ::Refinery::Page.translation_class.send :is_seo_meta
+
+ # Migrate data
+ existing_translations.each do |translation|
+ ::Refinery::Page.translation_class.find(translation['id']).update_attributes(
+ ::SeoMeta.attributes.keys.inject({}) {|attributes, name|
+ attributes.merge(name => translation[name.to_s])
+ }
+ )
+ end
+
+ # Reset column information again because otherwise the old columns will still exist.
+ ::Refinery::Page.reset_column_information
+ end
+
+ def self.down
+ # Grab the attributes of the records that currently exist
+ existing_translations = ::Refinery::Page.translation_class.all.map(&:attributes)
+
+ # Add columns back to your model
+ ::SeoMeta.attributes.each do |field, field_type|
+ unless ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(field)
+ add_column ::Refinery::Page.translation_class.table_name, field, field_type
+ end
+ end
+
+ # Reset column information because otherwise the new columns won't exist yet.
+ ::Refinery::Page.translation_class.reset_column_information
+
+ # Migrate data
+ existing_translations.each do |translation|
+ ::Refinery::Page.translation_class.update_all(
+ ::SeoMeta.attributes.keys.inject({}) {|attributes, name|
+ attributes.merge(name => translation[name.to_s])
+ }, :id => translation['id']
+ )
+ end
+
+ ::SeoMeta.attributes.keys.each do |k|
+ ::Refinery::Page.translation_class.module_eval %{
+ def #{k}
+ end
+
+ def #{k}=(*args)
+ end
+ }
+ end
+
+ # Reset column information again because otherwise the old columns will still exist.
+ ::Refinery::Page.reset_column_information
+
+ drop_table :seo_meta
+ end
+
+end
View
11 spec/dummy/db/migrate/20110802081572_create_add_template_columns.rb
@@ -0,0 +1,11 @@
+class CreateAddTemplateColumns < ActiveRecord::Migration
+ def self.up
+ add_column ::Refinery::Page.table_name, :view_template, :string
+ add_column ::Refinery::Page.table_name, :layout_template, :string
+ end
+
+ def self.down
+ remove_column ::Refinery::Page.table_name, :layout_template
+ remove_column ::Refinery::Page.table_name, :view_template
+ end
+end
View
21 spec/dummy/db/migrate/20110802081573_create_refinerycms_resources_schema.rb
@@ -0,0 +1,21 @@
+class CreateRefinerycmsResourcesSchema < ActiveRecord::Migration
+ def self.up
+ create_table ::Refinery::Resource.table_name, :force => true do |t|
+ t.string "file_mime_type"
+ t.string "file_name"
+ t.integer "file_size"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "file_uid"
+ t.string "file_ext"
+ end unless ::Refinery::Resource.table_exists?
+ end
+
+ def self.down
+ [::Resource].reject{|m|
+ !(defined?(m) and m.respond_to?(:table_name))
+ }.each do |model|
+ drop_table model.table_name if model.table_exists?
+ end
+ end
+end
View
239 spec/dummy/db/schema.rb
@@ -0,0 +1,239 @@
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 20110803223529) do
+
+ create_table "refinery_blog_categories", :force => true do |t|
+ t.string "title"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "cached_slug"
+ end
+
+ add_index "refinery_blog_categories", ["id"], :name => "index_refinery_blog_categories_on_id"
+
+ create_table "refinery_blog_categories_blog_posts", :force => true do |t|
+ t.integer "blog_category_id"
+ t.integer "blog_post_id"
+ end
+
+ add_index "refinery_blog_categories_blog_posts", ["blog_category_id", "blog_post_id"], :name => "index_blog_categories_blog_posts_on_bc_and_bp"
+
+ create_table "refinery_blog_comments", :force => true do |t|
+ t.integer "blog_post_id"
+ t.boolean "spam"
+ t.string "name"
+ t.string "email"
+ t.text "body"
+ t.string "state"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "refinery_blog_comments", ["id"], :name => "index_refinery_blog_comments_on_id"
+
+ create_table "refinery_blog_posts", :force => true do |t|
+ t.string "title"
+ t.text "body"
+ t.boolean "draft"
+ t.datetime "published_at"
+ 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 "refinery_blog_posts", ["id"], :name => "index_refinery_blog_posts_on_id"
+
+ create_table "refinery_images", :force => true do |t|
+ t.string "image_mime_type"
+ t.string "image_name"
+ t.integer "image_size"
+ t.integer "image_width"
+ t.integer "image_height"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "image_uid"
+ t.string "image_ext"
+ end
+
+ create_table "refinery_page_part_translations", :force => true do |t|
+ t.integer "refinery_page_part_id"
+ t.string "locale"
+ t.text "body"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "refinery_page_part_translations", ["refinery_page_part_id"], :name => "index_f9716c4215584edbca2557e32706a5ae084a15ef"
+
+ create_table "refinery_page_parts", :force => true do |t|
+ t.integer "refinery_page_id"
+ t.string "title"
+ t.text "body"
+ t.integer "position"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "refinery_page_parts", ["id"], :name => "index_refinery_page_parts_on_id"
+ add_index "refinery_page_parts", ["refinery_page_id"], :name => "index_refinery_page_parts_on_page_id"
+
+ create_table "refinery_page_translations", :force => true do |t|
+ t.integer "refinery_page_id"
+ t.string "locale"
+ t.string "title"
+ t.string "custom_title"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "refinery_page_translations", ["refinery_page_id"], :name => "index_d079468f88bff1c6ea81573a0d019ba8bf5c2902"
+
+ create_table "refinery_pages", :force => true do |t|
+ t.integer "parent_id"
+ t.integer "position"
+ t.string "path"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.boolean "show_in_menu", :default => true
+ t.string "link_url"
+ t.string "menu_match"
+ t.boolean "deletable", :default => true
+ t.string "custom_title_type", :default => "none"
+ t.boolean "draft", :default => false
+ t.boolean "skip_to_first_child", :default => false
+ t.integer "lft"
+ t.integer "rgt"
+ t.integer "depth"
+ t.string "view_template"
+ t.string "layout_template"
+ end
+
+ add_index "refinery_pages", ["depth"], :name => "index_refinery_pages_on_depth"
+ add_index "refinery_pages", ["id"], :name => "index_refinery_pages_on_id"
+ add_index "refinery_pages", ["lft"], :name => "index_refinery_pages_on_lft"
+ add_index "refinery_pages", ["parent_id"], :name => "index_refinery_pages_on_parent_id"
+ add_index "refinery_pages", ["rgt"], :name => "index_refinery_pages_on_rgt"
+
+ create_table "refinery_resources", :force => true do |t|
+ t.string "file_mime_type"
+ t.string "file_name"
+ t.integer "file_size"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "file_uid"
+ t.string "file_ext"
+ end
+
+ create_table "refinery_roles", :force => true do |t|
+ t.string "title"
+ end
+
+ create_table "refinery_roles_users", :id => false, :force => true do |t|
+ t.integer "user_id"
+ t.integer "role_id"
+ end
+
+ add_index "refinery_roles_users", ["role_id", "user_id"], :name => "index_refinery_roles_users_on_role_id_and_user_id"
+ add_index "refinery_roles_users", ["user_id", "role_id"], :name => "index_refinery_roles_users_on_user_id_and_role_id"
+
+ create_table "refinery_settings", :force => true do |t|
+ t.string "name"
+ t.text "value"
+ t.boolean "destroyable", :default => true
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "scoping"
+ t.boolean "restricted", :default => false
+ t.string "callback_proc_as_string"
+ t.string "form_value_type"
+ end
+
+ add_index "refinery_settings", ["name"], :name => "index_refinery_settings_on_name"
+
+ create_table "refinery_user_plugins", :force => true do |t|
+ t.integer "user_id"
+ t.string "name"
+ t.integer "position"
+ end
+
+ add_index "refinery_user_plugins", ["name"], :name => "index_refinery_user_plugins_on_title"
+ add_index "refinery_user_plugins", ["user_id", "name"], :name => "index_unique_refinery_user_plugins", :unique => true
+
+ create_table "refinery_users", :force => true do |t|
+ t.string "username", :null => false
+ t.string "email", :null => false
+ t.string "encrypted_password", :null => false
+ t.string "persistence_token"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "perishable_token"
+ t.datetime "current_sign_in_at"
+ t.datetime "last_sign_in_at"
+ t.string "current_sign_in_ip"
+ t.string "last_sign_in_ip"
+ t.integer "sign_in_count"
+ t.string "remember_token"
+ t.string "reset_password_token"
+ t.datetime "remember_created_at"
+ end
+
+ add_index "refinery_users", ["id"], :name => "index_refinery_users_on_id"
+
+ create_table "seo_meta", :force => true do |t|
+ t.integer "seo_meta_id"
+ t.string "seo_meta_type"
+ t.string "browser_title"
+ t.string "meta_keywords"
+ t.text "meta_description"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "seo_meta", ["id"], :name => "index_seo_meta_on_id"
+ add_index "seo_meta", ["seo_meta_id", "seo_meta_type"], :name => "index_seo_meta_on_seo_meta_id_and_seo_meta_type"
+
+ create_table "slugs", :force => true do |t|
+ t.string "name"
+ t.integer "sluggable_id"
+ t.integer "sequence", :default => 1, :null => false
+ t.string "sluggable_type", :limit => 40
+ t.string "scope", :limit => 40
+ t.datetime "created_at"
+ t.string "locale"
+ end
+
+ add_index "slugs", ["locale"], :name => "index_slugs_on_locale"
+ add_index "slugs", ["name", "sluggable_type", "scope", "sequence"], :name => "index_slugs_on_n_s_s_and_s", :unique => true
+ add_index "slugs", ["sluggable_id"], :name => "index_slugs_on_sluggable_id"
+
+ create_table "taggings", :force => true do |t|
+ t.integer "tag_id"