Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 6 support #84

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions roadie-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)"
Expand Down
8 changes: 7 additions & 1 deletion spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
17 changes: 17 additions & 0 deletions spec/railsapps/rails_52/.gitignore
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions spec/railsapps/rails_52/Gemfile
Original file line number Diff line number Diff line change
@@ -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: '../../..'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions spec/railsapps/rails_52/app/assets/stylesheets/email.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
body { background-color: green; }
.image { background: image-url("rails.png"); }
27 changes: 27 additions & 0 deletions spec/railsapps/rails_52/app/mailers/auto_mailer.rb
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions spec/railsapps/rails_52/app/mailers/mailer.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<%= stylesheet_link_tag "email" %>
</head>
<body>
<h1>Normal email</h1>
<div class="image"></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Normal email
11 changes: 11 additions & 0 deletions spec/railsapps/rails_52/app/views/mailer/normal_email.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<%= stylesheet_link_tag "email" %>
</head>
<body>
<h1>Normal email</h1>
<div class="image"></div>
</body>
</html>
1 change: 1 addition & 0 deletions spec/railsapps/rails_52/app/views/mailer/normal_email.text
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Normal email
4 changes: 4 additions & 0 deletions spec/railsapps/rails_52/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
5 changes: 5 additions & 0 deletions spec/railsapps/rails_52/config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This file is used by Rack-based servers to start the application.

require_relative 'config/environment'

run Rails.application
16 changes: 16 additions & 0 deletions spec/railsapps/rails_52/config/application.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions spec/railsapps/rails_52/config/boot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
5 changes: 5 additions & 0 deletions spec/railsapps/rails_52/config/environment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Load the Rails application.
require_relative 'application'

# Initialize the Rails application.
Rails.application.initialize!
51 changes: 51 additions & 0 deletions spec/railsapps/rails_52/config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -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
83 changes: 83 additions & 0 deletions spec/railsapps/rails_52/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -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
Loading