Skip to content

Commit

Permalink
Merge pull request #14 from rmacklin/support-rails-6
Browse files Browse the repository at this point in the history
Support Rails 6
  • Loading branch information
rmacklin authored Sep 9, 2019
2 parents c749633 + bccf4fe commit f654db6
Show file tree
Hide file tree
Showing 56 changed files with 877 additions and 30 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: ruby

rvm:
- 2.2.4
- 2.3.3
- 2.4.0
- 2.5.6
- 2.6.4

before_install:
- nvm install 6
Expand Down
2 changes: 1 addition & 1 deletion sprockets-bumble_d.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
spec.files = Dir['{lib}/**/*']
spec.require_paths = ['lib']

spec.add_dependency 'railties', ['>= 4.2.0', '< 6.0']
spec.add_dependency 'railties', ['>= 4.2.0', '< 7.0']
spec.add_dependency 'schmooze', '0.1.6'
spec.add_dependency 'sprockets', '~> 3.5'
end
12 changes: 6 additions & 6 deletions test/sprockets/bumble_d/transformer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def test_it_compiles_to_umd_modules
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_exports["default"] = void 0;
_module = babelHelpers.interopRequireDefault(_module);
_module2 = babelHelpers.interopRequireDefault(_module2);
var _default = 42;
_exports.default = _default;
_exports["default"] = _default;
});
JS

Expand Down Expand Up @@ -136,10 +136,10 @@ def test_it_compiles_to_umd_modules__works_with_namespaces
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_exports["default"] = void 0;
_module = babelHelpers.interopRequireDefault(_module);
var _default = 42;
_exports.default = _default;
_exports["default"] = _default;
});
JS

Expand Down Expand Up @@ -178,11 +178,11 @@ def test_it_can_compile_to_another_module_format
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_exports["default"] = void 0;
_module = babelHelpers.interopRequireDefault(_module);
_module2 = babelHelpers.interopRequireDefault(_module2);
var _default = 42;
_exports.default = _default;
_exports["default"] = _default;
});
JS

Expand Down
1 change: 0 additions & 1 deletion test/test_apps/4.2/test

This file was deleted.

1 change: 1 addition & 0 deletions test/test_apps/4.2/test/asset_compilation_test.rb
File renamed without changes.
1 change: 0 additions & 1 deletion test/test_apps/5.0/test

This file was deleted.

1 change: 1 addition & 0 deletions test/test_apps/5.0/test/asset_compilation_test.rb
7 changes: 7 additions & 0 deletions test/test_apps/5.0/test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
end
16 changes: 8 additions & 8 deletions test/test_apps/5.0_amd/test/asset_compilation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,53 @@ def test_compiled_assets_are_correct
assert_equal EXPECTED_OUTPUT, File.read(compiled_main_js_file)
end

MAIN_JS_DIGEST = '28d1277a0eefc149dba33a55c8c8c507d808a1a7cd7efc30d49c56a891b66cf1'
MAIN_JS_DIGEST = 'f4b4c2aa0b687f7aa0fb7e430800b58a3b646bf1301763fd9b1116deb0c7e278'
EXPECTED_OUTPUT = <<-JS
define("test_engine/qux", ["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_exports["default"] = void 0;
function Qux(config) {
this.config = config;
}
var _default = Qux;
_exports.default = _default;
_exports["default"] = _default;
});
define("foo", ["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_exports["default"] = void 0;
function Foo() {
this.number = 42;
}
var _default = Foo;
_exports.default = _default;
_exports["default"] = _default;
});
define("bar", ["exports", "foo"], function (_exports, _foo) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
_exports["default"] = void 0;
_foo = babelHelpers.interopRequireDefault(_foo);
function Bar() {
this.foo = new _foo.default();
this.foo = new _foo["default"]();
}
var _default = Bar;
_exports.default = _default;
_exports["default"] = _default;
});
Expand Down
1 change: 0 additions & 1 deletion test/test_apps/5.0_amd/test/test_helper.rb

This file was deleted.

7 changes: 7 additions & 0 deletions test/test_apps/5.0_amd/test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
end
19 changes: 19 additions & 0 deletions test/test_apps/6.0/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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/*


/public/assets
.byebug_history

# Ignore master key for decrypting credentials and more.
/config/master.key
1 change: 1 addition & 0 deletions test/test_apps/6.0/.ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby-2.6.1
11 changes: 11 additions & 0 deletions test/test_apps/6.0/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'

gem 'sprockets-bumble_d', :path => '../../..'

gem 'test_engine', path: '../test_engine'
24 changes: 24 additions & 0 deletions test/test_apps/6.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
6 changes: 6 additions & 0 deletions test/test_apps/6.0/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'

Rails.application.load_tasks
1 change: 1 addition & 0 deletions test/test_apps/6.0/app
105 changes: 105 additions & 0 deletions test/test_apps/6.0/bin/bundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'bundle' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "rubygems"

m = Module.new do
module_function

def invoked_as_script?
File.expand_path($0) == File.expand_path(__FILE__)
end

def env_var_version
ENV["BUNDLER_VERSION"]
end

def cli_arg_version
return unless invoked_as_script? # don't want to hijack other binstubs
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
bundler_version = $1 || ">= 0.a"
update_index = i
end
bundler_version
end

def gemfile
gemfile = ENV["BUNDLE_GEMFILE"]
return gemfile if gemfile && !gemfile.empty?

File.expand_path("../../Gemfile", __FILE__)
end

def lockfile
lockfile =
case File.basename(gemfile)
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
end

def lockfile_version
return unless File.file?(lockfile)
lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
Regexp.last_match(1)
end

def bundler_version
@bundler_version ||= begin
env_var_version || cli_arg_version ||
lockfile_version || "#{Gem::Requirement.default}.a"
end
end

def load_bundler!
ENV["BUNDLE_GEMFILE"] ||= gemfile

# must dup string for RG < 1.8 compatibility
activate_bundler(bundler_version.dup)
end

def activate_bundler(bundler_version)
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
bundler_version = "< 2"
end
gem_error = activation_error_handling do
gem "bundler", bundler_version
end
return if gem_error.nil?
require_error = activation_error_handling do
require "bundler/version"
end
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
exit 42
end

def activation_error_handling
yield
nil
rescue StandardError, LoadError => e
e
end
end

m.load_bundler!

if m.invoked_as_script?
load Gem.bin_path("bundler", "bundle")
end
4 changes: 4 additions & 0 deletions test/test_apps/6.0/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', __dir__)
require_relative '../config/boot'
require 'rails/commands'
4 changes: 4 additions & 0 deletions test/test_apps/6.0/bin/rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run
25 changes: 25 additions & 0 deletions test/test_apps/6.0/bin/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env ruby
require 'fileutils'

# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)

def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
end

FileUtils.chdir APP_ROOT do
# This script is a way to setup or update your development environment automatically.
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
# Add necessary setup steps to this file.

puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')

puts "\n== Removing old logs and tempfiles =="
system! 'bin/rails log:clear tmp:clear'

puts "\n== Restarting application server =="
system! 'bin/rails restart'
end
5 changes: 5 additions & 0 deletions test/test_apps/6.0/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
Loading

0 comments on commit f654db6

Please sign in to comment.