From 2d457424bc952348d7fe28849ab71ab2de56ef9b Mon Sep 17 00:00:00 2001 From: Gustavo Cunha Date: Mon, 5 Jan 2015 11:35:20 -0300 Subject: [PATCH 1/2] Update to rails 4.2.0 Update to ruby 2.2.0 Update gems --- .capistrano/metrics | 1 + Gemfile | 2 +- Gemfile.lock | 143 +++++++++++++--------- bin/rails | 2 +- bin/setup | 29 +++++ config/application.rb | 10 +- config/boot.rb | 3 +- config/environments/development.rb | 7 ++ config/environments/production.rb | 35 +++--- config/environments/stage.rb | 35 +++--- config/environments/test.rb | 7 +- config/initializers/assets.rb | 11 ++ config/initializers/cookies_serializer.rb | 2 +- config/initializers/wrap_parameters.rb | 5 + 14 files changed, 187 insertions(+), 105 deletions(-) create mode 100644 .capistrano/metrics create mode 100755 bin/setup diff --git a/.capistrano/metrics b/.capistrano/metrics new file mode 100644 index 00000000..94a4335e --- /dev/null +++ b/.capistrano/metrics @@ -0,0 +1 @@ +full \ No newline at end of file diff --git a/Gemfile b/Gemfile index 3615ec0f..46503567 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 4.1.6' +gem 'rails', '~> 4.2.0' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' # Use Uglifier as compressor for JavaScript assets diff --git a/Gemfile.lock b/Gemfile.lock index 50bdc23d..a62b507c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,35 +1,44 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.1.6) - actionpack (= 4.1.6) - actionview (= 4.1.6) + actionmailer (4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.6) - actionview (= 4.1.6) - activesupport (= 4.1.6) - rack (~> 1.5.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.0) + actionview (= 4.2.0) + activesupport (= 4.2.0) + rack (~> 1.6.0) rack-test (~> 0.6.2) - actionview (4.1.6) - activesupport (= 4.1.6) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + actionview (4.2.0) + activesupport (= 4.2.0) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.6) - activesupport (= 4.1.6) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + activejob (4.2.0) + activesupport (= 4.2.0) + globalid (>= 0.3.0) + activemodel (4.2.0) + activesupport (= 4.2.0) builder (~> 3.1) - activerecord (4.1.6) - activemodel (= 4.1.6) - activesupport (= 4.1.6) - arel (~> 5.0.0) - activesupport (4.1.6) - i18n (~> 0.6, >= 0.6.9) + activerecord (4.2.0) + activemodel (= 4.2.0) + activesupport (= 4.2.0) + arel (~> 6.0) + activesupport (4.2.0) + i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - arel (5.0.1.20140414130214) + arel (6.0.0) bcrypt (3.1.9) - brakeman (2.6.3) + brakeman (3.0.0) erubis (~> 2.6) fastercsv (~> 1.5) haml (>= 3.0, < 5.0) @@ -41,7 +50,8 @@ GEM slim (>= 1.3.6, < 3.0) terminal-table (~> 1.4) builder (3.2.2) - capistrano (3.2.1) + capistrano (3.3.5) + capistrano-stats (~> 1.1.0) i18n rake (>= 10.0.0) sshkit (~> 1.3) @@ -54,6 +64,7 @@ GEM capistrano-rvm (0.1.2) capistrano (~> 3.0) sshkit (~> 1.2) + capistrano-stats (1.1.1) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -61,65 +72,81 @@ GEM coffee-script-source execjs coffee-script-source (1.8.0) - colorize (0.7.3) + colorize (0.7.5) daemon_controller (1.2.0) erubis (2.7.0) execjs (2.2.2) fastercsv (1.5.5) - haml (4.0.5) + globalid (0.3.0) + activesupport (>= 4.1.0) + haml (4.0.6) tilt highline (1.6.21) hike (1.2.3) - i18n (0.6.11) - jquery-rails (3.1.2) - railties (>= 3.0, < 5.0) + i18n (0.7.0) + jquery-rails (4.0.3) + rails-dom-testing (~> 1.0) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (1.8.1) - mail (2.6.1) + loofah (2.0.1) + nokogiri (>= 1.5.9) + mail (2.6.3) mime-types (>= 1.16, < 3) mime-types (2.4.3) - minitest (5.4.2) + mini_portile (0.6.2) + minitest (5.5.0) multi_json (1.10.1) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (2.9.1) - passenger (4.0.53) + nokogiri (1.6.5) + mini_portile (~> 0.6.0) + passenger (4.0.57) daemon_controller (>= 1.2.0) rack rake (>= 0.8.1) - quiet_assets (1.0.3) + quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.5.2) + rack (1.6.0) rack-test (0.6.2) rack (>= 1.0) - rails (4.1.6) - actionmailer (= 4.1.6) - actionpack (= 4.1.6) - actionview (= 4.1.6) - activemodel (= 4.1.6) - activerecord (= 4.1.6) - activesupport (= 4.1.6) + rails (4.2.0) + actionmailer (= 4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) + activemodel (= 4.2.0) + activerecord (= 4.2.0) + activesupport (= 4.2.0) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.6) - sprockets-rails (~> 2.0) - railties (4.1.6) - actionpack (= 4.1.6) - activesupport (= 4.1.6) + railties (= 4.2.0) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.5) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.1) + loofah (~> 2.0) + railties (4.2.0) + actionpack (= 4.2.0) + activesupport (= 4.2.0) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.3.2) - rdoc (4.1.2) - json (~> 1.4) + rake (10.4.2) + rdoc (4.2.0) ruby2ruby (2.1.3) ruby_parser (~> 3.1) sexp_processor (~> 4.0) ruby_parser (3.5.0) sexp_processor (~> 4.1) sass (3.2.19) - sass-rails (4.0.3) + sass-rails (4.0.5) railties (>= 4.0.0, < 5.0) - sass (~> 3.2.0) - sprockets (~> 2.8, <= 2.11.0) + sass (~> 3.2.2) + sprockets (~> 2.8, < 3.0) sprockets-rails (~> 2.0) sdoc (0.4.1) json (~> 1.7, >= 1.7.7) @@ -128,30 +155,30 @@ GEM slim (2.1.0) temple (~> 0.6.9) tilt (>= 1.3.3, < 2.1) - spring (1.1.3) - sprockets (2.11.0) + spring (1.2.0) + sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.2.0) + sprockets-rails (2.2.2) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) - sshkit (1.5.1) - colorize + sshkit (1.6.1) + colorize (>= 0.7.0) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - temple (0.6.9) + temple (0.6.10) terminal-table (1.4.5) thor (0.19.1) thread_safe (0.3.4) tilt (1.4.1) - turbolinks (2.4.0) + turbolinks (2.5.3) coffee-rails tzinfo (1.2.2) thread_safe (~> 0.1) - uglifier (2.5.3) + uglifier (2.6.1) execjs (>= 0.3.0) json (>= 1.8.0) @@ -169,7 +196,7 @@ DEPENDENCIES jquery-rails passenger quiet_assets - rails (~> 4.1.6) + rails (~> 4.2.0) sass-rails (~> 4.0.3) sdoc (~> 0.4.0) spring diff --git a/bin/rails b/bin/rails index 728cd85a..5191e692 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/setup b/bin/setup new file mode 100755 index 00000000..acdb2c13 --- /dev/null +++ b/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/config/application.rb b/config/application.rb index 39a0975d..c55f85ad 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,14 +1,13 @@ require File.expand_path('../boot', __FILE__) -# Pick the frameworks you want: # require 'rails/all' -require "active_model/railtie" # require "active_record/railtie" require "action_controller/railtie" -require "action_mailer/railtie" require "action_view/railtie" -require "sprockets/railtie" +require "action_mailer/railtie" +require "active_job/railtie" require "rails/test_unit/railtie" +require "sprockets/railtie" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -27,5 +26,8 @@ class Application < Rails::Application # 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 + + # Do not swallow errors in after_commit/after_rollback callbacks. + # config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/boot.rb b/config/boot.rb index 5e5f0c1f..6b750f00 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,3 @@ -# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environments/development.rb b/config/environments/development.rb index a384d952..12293d70 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -19,11 +19,18 @@ # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # 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. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. # Raises helpful error messages. diff --git a/config/environments/production.rb b/config/environments/production.rb index 5410695d..d58635b9 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -16,11 +16,13 @@ # 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. + # For large-scale production use, consider using a caching reverse proxy like + # NGINX, varnish or squid. # config.action_dispatch.rack_cache = true - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = true # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -29,21 +31,22 @@ # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = true - # Generate digests for assets URLs. + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. config.assets.digest = true - # Version of your assets, change this if you want to expire all your assets. - config.assets.version = '1.0' + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # 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 + # 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 + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug # Prepend all log lines with the following tags. # config.log_tags = [ :subdomain, :uuid ] @@ -55,11 +58,7 @@ # 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 in app/assets folder are already added. - # config.assets.precompile += %w( search.js ) + # config.action_controller.asset_host = 'http://assets.example.com' # 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. @@ -72,9 +71,9 @@ # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # 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 + + # Do not dump schema after migrations. + # config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/stage.rb b/config/environments/stage.rb index 5410695d..d58635b9 100644 --- a/config/environments/stage.rb +++ b/config/environments/stage.rb @@ -16,11 +16,13 @@ # 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. + # For large-scale production use, consider using a caching reverse proxy like + # NGINX, varnish or squid. # config.action_dispatch.rack_cache = true - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = true # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -29,21 +31,22 @@ # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = true - # Generate digests for assets URLs. + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. config.assets.digest = true - # Version of your assets, change this if you want to expire all your assets. - config.assets.version = '1.0' + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # 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 + # 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 + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug # Prepend all log lines with the following tags. # config.log_tags = [ :subdomain, :uuid ] @@ -55,11 +58,7 @@ # 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 in app/assets folder are already added. - # config.assets.precompile += %w( search.js ) + # config.action_controller.asset_host = 'http://assets.example.com' # 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. @@ -72,9 +71,9 @@ # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # 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 + + # Do not dump schema after migrations. + # config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/test.rb b/config/environments/test.rb index 053f5b66..1c19f08b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,8 +12,8 @@ # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static asset server for tests with Cache-Control for performance. - config.serve_static_assets = true + # Configure static file server for tests with Cache-Control for performance. + config.serve_static_files = true config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching. @@ -31,6 +31,9 @@ # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Randomize the order test cases are executed. + config.active_support.test_order = :random + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 5a503f2b..59e28069 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -1 +1,12 @@ Rails.application.config.assets.precompile += %w( website.css fallback.css modernizr.js custom.js ) +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7a06a89f..7f70458d 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.action_dispatch.cookies_serializer = :json \ No newline at end of file +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index b81ea74b..33725e95 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -7,3 +7,8 @@ ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] if respond_to?(:wrap_parameters) end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end From 7c9e60bb7c0c53a089941bb634530af9b95ae0a7 Mon Sep 17 00:00:00 2001 From: Gustavo Cunha Date: Mon, 5 Jan 2015 11:36:24 -0300 Subject: [PATCH 2/2] Fix capistrano files --- .capistrano/metrics | 1 - .gitignore | 1 + config/deploy.rb | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 .capistrano/metrics diff --git a/.capistrano/metrics b/.capistrano/metrics deleted file mode 100644 index 94a4335e..00000000 --- a/.capistrano/metrics +++ /dev/null @@ -1 +0,0 @@ -full \ No newline at end of file diff --git a/.gitignore b/.gitignore index d4df5756..40b89a39 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ config/database.yml ## Environment normalisation: /.bundle +/.capistrano /vendor/bundle # these should all be checked in to normalise the environment: diff --git a/config/deploy.rb b/config/deploy.rb index ab4616d1..061f0f0a 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,10 +1,10 @@ # config valid only for Capistrano 3.1 -lock '3.2.1' +lock '3.3.5' set :application, 'gmmcal.com.br' set :repo_url, 'git@github.com:gmmcal/gmmcal.com.br.git' set :base_path, "/var/www/rails/gmmcal.com.br" -set :ruby_version, "2.1.2" +set :ruby_version, "2.2.0" set :ruby_gemset, "gmmcal.com.br" ask :user, "root" ask :server, "example.com"