Skip to content

Commit

Permalink
Support Rails 8 (#48)
Browse files Browse the repository at this point in the history
Add rails 8 support

Co-authored-by: Valter Santos <[email protected]>
  • Loading branch information
ric2b and MrAsler authored Nov 8, 2024
1 parent 774107b commit 057b67f
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 21 deletions.
16 changes: 12 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: 2.1
jobs:
lint:
docker:
- image: cimg/ruby:3.1.6
- image: cimg/ruby:3.2.5
working_directory: ~/rails-multitenant
steps:
- checkout
- restore_cache:
keys:
- v1-gems-ruby-3.1.6-{{ checksum "rails_multitenant.gemspec" }}-{{ checksum "Gemfile" }}
- v1-gems-ruby-3.1.6-
- v1-gems-ruby-3.2.5-{{ checksum "rails_multitenant.gemspec" }}-{{ checksum "Gemfile" }}
- v1-gems-ruby-3.2.5-
- run:
name: Install Gems
command: |
Expand All @@ -18,7 +18,7 @@ jobs:
bundle clean
fi
- save_cache:
key: v1-gems-ruby-3.1.6-{{ checksum "rails_multitenant.gemspec" }}-{{ checksum "Gemfile" }}
key: v1-gems-ruby-3.2.5-{{ checksum "rails_multitenant.gemspec" }}-{{ checksum "Gemfile" }}
paths:
- "vendor/bundle"
- "gemfiles/vendor/bundle"
Expand Down Expand Up @@ -76,3 +76,11 @@ workflows:
- 3.1.6
- 3.2.5
- 3.3.5
- test:
matrix:
parameters:
gemfile:
- gemfiles/rails_8.0.gemfile
ruby_version:
- 3.2.5
- 3.3.5
6 changes: 6 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
appraise 'rails-7.0' do
gem 'activerecord', '~> 7.0.8'
gem 'activesupport', '~> 7.0.8'
gem 'sqlite3', '~> 1.7'
end

appraise 'rails-7.1' do
Expand All @@ -14,3 +15,8 @@ appraise 'rails-7.2' do
gem 'activerecord', '~> 7.2.1'
gem 'activesupport', '~> 7.2.1'
end

appraise 'rails-8.0' do
gem 'activerecord', '~> 8.0.0'
gem 'activesupport', '~> 8.0.0'
end
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.21.0
- Add support for Rails 8.0

## 0.20.0
* Rails 7.2 support
* Drop unsupported rails version 6.1
Expand Down
5 changes: 3 additions & 2 deletions gemfiles/rails_7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

source "https://rubygems.org"

gem "activerecord", "~> 7.0.4"
gem "activesupport", "~> 7.0.4"
gem "activerecord", "~> 7.0.8"
gem "activesupport", "~> 7.0.8"
gem "sqlite3", "~> 1.7"

gemspec path: "../"
4 changes: 2 additions & 2 deletions gemfiles/rails_7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "https://rubygems.org"

gem "activerecord", "~> 7.1.0"
gem "activesupport", "~> 7.1.0"
gem "activerecord", "~> 7.1.4"
gem "activesupport", "~> 7.1.4"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rails_8.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "activerecord", "~> 8.0.0"
gem "activesupport", "~> 8.0.0"

gemspec path: "../"
12 changes: 4 additions & 8 deletions lib/rails_multitenant/multitenant_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ def multitenant_on(context_entity_id_field, required: true)
def multitenant_on_model(context_entity, required: true)
multitenant_on("#{context_entity}_id".to_sym, required: required)

if ActiveRecord::VERSION::MAJOR < 5
belongs_to(context_entity)
else
# Rails 5 added required validation to belongs_to associations and
# an `optional` setting to disable it. We already do validation on
# the foreign key so we always disable the native Rails validation.
belongs_to(context_entity, optional: true)
end
# Rails 5 added required validation to belongs_to associations and
# an `optional` setting to disable it. We already do validation on
# the foreign key so we always disable the native Rails validation.
belongs_to(context_entity, optional: true)
end

def validates_multitenant_uniqueness_of(*attr_names)
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_multitenant/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RailsMultitenant
VERSION = '0.20.0'
VERSION = '0.21.0'
end
6 changes: 3 additions & 3 deletions rails_multitenant.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 3.1'

spec.add_dependency 'activerecord', '>= 7.0', '< 7.3'
spec.add_dependency 'activesupport', '>= 7.0', '< 7.3'
spec.add_dependency 'activerecord', '>= 7.0', '< 8.1'
spec.add_dependency 'activesupport', '>= 7.0', '< 8.1'

spec.add_development_dependency 'appraisal'
spec.add_development_dependency 'coveralls'
Expand All @@ -37,5 +37,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rspec_junit_formatter'
spec.add_development_dependency 'salsify_rubocop', '~> 1.27.1'
spec.add_development_dependency 'simplecov', '~> 0.15.1'
spec.add_development_dependency 'sqlite3', '~> 1.6.0'
spec.add_development_dependency 'sqlite3', '~> 2.1'
end
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
end

require 'active_record'
ActiveRecord::Base.belongs_to_required_by_default = true if ActiveRecord::VERSION::MAJOR >= 5

require 'logger'
require 'database_cleaner'
Expand Down

0 comments on commit 057b67f

Please sign in to comment.