diff --git a/.travis.yml b/.travis.yml index 43ec68d..65f91e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,27 @@ sudo: false language: ruby + +bundler_args: --without guard --path=.bundle +before_script: "./setup.sh install" +script: "bundle exec rspec" + rvm: - 2.2 - 2.3 - 2.4 +env: + - APP=rails_42 + - APP=rails_42_sprockets_rails_3 + - APP=rails_50 + - APP=rails_51 + - APP=rails_52 + matrix: fast_finish: true + include: + - rvm: 2.4 + env: APP=rails_master cache: directories: @@ -15,5 +30,5 @@ cache: - spec/railsapps/rails_42_sprockets_rails_3/.bundle - spec/railsapps/rails_50/.bundle - spec/railsapps/rails_51/.bundle -bundler_args: --without guard --path=.bundle -script: "rake" + - spec/railsapps/rails_52/.bundle + - spec/railsapps/rails_master/.bundle diff --git a/roadie-rails.gemspec b/roadie-rails.gemspec index 127364a..1dd8325 100644 --- a/roadie-rails.gemspec +++ b/roadie-rails.gemspec @@ -22,9 +22,9 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "roadie", "~> 3.1" - spec.add_dependency "railties", ">= 3.0", "< 5.2" + spec.add_dependency "railties", ">= 3.0", "< 6.1" - spec.add_development_dependency "rails", ">= 4.2", "< 5.2" + spec.add_development_dependency "rails", ">= 4.2", "< 6.1" spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "rspec-rails" diff --git a/setup.sh b/setup.sh index 0a56e6a..be09596 100755 --- a/setup.sh +++ b/setup.sh @@ -32,7 +32,8 @@ if [[ $1 == "install" ]]; then header "Installing gem dependencies" install - for app_path in $root/spec/railsapps/rails_*; do + app="${APP:-rails_*}" + for app_path in $root/spec/railsapps/$app; do ( header "Rails app $(basename $app_path)" cd $app_path @@ -46,7 +47,8 @@ elif [[ $1 == "update" ]]; then header "Updating gem dependencies" update - for app_path in $root/spec/railsapps/rails_*; do + app="${APP:-rails_*}" + for app_path in $root/spec/railsapps/$app; do ( cd $app_path header "Updating $(basename $app_path)" diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index 57274b7..2ba01ad 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -11,9 +11,15 @@ def parse_html_in_email(mail) RailsApp.new("Rails 4.2.x", 'rails_42', runner: :bin, asset_pipeline: true, digests: false), RailsApp.new("Rails 4.2.x (with sprockets-rails 3)", 'rails_42_sprockets_rails_3', runner: :bin, asset_pipeline: true, digests: true, sprockets: 3), RailsApp.new("Rails 5.0.x", 'rails_50', runner: :bin, asset_pipeline: true, digests: true, sprockets: 3), - RailsApp.new("Rails 5.1.0", 'rails_51', runner: :bin, asset_pipeline: true, digests: true, sprockets: 3) + RailsApp.new("Rails 5.1.0", 'rails_51', runner: :bin, asset_pipeline: true, digests: true, sprockets: 3), + RailsApp.new("Rails 5.2.0", 'rails_52', runner: :bin, asset_pipeline: true, digests: true, sprockets: 3), + RailsApp.new("Rails master", 'rails_master', runner: :bin, asset_pipeline: true, digests: true, sprockets: 3) ] + if app = ENV['APP'] + rails_apps.select! { |a| a.path == app } + end + rails_apps.each do |app| describe "with #{app}" do before { app.reset } diff --git a/spec/railsapps/rails_52/.gitignore b/spec/railsapps/rails_52/.gitignore new file mode 100644 index 0000000..48fb168 --- /dev/null +++ b/spec/railsapps/rails_52/.gitignore @@ -0,0 +1,17 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore Byebug command history file. +.byebug_history diff --git a/spec/railsapps/rails_52/Gemfile b/spec/railsapps/rails_52/Gemfile new file mode 100644 index 0000000..16d528b --- /dev/null +++ b/spec/railsapps/rails_52/Gemfile @@ -0,0 +1,8 @@ +source 'https://rubygems.org' + +gem 'rails', '~> 5.2.0.rc1' +gem 'sass-rails' +gem 'sprockets-rails' +gem 'listen' + +gem 'roadie-rails', path: '../../..' diff --git a/spec/railsapps/rails_52/app/assets/images/rails.png b/spec/railsapps/rails_52/app/assets/images/rails.png new file mode 100644 index 0000000..d5edc04 Binary files /dev/null and b/spec/railsapps/rails_52/app/assets/images/rails.png differ diff --git a/spec/railsapps/rails_52/app/assets/stylesheets/email.css.scss b/spec/railsapps/rails_52/app/assets/stylesheets/email.css.scss new file mode 100644 index 0000000..8fb351f --- /dev/null +++ b/spec/railsapps/rails_52/app/assets/stylesheets/email.css.scss @@ -0,0 +1,2 @@ +body { background-color: green; } +.image { background: image-url("rails.png"); } diff --git a/spec/railsapps/rails_52/app/mailers/auto_mailer.rb b/spec/railsapps/rails_52/app/mailers/auto_mailer.rb new file mode 100644 index 0000000..81f522e --- /dev/null +++ b/spec/railsapps/rails_52/app/mailers/auto_mailer.rb @@ -0,0 +1,27 @@ +class AutoMailer < ActionMailer::Base + include Roadie::Rails::Automatic + + default from: 'john@example.com' + + def normal_email + generate_email + end + + def disabled_email + generate_email + end + + private + def roadie_options + unless action_name =~ /disabled/ + super.combine(url_options: {protocol: "https"}) + end + end + + def generate_email + mail(to: 'example@example.org', subject: "Notification for you") do |format| + format.html { render :normal_email } + format.text { render :normal_email } + end + end +end diff --git a/spec/railsapps/rails_52/app/mailers/mailer.rb b/spec/railsapps/rails_52/app/mailers/mailer.rb new file mode 100644 index 0000000..87cbb8a --- /dev/null +++ b/spec/railsapps/rails_52/app/mailers/mailer.rb @@ -0,0 +1,17 @@ +class Mailer < ActionMailer::Base + include Roadie::Rails::Mailer + + default from: 'john@example.com' + + def normal_email + roadie_mail(to: 'example@example.org', subject: "Notification for you") do |format| + format.html + format.text + end + end + + private + def roadie_options + super.combine(url_options: {protocol: "https"}) + end +end diff --git a/spec/railsapps/rails_52/app/views/auto_mailer/normal_email.html.erb b/spec/railsapps/rails_52/app/views/auto_mailer/normal_email.html.erb new file mode 100644 index 0000000..cf672b4 --- /dev/null +++ b/spec/railsapps/rails_52/app/views/auto_mailer/normal_email.html.erb @@ -0,0 +1,11 @@ + + + + + <%= stylesheet_link_tag "email" %> + + +

Normal email

+
+ + diff --git a/spec/railsapps/rails_52/app/views/auto_mailer/normal_email.text b/spec/railsapps/rails_52/app/views/auto_mailer/normal_email.text new file mode 100644 index 0000000..302fdf4 --- /dev/null +++ b/spec/railsapps/rails_52/app/views/auto_mailer/normal_email.text @@ -0,0 +1 @@ +Normal email diff --git a/spec/railsapps/rails_52/app/views/mailer/normal_email.html.erb b/spec/railsapps/rails_52/app/views/mailer/normal_email.html.erb new file mode 100644 index 0000000..cf672b4 --- /dev/null +++ b/spec/railsapps/rails_52/app/views/mailer/normal_email.html.erb @@ -0,0 +1,11 @@ + + + + + <%= stylesheet_link_tag "email" %> + + +

Normal email

+
+ + diff --git a/spec/railsapps/rails_52/app/views/mailer/normal_email.text b/spec/railsapps/rails_52/app/views/mailer/normal_email.text new file mode 100644 index 0000000..302fdf4 --- /dev/null +++ b/spec/railsapps/rails_52/app/views/mailer/normal_email.text @@ -0,0 +1 @@ +Normal email diff --git a/spec/railsapps/rails_52/bin/rails b/spec/railsapps/rails_52/bin/rails new file mode 100755 index 0000000..5191e69 --- /dev/null +++ b/spec/railsapps/rails_52/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/spec/railsapps/rails_52/config.ru b/spec/railsapps/rails_52/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/spec/railsapps/rails_52/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/spec/railsapps/rails_52/config/application.rb b/spec/railsapps/rails_52/config/application.rb new file mode 100644 index 0000000..9c3923a --- /dev/null +++ b/spec/railsapps/rails_52/config/application.rb @@ -0,0 +1,16 @@ +require_relative 'boot' + +require 'action_controller/railtie' +require 'action_mailer/railtie' +require 'action_view/railtie' +require 'sprockets/railtie' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Rails52 + class Application < Rails::Application + config.roadie.url_options = { host: 'example.app.org' } + end +end diff --git a/spec/railsapps/rails_52/config/boot.rb b/spec/railsapps/rails_52/config/boot.rb new file mode 100644 index 0000000..30f5120 --- /dev/null +++ b/spec/railsapps/rails_52/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/spec/railsapps/rails_52/config/environment.rb b/spec/railsapps/rails_52/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/spec/railsapps/rails_52/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/spec/railsapps/rails_52/config/environments/development.rb b/spec/railsapps/rails_52/config/environments/development.rb new file mode 100644 index 0000000..58d20de --- /dev/null +++ b/spec/railsapps/rails_52/config/environments/development.rb @@ -0,0 +1,51 @@ +Rails.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 + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=172800' + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # 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 + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/spec/railsapps/rails_52/config/environments/production.rb b/spec/railsapps/rails_52/config/environments/production.rb new file mode 100644 index 0000000..7dabce6 --- /dev/null +++ b/spec/railsapps/rails_52/config/environments/production.rb @@ -0,0 +1,83 @@ +Rails.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 + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded 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 + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # 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 + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # 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 = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "rails_51_#{Rails.env}" + config.action_mailer.perform_caching = false + + # 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 locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end +end diff --git a/spec/railsapps/rails_52/config/environments/test.rb b/spec/railsapps/rails_52/config/environments/test.rb new file mode 100644 index 0000000..30587ef --- /dev/null +++ b/spec/railsapps/rails_52/config/environments/test.rb @@ -0,0 +1,42 @@ +Rails.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 = 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 + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + '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 + + # 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 + config.action_mailer.perform_caching = 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 + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/spec/railsapps/rails_52/config/initializers/application_controller_renderer.rb b/spec/railsapps/rails_52/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..51639b6 --- /dev/null +++ b/spec/railsapps/rails_52/config/initializers/application_controller_renderer.rb @@ -0,0 +1,6 @@ +# Be sure to restart your server when you modify this file. + +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) diff --git a/spec/railsapps/rails_52/config/initializers/assets.rb b/spec/railsapps/rails_52/config/initializers/assets.rb new file mode 100644 index 0000000..8bf3ad0 --- /dev/null +++ b/spec/railsapps/rails_52/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# 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( email.css ) diff --git a/spec/railsapps/rails_52/config/initializers/backtrace_silencers.rb b/spec/railsapps/rails_52/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/spec/railsapps/rails_52/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! diff --git a/spec/railsapps/rails_52/config/initializers/cookies_serializer.rb b/spec/railsapps/rails_52/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/spec/railsapps/rails_52/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/spec/railsapps/rails_52/config/initializers/filter_parameter_logging.rb b/spec/railsapps/rails_52/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/spec/railsapps/rails_52/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/spec/railsapps/rails_52/config/initializers/inflections.rb b/spec/railsapps/rails_52/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/spec/railsapps/rails_52/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/spec/railsapps/rails_52/config/initializers/mime_types.rb b/spec/railsapps/rails_52/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/spec/railsapps/rails_52/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# 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 diff --git a/spec/railsapps/rails_52/config/initializers/new_framework_defaults.rb b/spec/railsapps/rails_52/config/initializers/new_framework_defaults.rb new file mode 100644 index 0000000..0859f91 --- /dev/null +++ b/spec/railsapps/rails_52/config/initializers/new_framework_defaults.rb @@ -0,0 +1,18 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.0 upgrade. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Enable per-form CSRF tokens. Previous versions had false. +Rails.application.config.action_controller.per_form_csrf_tokens = true + +# Enable origin-checking CSRF mitigation. Previous versions had false. +Rails.application.config.action_controller.forgery_protection_origin_check = true + +# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. +# Previous versions had false. +ActiveSupport.to_time_preserves_timezone = true + +# Configure SSL options to enable HSTS with subdomains. Previous versions had false. +Rails.application.config.ssl_options = { hsts: { subdomains: true } } diff --git a/spec/railsapps/rails_52/config/initializers/session_store.rb b/spec/railsapps/rails_52/config/initializers/session_store.rb new file mode 100644 index 0000000..e26c847 --- /dev/null +++ b/spec/railsapps/rails_52/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_rails_51_session' diff --git a/spec/railsapps/rails_52/config/initializers/wrap_parameters.rb b/spec/railsapps/rails_52/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..633c1c8 --- /dev/null +++ b/spec/railsapps/rails_52/config/initializers/wrap_parameters.rb @@ -0,0 +1,9 @@ +# 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. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end diff --git a/spec/railsapps/rails_52/config/locales/en.yml b/spec/railsapps/rails_52/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/spec/railsapps/rails_52/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/spec/railsapps/rails_52/config/routes.rb b/spec/railsapps/rails_52/config/routes.rb new file mode 100644 index 0000000..787824f --- /dev/null +++ b/spec/railsapps/rails_52/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html +end diff --git a/spec/railsapps/rails_52/log/.keep b/spec/railsapps/rails_52/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/railsapps/rails_master/.gitignore b/spec/railsapps/rails_master/.gitignore new file mode 100644 index 0000000..48fb168 --- /dev/null +++ b/spec/railsapps/rails_master/.gitignore @@ -0,0 +1,17 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore Byebug command history file. +.byebug_history diff --git a/spec/railsapps/rails_master/Gemfile b/spec/railsapps/rails_master/Gemfile new file mode 100644 index 0000000..847eca5 --- /dev/null +++ b/spec/railsapps/rails_master/Gemfile @@ -0,0 +1,10 @@ +source 'https://rubygems.org' + +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +gem 'rails', github: 'rails/rails' +gem 'sass-rails' +gem 'sprockets-rails' +gem 'listen' + +gem 'roadie-rails', path: '../../..' diff --git a/spec/railsapps/rails_master/app/assets/images/rails.png b/spec/railsapps/rails_master/app/assets/images/rails.png new file mode 100644 index 0000000..d5edc04 Binary files /dev/null and b/spec/railsapps/rails_master/app/assets/images/rails.png differ diff --git a/spec/railsapps/rails_master/app/assets/stylesheets/email.css.scss b/spec/railsapps/rails_master/app/assets/stylesheets/email.css.scss new file mode 100644 index 0000000..8fb351f --- /dev/null +++ b/spec/railsapps/rails_master/app/assets/stylesheets/email.css.scss @@ -0,0 +1,2 @@ +body { background-color: green; } +.image { background: image-url("rails.png"); } diff --git a/spec/railsapps/rails_master/app/mailers/auto_mailer.rb b/spec/railsapps/rails_master/app/mailers/auto_mailer.rb new file mode 100644 index 0000000..81f522e --- /dev/null +++ b/spec/railsapps/rails_master/app/mailers/auto_mailer.rb @@ -0,0 +1,27 @@ +class AutoMailer < ActionMailer::Base + include Roadie::Rails::Automatic + + default from: 'john@example.com' + + def normal_email + generate_email + end + + def disabled_email + generate_email + end + + private + def roadie_options + unless action_name =~ /disabled/ + super.combine(url_options: {protocol: "https"}) + end + end + + def generate_email + mail(to: 'example@example.org', subject: "Notification for you") do |format| + format.html { render :normal_email } + format.text { render :normal_email } + end + end +end diff --git a/spec/railsapps/rails_master/app/mailers/mailer.rb b/spec/railsapps/rails_master/app/mailers/mailer.rb new file mode 100644 index 0000000..87cbb8a --- /dev/null +++ b/spec/railsapps/rails_master/app/mailers/mailer.rb @@ -0,0 +1,17 @@ +class Mailer < ActionMailer::Base + include Roadie::Rails::Mailer + + default from: 'john@example.com' + + def normal_email + roadie_mail(to: 'example@example.org', subject: "Notification for you") do |format| + format.html + format.text + end + end + + private + def roadie_options + super.combine(url_options: {protocol: "https"}) + end +end diff --git a/spec/railsapps/rails_master/app/views/auto_mailer/normal_email.html.erb b/spec/railsapps/rails_master/app/views/auto_mailer/normal_email.html.erb new file mode 100644 index 0000000..cf672b4 --- /dev/null +++ b/spec/railsapps/rails_master/app/views/auto_mailer/normal_email.html.erb @@ -0,0 +1,11 @@ + + + + + <%= stylesheet_link_tag "email" %> + + +

Normal email

+
+ + diff --git a/spec/railsapps/rails_master/app/views/auto_mailer/normal_email.text b/spec/railsapps/rails_master/app/views/auto_mailer/normal_email.text new file mode 100644 index 0000000..302fdf4 --- /dev/null +++ b/spec/railsapps/rails_master/app/views/auto_mailer/normal_email.text @@ -0,0 +1 @@ +Normal email diff --git a/spec/railsapps/rails_master/app/views/mailer/normal_email.html.erb b/spec/railsapps/rails_master/app/views/mailer/normal_email.html.erb new file mode 100644 index 0000000..cf672b4 --- /dev/null +++ b/spec/railsapps/rails_master/app/views/mailer/normal_email.html.erb @@ -0,0 +1,11 @@ + + + + + <%= stylesheet_link_tag "email" %> + + +

Normal email

+
+ + diff --git a/spec/railsapps/rails_master/app/views/mailer/normal_email.text b/spec/railsapps/rails_master/app/views/mailer/normal_email.text new file mode 100644 index 0000000..302fdf4 --- /dev/null +++ b/spec/railsapps/rails_master/app/views/mailer/normal_email.text @@ -0,0 +1 @@ +Normal email diff --git a/spec/railsapps/rails_master/bin/rails b/spec/railsapps/rails_master/bin/rails new file mode 100755 index 0000000..5191e69 --- /dev/null +++ b/spec/railsapps/rails_master/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/spec/railsapps/rails_master/config.ru b/spec/railsapps/rails_master/config.ru new file mode 100644 index 0000000..f7ba0b5 --- /dev/null +++ b/spec/railsapps/rails_master/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/spec/railsapps/rails_master/config/application.rb b/spec/railsapps/rails_master/config/application.rb new file mode 100644 index 0000000..693e685 --- /dev/null +++ b/spec/railsapps/rails_master/config/application.rb @@ -0,0 +1,16 @@ +require_relative 'boot' + +require 'action_controller/railtie' +require 'action_mailer/railtie' +require 'action_view/railtie' +require 'sprockets/railtie' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module RailsMaster + class Application < Rails::Application + config.roadie.url_options = { host: 'example.app.org' } + end +end diff --git a/spec/railsapps/rails_master/config/boot.rb b/spec/railsapps/rails_master/config/boot.rb new file mode 100644 index 0000000..30f5120 --- /dev/null +++ b/spec/railsapps/rails_master/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/spec/railsapps/rails_master/config/environment.rb b/spec/railsapps/rails_master/config/environment.rb new file mode 100644 index 0000000..426333b --- /dev/null +++ b/spec/railsapps/rails_master/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/spec/railsapps/rails_master/config/environments/development.rb b/spec/railsapps/rails_master/config/environments/development.rb new file mode 100644 index 0000000..58d20de --- /dev/null +++ b/spec/railsapps/rails_master/config/environments/development.rb @@ -0,0 +1,51 @@ +Rails.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 + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=172800' + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # 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 + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/spec/railsapps/rails_master/config/environments/production.rb b/spec/railsapps/rails_master/config/environments/production.rb new file mode 100644 index 0000000..7dabce6 --- /dev/null +++ b/spec/railsapps/rails_master/config/environments/production.rb @@ -0,0 +1,83 @@ +Rails.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 + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded 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 + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # 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 + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # 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 = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "rails_51_#{Rails.env}" + config.action_mailer.perform_caching = false + + # 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 locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end +end diff --git a/spec/railsapps/rails_master/config/environments/test.rb b/spec/railsapps/rails_master/config/environments/test.rb new file mode 100644 index 0000000..30587ef --- /dev/null +++ b/spec/railsapps/rails_master/config/environments/test.rb @@ -0,0 +1,42 @@ +Rails.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 = 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 + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + '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 + + # 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 + config.action_mailer.perform_caching = 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 + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/spec/railsapps/rails_master/config/initializers/application_controller_renderer.rb b/spec/railsapps/rails_master/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..51639b6 --- /dev/null +++ b/spec/railsapps/rails_master/config/initializers/application_controller_renderer.rb @@ -0,0 +1,6 @@ +# Be sure to restart your server when you modify this file. + +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) diff --git a/spec/railsapps/rails_master/config/initializers/assets.rb b/spec/railsapps/rails_master/config/initializers/assets.rb new file mode 100644 index 0000000..8bf3ad0 --- /dev/null +++ b/spec/railsapps/rails_master/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# 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( email.css ) diff --git a/spec/railsapps/rails_master/config/initializers/backtrace_silencers.rb b/spec/railsapps/rails_master/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/spec/railsapps/rails_master/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! diff --git a/spec/railsapps/rails_master/config/initializers/cookies_serializer.rb b/spec/railsapps/rails_master/config/initializers/cookies_serializer.rb new file mode 100644 index 0000000..5a6a32d --- /dev/null +++ b/spec/railsapps/rails_master/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/spec/railsapps/rails_master/config/initializers/filter_parameter_logging.rb b/spec/railsapps/rails_master/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000..4a994e1 --- /dev/null +++ b/spec/railsapps/rails_master/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/spec/railsapps/rails_master/config/initializers/inflections.rb b/spec/railsapps/rails_master/config/initializers/inflections.rb new file mode 100644 index 0000000..ac033bf --- /dev/null +++ b/spec/railsapps/rails_master/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/spec/railsapps/rails_master/config/initializers/mime_types.rb b/spec/railsapps/rails_master/config/initializers/mime_types.rb new file mode 100644 index 0000000..dc18996 --- /dev/null +++ b/spec/railsapps/rails_master/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# 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 diff --git a/spec/railsapps/rails_master/config/initializers/new_framework_defaults.rb b/spec/railsapps/rails_master/config/initializers/new_framework_defaults.rb new file mode 100644 index 0000000..0859f91 --- /dev/null +++ b/spec/railsapps/rails_master/config/initializers/new_framework_defaults.rb @@ -0,0 +1,18 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.0 upgrade. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. + +# Enable per-form CSRF tokens. Previous versions had false. +Rails.application.config.action_controller.per_form_csrf_tokens = true + +# Enable origin-checking CSRF mitigation. Previous versions had false. +Rails.application.config.action_controller.forgery_protection_origin_check = true + +# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. +# Previous versions had false. +ActiveSupport.to_time_preserves_timezone = true + +# Configure SSL options to enable HSTS with subdomains. Previous versions had false. +Rails.application.config.ssl_options = { hsts: { subdomains: true } } diff --git a/spec/railsapps/rails_master/config/initializers/session_store.rb b/spec/railsapps/rails_master/config/initializers/session_store.rb new file mode 100644 index 0000000..e26c847 --- /dev/null +++ b/spec/railsapps/rails_master/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_rails_51_session' diff --git a/spec/railsapps/rails_master/config/initializers/wrap_parameters.rb b/spec/railsapps/rails_master/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..633c1c8 --- /dev/null +++ b/spec/railsapps/rails_master/config/initializers/wrap_parameters.rb @@ -0,0 +1,9 @@ +# 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. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end diff --git a/spec/railsapps/rails_master/config/locales/en.yml b/spec/railsapps/rails_master/config/locales/en.yml new file mode 100644 index 0000000..0653957 --- /dev/null +++ b/spec/railsapps/rails_master/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/spec/railsapps/rails_master/config/routes.rb b/spec/railsapps/rails_master/config/routes.rb new file mode 100644 index 0000000..787824f --- /dev/null +++ b/spec/railsapps/rails_master/config/routes.rb @@ -0,0 +1,3 @@ +Rails.application.routes.draw do + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html +end diff --git a/spec/railsapps/rails_master/log/.keep b/spec/railsapps/rails_master/log/.keep new file mode 100644 index 0000000..e69de29 diff --git a/spec/support/rails_app.rb b/spec/support/rails_app.rb index 08dbe4d..fdd08d8 100644 --- a/spec/support/rails_app.rb +++ b/spec/support/rails_app.rb @@ -1,7 +1,9 @@ class RailsApp + attr_reader :name, :path + def initialize(name, path, options = {}) - @name = name - @path = File.expand_path("../../railsapps/#{path}", __FILE__) + @name, @path = name, path + @full_path = File.expand_path("../../railsapps/#{path}", __FILE__) @runner = options.fetch(:runner) @using_asset_pipeline = options.fetch(:asset_pipeline) @digests = options.fetch(:digests) @@ -61,7 +63,7 @@ def run_file_in_app_context(file_path) def run_in_app_context(command) Bundler.with_clean_env do - Dir.chdir @path do + Dir.chdir @full_path do IO.popen(command).read end end