From 9ae013ae3cc264b98964701507242fd19d2dcd96 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 22 Jan 2013 23:01:51 -0200 Subject: [PATCH] Updating test app running rake rails:update, tests running with failures --- Gemfile | 1 + Gemfile.lock | 3 + lib/devise/rails/routes.rb | 4 +- test/rails_app/Rakefile | 4 - test/rails_app/bin/bundle | 3 + test/rails_app/bin/rails | 4 + test/rails_app/bin/rake | 4 + test/rails_app/config/application.rb | 1 - test/rails_app/config/boot.rb | 6 +- test/rails_app/config/environment.rb | 4 +- .../config/environments/development.rb | 30 +++++-- .../config/environments/production.rb | 87 +++++++++++++++---- test/rails_app/config/environments/test.rb | 33 +++---- .../config/initializers/secret_token.rb | 3 +- .../config/initializers/session_store.rb | 1 + test/rails_app/script/rails | 10 --- 16 files changed, 134 insertions(+), 64 deletions(-) create mode 100755 test/rails_app/bin/bundle create mode 100755 test/rails_app/bin/rails create mode 100755 test/rails_app/bin/rake create mode 100644 test/rails_app/config/initializers/session_store.rb delete mode 100755 test/rails_app/script/rails diff --git a/Gemfile b/Gemfile index 542d0484..2bbcda50 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source "http://rubygems.org" gemspec gem "rails", "~> 4.0.0.beta", github: "rails/rails", branch: "master" +gem "protected_attributes", "~> 1.0.0" gem "omniauth", "~> 1.0.0" gem "omniauth-oauth2", "~> 1.0.0" gem "rdoc" diff --git a/Gemfile.lock b/Gemfile.lock index fa8bbb74..209a593e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -112,6 +112,8 @@ GEM origin (1.0.11) orm_adapter (0.4.0) polyglot (0.3.3) + protected_attributes (1.0.0) + activemodel (>= 4.0.0.beta, < 5.0) rack (1.5.2) rack-openid (1.3.1) rack (>= 1.1.0) @@ -161,6 +163,7 @@ DEPENDENCIES omniauth-facebook omniauth-oauth2 (~> 1.0.0) omniauth-openid (~> 1.0.1) + protected_attributes (~> 1.0.0) rails (~> 4.0.0.beta)! rdoc sqlite3 diff --git a/lib/devise/rails/routes.rb b/lib/devise/rails/routes.rb index 605e2718..2d06cbf2 100644 --- a/lib/devise/rails/routes.rb +++ b/lib/devise/rails/routes.rb @@ -398,13 +398,13 @@ module ActionDispatch::Routing providers = Regexp.union(mapping.to.omniauth_providers.map(&:to_s)) - match "#{path_prefix}/:provider", + get "#{path_prefix}/:provider", :constraints => { :provider => providers }, :to => "#{controllers[:omniauth_callbacks]}#passthru", :as => :omniauth_authorize, :via => [:get, :post] - match "#{path_prefix}/:action/callback", + get "#{path_prefix}/:action/callback", :constraints => { :action => providers }, :to => controllers[:omniauth_callbacks], :as => :omniauth_callback, diff --git a/test/rails_app/Rakefile b/test/rails_app/Rakefile index f47ab4d5..ba6b733d 100644 --- a/test/rails_app/Rakefile +++ b/test/rails_app/Rakefile @@ -3,8 +3,4 @@ require File.expand_path('../config/application', __FILE__) -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - Rails.application.load_tasks diff --git a/test/rails_app/bin/bundle b/test/rails_app/bin/bundle new file mode 100755 index 00000000..66e9889e --- /dev/null +++ b/test/rails_app/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test/rails_app/bin/rails b/test/rails_app/bin/rails new file mode 100755 index 00000000..728cd85a --- /dev/null +++ b/test/rails_app/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test/rails_app/bin/rake b/test/rails_app/bin/rake new file mode 100755 index 00000000..17240489 --- /dev/null +++ b/test/rails_app/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test/rails_app/config/application.rb b/test/rails_app/config/application.rb index ecafba8d..d1e30db8 100644 --- a/test/rails_app/config/application.rb +++ b/test/rails_app/config/application.rb @@ -2,7 +2,6 @@ require File.expand_path('../boot', __FILE__) require "action_controller/railtie" require "action_mailer/railtie" -require "active_resource/railtie" require "rails/test_unit/railtie" Bundler.require :default, DEVISE_ORM diff --git a/test/rails_app/config/boot.rb b/test/rails_app/config/boot.rb index ced57d00..d0ab1394 100644 --- a/test/rails_app/config/boot.rb +++ b/test/rails_app/config/boot.rb @@ -2,7 +2,7 @@ unless defined?(DEVISE_ORM) DEVISE_ORM = (ENV["DEVISE_ORM"] || :active_record).to_sym end -require 'rubygems' -require 'bundler/setup' +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) -$:.unshift File.expand_path('../../../../lib', __FILE__) \ No newline at end of file +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/test/rails_app/config/environment.rb b/test/rails_app/config/environment.rb index cb86aabf..1fe685fd 100644 --- a/test/rails_app/config/environment.rb +++ b/test/rails_app/config/environment.rb @@ -1,5 +1,5 @@ -# Load the rails application +# Load the rails application. require File.expand_path('../application', __FILE__) -# Initialize the rails application +# Initialize the rails application. RailsApp::Application.initialize! diff --git a/test/rails_app/config/environments/development.rb b/test/rails_app/config/environments/development.rb index bc251f75..f7cea6d5 100644 --- a/test/rails_app/config/environments/development.rb +++ b/test/rails_app/config/environments/development.rb @@ -1,18 +1,34 @@ RailsApp::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb + # 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 webserver when you make code changes. + # 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 + # Do not eager load code on boot. + config.eager_load = false - # Show full error reports and disable caching + # 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 + # 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 + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL). + config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Raise an error on page load if there are pending migrations + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + config.assets.debug = true end diff --git a/test/rails_app/config/environments/production.rb b/test/rails_app/config/environments/production.rb index fe0831be..79c54188 100644 --- a/test/rails_app/config/environments/production.rb +++ b/test/rails_app/config/environments/production.rb @@ -1,33 +1,84 @@ RailsApp::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb + # Settings specified here will take precedence over those in config/application.rb. - # The production environment is meant for finished, "live" apps. - # Code is not reloaded between requests + # Code is not reloaded between requests. config.cache_classes = true - # Full error reports are disabled and caching is turned on + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both thread web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true - # See everything in the log (default is :info) - # config.log_level = :debug + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # config.action_dispatch.rack_cache = true - # Use a different logger for distributed setups - # config.logger = SyslogLogger.new - - # Use a different cache store in production - # config.cache_store = :mem_cache_store - - # Disable Rails's static asset server - # In production, Apache or nginx will already do this + # Disable Rails's static asset server (Apache or nginx will already do this). config.serve_static_assets = false - # Enable serving of images, stylesheets, and javascripts from an asset server + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Whether to fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # Generate digests for assets URLs. + config.assets.digest = true + + # Version of your assets, change this if you want to expire all your assets. + config.assets.version = '1.0' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = '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 + + # Set to :debug to see everything in the log. + config.log_level = :info + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(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" - # Disable delivery errors, bad email addresses will be ignored + # Precompile additional assets. + # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. + # config.assets.precompile += %w( search.js ) + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. # 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 + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL). + # config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Disable automatic flushing of the log to improve performance. + # config.autoflush_log = false + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new end diff --git a/test/rails_app/config/environments/test.rb b/test/rails_app/config/environments/test.rb index 0dfc4389..b9feca88 100644 --- a/test/rails_app/config/environments/test.rb +++ b/test/rails_app/config/environments/test.rb @@ -1,33 +1,36 @@ RailsApp::Application.configure do - # Settings specified here will take precedence over those in config/environment.rb + # 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 + # 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! + # and recreated between test runs. Don't rely on the data there! config.cache_classes = true - # Log error messages when you accidentally call methods on nil. - config.whiny_nils = true + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false - # Show full error reports and disable caching + # Configure static asset server for tests with Cache-Control for performance. + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false - # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = 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 - - config.action_dispatch.show_exceptions = false - + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr end diff --git a/test/rails_app/config/initializers/secret_token.rb b/test/rails_app/config/initializers/secret_token.rb index d27fc2d9..4089a38c 100644 --- a/test/rails_app/config/initializers/secret_token.rb +++ b/test/rails_app/config/initializers/secret_token.rb @@ -1,2 +1 @@ -Rails.application.config.secret_token = 'ea942c41850d502f2c8283e26bdc57829f471bb18224ddff0a192c4f32cdf6cb5aa0d82b3a7a7adbeb640c4b06f3aa1cd5f098162d8240f669b39d6b49680571' -Rails.application.config.session_store :cookie_store, :key => "_my_app" \ No newline at end of file +RailsApp::Application.config.secret_key_base = 'd588e99efff13a86461fd6ab82327823ad2f8feb5dc217ce652cdd9f0dfc5eb4b5a62a92d24d2574d7d51dfb1ea8dd453ea54e00cf672159a13104a135422a10' diff --git a/test/rails_app/config/initializers/session_store.rb b/test/rails_app/config/initializers/session_store.rb new file mode 100644 index 00000000..d770aeb8 --- /dev/null +++ b/test/rails_app/config/initializers/session_store.rb @@ -0,0 +1 @@ +RailsApp::Application.config.session_store :encrypted_cookie_store, key: '_rails_app_session' diff --git a/test/rails_app/script/rails b/test/rails_app/script/rails deleted file mode 100755 index ec22bf97..00000000 --- a/test/rails_app/script/rails +++ /dev/null @@ -1,10 +0,0 @@ -#!/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. - -ENV_PATH = File.expand_path('../../config/environment', __FILE__) -BOOT_PATH = File.expand_path('../../config/boot', __FILE__) -APP_PATH = File.expand_path('../../config/application', __FILE__) -ROOT_PATH = File.expand_path('../..', __FILE__) - -require BOOT_PATH -require 'rails/commands'