Skip to content

Commit 057b67f

Browse files
ric2bMrAsler
andauthored
Support Rails 8 (#48)
Add rails 8 support Co-authored-by: Valter Santos <[email protected]>
1 parent 774107b commit 057b67f

File tree

10 files changed

+42
-21
lines changed

10 files changed

+42
-21
lines changed

.circleci/config.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ version: 2.1
22
jobs:
33
lint:
44
docker:
5-
- image: cimg/ruby:3.1.6
5+
- image: cimg/ruby:3.2.5
66
working_directory: ~/rails-multitenant
77
steps:
88
- checkout
99
- restore_cache:
1010
keys:
11-
- v1-gems-ruby-3.1.6-{{ checksum "rails_multitenant.gemspec" }}-{{ checksum "Gemfile" }}
12-
- v1-gems-ruby-3.1.6-
11+
- v1-gems-ruby-3.2.5-{{ checksum "rails_multitenant.gemspec" }}-{{ checksum "Gemfile" }}
12+
- v1-gems-ruby-3.2.5-
1313
- run:
1414
name: Install Gems
1515
command: |
@@ -18,7 +18,7 @@ jobs:
1818
bundle clean
1919
fi
2020
- save_cache:
21-
key: v1-gems-ruby-3.1.6-{{ checksum "rails_multitenant.gemspec" }}-{{ checksum "Gemfile" }}
21+
key: v1-gems-ruby-3.2.5-{{ checksum "rails_multitenant.gemspec" }}-{{ checksum "Gemfile" }}
2222
paths:
2323
- "vendor/bundle"
2424
- "gemfiles/vendor/bundle"
@@ -76,3 +76,11 @@ workflows:
7676
- 3.1.6
7777
- 3.2.5
7878
- 3.3.5
79+
- test:
80+
matrix:
81+
parameters:
82+
gemfile:
83+
- gemfiles/rails_8.0.gemfile
84+
ruby_version:
85+
- 3.2.5
86+
- 3.3.5

Appraisals

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
appraise 'rails-7.0' do
44
gem 'activerecord', '~> 7.0.8'
55
gem 'activesupport', '~> 7.0.8'
6+
gem 'sqlite3', '~> 1.7'
67
end
78

89
appraise 'rails-7.1' do
@@ -14,3 +15,8 @@ appraise 'rails-7.2' do
1415
gem 'activerecord', '~> 7.2.1'
1516
gem 'activesupport', '~> 7.2.1'
1617
end
18+
19+
appraise 'rails-8.0' do
20+
gem 'activerecord', '~> 8.0.0'
21+
gem 'activesupport', '~> 8.0.0'
22+
end

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.21.0
4+
- Add support for Rails 8.0
5+
36
## 0.20.0
47
* Rails 7.2 support
58
* Drop unsupported rails version 6.1

gemfiles/rails_7.0.gemfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
source "https://rubygems.org"
44

5-
gem "activerecord", "~> 7.0.4"
6-
gem "activesupport", "~> 7.0.4"
5+
gem "activerecord", "~> 7.0.8"
6+
gem "activesupport", "~> 7.0.8"
7+
gem "sqlite3", "~> 1.7"
78

89
gemspec path: "../"

gemfiles/rails_7.1.gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
source "https://rubygems.org"
44

5-
gem "activerecord", "~> 7.1.0"
6-
gem "activesupport", "~> 7.1.0"
5+
gem "activerecord", "~> 7.1.4"
6+
gem "activesupport", "~> 7.1.4"
77

88
gemspec path: "../"

gemfiles/rails_8.0.gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file was generated by Appraisal
2+
3+
source "https://rubygems.org"
4+
5+
gem "activerecord", "~> 8.0.0"
6+
gem "activesupport", "~> 8.0.0"
7+
8+
gemspec path: "../"

lib/rails_multitenant/multitenant_model.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,10 @@ def multitenant_on(context_entity_id_field, required: true)
3333
def multitenant_on_model(context_entity, required: true)
3434
multitenant_on("#{context_entity}_id".to_sym, required: required)
3535

36-
if ActiveRecord::VERSION::MAJOR < 5
37-
belongs_to(context_entity)
38-
else
39-
# Rails 5 added required validation to belongs_to associations and
40-
# an `optional` setting to disable it. We already do validation on
41-
# the foreign key so we always disable the native Rails validation.
42-
belongs_to(context_entity, optional: true)
43-
end
36+
# Rails 5 added required validation to belongs_to associations and
37+
# an `optional` setting to disable it. We already do validation on
38+
# the foreign key so we always disable the native Rails validation.
39+
belongs_to(context_entity, optional: true)
4440
end
4541

4642
def validates_multitenant_uniqueness_of(*attr_names)

lib/rails_multitenant/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module RailsMultitenant
4-
VERSION = '0.20.0'
4+
VERSION = '0.21.0'
55
end

rails_multitenant.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
2626

2727
spec.required_ruby_version = '>= 3.1'
2828

29-
spec.add_dependency 'activerecord', '>= 7.0', '< 7.3'
30-
spec.add_dependency 'activesupport', '>= 7.0', '< 7.3'
29+
spec.add_dependency 'activerecord', '>= 7.0', '< 8.1'
30+
spec.add_dependency 'activesupport', '>= 7.0', '< 8.1'
3131

3232
spec.add_development_dependency 'appraisal'
3333
spec.add_development_dependency 'coveralls'
@@ -37,5 +37,5 @@ Gem::Specification.new do |spec|
3737
spec.add_development_dependency 'rspec_junit_formatter'
3838
spec.add_development_dependency 'salsify_rubocop', '~> 1.27.1'
3939
spec.add_development_dependency 'simplecov', '~> 0.15.1'
40-
spec.add_development_dependency 'sqlite3', '~> 1.6.0'
40+
spec.add_development_dependency 'sqlite3', '~> 2.1'
4141
end

spec/spec_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
end
1313

1414
require 'active_record'
15-
ActiveRecord::Base.belongs_to_required_by_default = true if ActiveRecord::VERSION::MAJOR >= 5
1615

1716
require 'logger'
1817
require 'database_cleaner'

0 commit comments

Comments
 (0)