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

Add support for testing with multiple Rails versions #1673

Merged
merged 1 commit into from
Nov 16, 2019
Merged
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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
strategy:
fail-fast: false
matrix:
rails:
- '5.2'
- '6.0'
ruby:
- '2.5.x'
- '2.6.x'
Expand All @@ -20,6 +23,7 @@ jobs:
PGHOST: 127.0.0.1
PGUSER: postgres
RAILS_ENV: test
RAILS_VERSION: ${{ matrix.rails }}
CC_TEST_REPORTER_ID: bca4349e32f97919210ac8a450b04904b90683fcdd57d65a22c0f5065482bc22
services:
postgres:
Expand Down Expand Up @@ -48,7 +52,7 @@ jobs:
uses: actions/cache@preview
with:
path: vendor/bundle
key: ${{ runner.os }}-bundle-${{ matrix.ruby }}-${{ matrix.database }}-${{ hashFiles('**/Gemfile') }}
key: ${{ runner.os }}-bundle-${{ matrix.ruby }}-${{ matrix.rails }}-${{ matrix.database }}-${{ hashFiles('**/Gemfile') }}
restore-keys: |
${{ runner.os }}-bundle-
- name: Install bundle
Expand Down
7 changes: 5 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ source 'https://rubygems.org'

gemspec

gem 'rails', '~> 6.0.0'
rails_version = ENV.fetch('RAILS_VERSION', 6.0).to_f
gem 'rails', "~> #{rails_version}.0"

# Profiling
gem 'rack-mini-profiler', group: :development, require: false

gem 'sqlite3', '~> 1.4.1' if ENV['DB'].nil? || ENV['DB'] == 'sqlite'
if ENV['DB'].nil? || ENV['DB'] == 'sqlite'
gem 'sqlite3', rails_version > 5.0 ? '~> 1.4.1' : '~> 1.3.6'
end
gem 'mysql2', '~> 0.5.1' if ENV['DB'] == 'mysql'
gem 'pg', '~> 1.0' if ENV['DB'] == 'postgresql'
gem 'sassc-rails'
Expand Down
4 changes: 3 additions & 1 deletion spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
module Dummy
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
if config.respond_to?(:load_defaults)
config.load_defaults ENV['RAILS_VERSION'] || 6.0
end

# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
Expand Down
6 changes: 4 additions & 2 deletions spec/dummy/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
if ActiveRecord::Base.respond_to?(:verbose_query_logs=)
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
end

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20180409171801_create_series.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateSeries < ActiveRecord::Migration[5.1]
class CreateSeries < ActiveRecord::Migration[5.0]
def change
create_table :series do |t|
t.string :name
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/db/migrate/20190417070726_create_bookings.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CreateBookings < ActiveRecord::Migration[5.2]
class CreateBookings < ActiveRecord::Migration[5.0]
def change
create_table :bookings do |t|
t.date :from
Expand Down