Skip to content
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
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
matrix:
adapter: [ 'mysql2', 'pg', 'sqlite3' ]
ruby: ['3.3', '3.4', '4.0']
rails: ['~> 7.1.0', '~> 7.2.0', '~> 8.0.0', '~> 8.1.0']

steps:
- name: Checkout
Expand All @@ -68,19 +69,22 @@ jobs:
run: bundle config set path 'vendor/bundle'
working-directory: spec/dummyapp

- name: Install dummyapp dependencies (${{ matrix.adapter }})
- name: Install dummyapp dependencies (${{ matrix.adapter }}, Rails ${{ matrix.rails }})
run: bundle install
working-directory: spec/dummyapp
env:
DATABASE_ADAPTER: ${{ matrix.adapter }}
RAILS_VERSION: ${{ matrix.rails }}

- name: Run dummyapp migrations (${{ matrix.adapter }})
- name: Run dummyapp migrations (${{ matrix.adapter }}, Rails ${{ matrix.rails }})
run: bin/rails db:create
working-directory: spec/dummyapp
env:
DATABASE_ADAPTER: ${{ matrix.adapter }}
RAILS_VERSION: ${{ matrix.rails }}

- name: Run Integration tests (${{ matrix.adapter }})
- name: Run Integration tests (${{ matrix.adapter }}, Rails ${{ matrix.rails }})
run: bundle exec rake spec:integration
env:
DATABASE_ADAPTER: ${{ matrix.adapter }}
RAILS_VERSION: ${{ matrix.rails }}
8 changes: 6 additions & 2 deletions spec/dummyapp/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.0"
gem "rails", ENV.fetch("RAILS_VERSION", "~> 7.1.0")

case ENV['DATABASE_ADAPTER'] # This feels so wrong
when 'mysql2'
gem 'mysql2', '>= 0.5', '< 1'
when 'pg'
gem 'pg', '>= 1.5', '< 2'
when 'sqlite3'
gem 'sqlite3', '>= 1.6', '< 2'
if ENV.fetch("RAILS_VERSION", "~> 7.1.0")[/(\d+)\./, 1].to_i >= 8
gem 'sqlite3', '>= 2.1'
else
gem 'sqlite3', '>= 1.6', '< 2'
end
else
raise 'The environment variable DATABASE_ADAPTER must be one of mysql2, pg, or sqlite3'
end
Expand Down
11 changes: 10 additions & 1 deletion spec/support/aruba.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ def read_file(name)
read(name).join("\n")
end

def rails8?
ENV.fetch("RAILS_VERSION", "~> 7.1.0")[/(\d+)\./, 1].to_i >= 8
end

def models_template_dir
File.join(::Aruba.config.root_directory, "spec/templates/#{ENV["DATABASE_ADAPTER"]}")
File.join(::Aruba.config.root_directory, "spec/templates/pre8/#{ENV["DATABASE_ADAPTER"]}")
end

def migrations_template_dir
File.join(::Aruba.config.root_directory, "spec/templates/migrations")
end

def model_template(name)
if rails8?
rails8_path = File.join(::Aruba.config.root_directory, "spec/templates/rails8/#{ENV["DATABASE_ADAPTER"]}", name)
return rails8_path if File.exist?(rails8_path)
end

File.join(models_template_dir, name)
end

Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions spec/templates/rails8/mysql2/test_default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: test_defaults
#
# id :bigint not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float(24) default(12.34)
# integer :integer default(99)
# string :string(255) default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
class TestDefault < ApplicationRecord
end
20 changes: 20 additions & 0 deletions spec/templates/rails8/mysql2/test_default_updated.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: test_defaults
#
# id :bigint not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float(24) default(12.34)
# int_field :integer
# integer :integer default(99)
# string :string(255) default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
class TestDefault < ApplicationRecord
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true
class TestDefault < ApplicationRecord
end

# == Schema Information
#
# Table name: test_defaults
#
# id :bigint not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float(24) default(12.34)
# integer :integer default(99)
# string :string(255) default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
19 changes: 19 additions & 0 deletions spec/templates/rails8/mysql2/test_sibling_default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: test_defaults
#
# id :bigint not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float(24) default(12.34)
# integer :integer default(99)
# string :string(255) default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
class TestSiblingDefault < TestDefault
end
19 changes: 19 additions & 0 deletions spec/templates/rails8/pg/test_default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: test_defaults
#
# id :bigint not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float default(12.34)
# integer :integer default(99)
# string :string default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
class TestDefault < ApplicationRecord
end
20 changes: 20 additions & 0 deletions spec/templates/rails8/pg/test_default_updated.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: test_defaults
#
# id :bigint not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float default(12.34)
# int_field :integer
# integer :integer default(99)
# string :string default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
class TestDefault < ApplicationRecord
end
19 changes: 19 additions & 0 deletions spec/templates/rails8/pg/test_default_with_bottom_annotations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true
class TestDefault < ApplicationRecord
end

# == Schema Information
#
# Table name: test_defaults
#
# id :bigint not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float default(12.34)
# integer :integer default(99)
# string :string default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
19 changes: 19 additions & 0 deletions spec/templates/rails8/pg/test_sibling_default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: test_defaults
#
# id :bigint not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float default(12.34)
# integer :integer default(99)
# string :string default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
class TestSiblingDefault < TestDefault
end
19 changes: 19 additions & 0 deletions spec/templates/rails8/sqlite3/test_default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: test_defaults
#
# id :integer not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float default(12.34)
# integer :integer default(99)
# string :string default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
class TestDefault < ApplicationRecord
end
20 changes: 20 additions & 0 deletions spec/templates/rails8/sqlite3/test_default_updated.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: test_defaults
#
# id :integer not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float default(12.34)
# int_field :integer
# integer :integer default(99)
# string :string default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
class TestDefault < ApplicationRecord
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true
class TestDefault < ApplicationRecord
end

# == Schema Information
#
# Table name: test_defaults
#
# id :integer not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float default(12.34)
# integer :integer default(99)
# string :string default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
19 changes: 19 additions & 0 deletions spec/templates/rails8/sqlite3/test_sibling_default.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

# == Schema Information
#
# Table name: test_defaults
#
# id :integer not null, primary key
# boolean :boolean default(FALSE)
# date :date default(Tue, 04 Jul 2023)
# datetime :datetime default(2023-07-04 12:34:56.000000000 UTC +00:00)
# decimal :decimal(14, 2) default(43.21)
# float :float default(12.34)
# integer :integer default(99)
# string :string default("hello world!")
# created_at :datetime not null
# updated_at :datetime not null
#
class TestSiblingDefault < TestDefault
end
Loading