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

feat: adding support for rails 6 and 7 #73

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
15 changes: 10 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ jobs:
ruby:
- 2.7
- 2.6
- 2.5
- 2.4
- jruby
gemfile:
- Rails-7_0
- Rails-6_1
- Rails-6_0
- Rails-5_2
- Rails-5_1
- Rails-5_0
backend:
- sqlite3
- mysql
Expand All @@ -37,6 +36,10 @@ jobs:
# Allow test failures for some configurations
- ruby: jruby
allow-failures: true
exclude:
# Rails 7 depends on ruby 2.7
- ruby: 2.6
gemfile: Rails-7_0

env:
# For Bundler control variables, refer to:
Expand Down Expand Up @@ -78,7 +81,7 @@ jobs:
username: root
password: verysecret
database: activeid_test
encoding: utf8mb4
encoding: binary
EOF

- name: Run tests (with monkey patches)
Expand All @@ -98,6 +101,8 @@ jobs:
env:
MYSQL_ROOT_PASSWORD: verysecret
MYSQL_DATABASE: activeid_test
MARIADB_DEFAULT_CHARACTER_SET: binary
MARIADB_DEFAULT_COLLATE: binary
options: >-
--health-cmd="mysqladmin ping"
--health-interval=7s
Expand Down
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
inherit_from:
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml

# .rubocop.yml

require:
- rubocop-performance
- rubocop-rails

AllCops:
DisplayCopNames: false
StyleGuideCopsOnly: false
Expand Down
8 changes: 6 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ source "http://rubygems.org"
# Specify your gem's dependencies in activeid.gemspec
gemspec

gem "codecov", require: false, group: :test
gem "simplecov", require: false, group: :test
group :test do
gem "codecov", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "simplecov", require: false
end
6 changes: 3 additions & 3 deletions activeid.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-

$:.push File.expand_path("../lib", __FILE__)
require "active_id/version"
require "activeid/version"

Gem::Specification.new do |s|
s.name = "activeid"
Expand Down Expand Up @@ -34,9 +34,9 @@ Gem::Specification.new do |s|
else
s.add_development_dependency "mysql2"
s.add_development_dependency "pg"
s.add_development_dependency "sqlite3", "~> 1.3.6"
s.add_development_dependency "sqlite3", "~> 1.4.0"
end

s.add_runtime_dependency "activerecord", ">= 5.0", "< 6.0"
s.add_runtime_dependency "activerecord", ">= 5.2", "< 7.1"
s.add_runtime_dependency "uuidtools"
end
2 changes: 1 addition & 1 deletion examples/name_based_uuids.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require "bundler/setup"
Bundler.require :development

require "active_id"
require "activeid"
require_relative "../spec/support/0_logger"
require_relative "../spec/support/1_db_connection"

Expand Down
2 changes: 1 addition & 1 deletion examples/registering_active_record_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require "bundler/setup"
Bundler.require :development

require "active_id"
require "activeid"
require_relative "../spec/support/0_logger"
require_relative "../spec/support/1_db_connection"

Expand Down
2 changes: 1 addition & 1 deletion examples/storing_uuids_as_binaries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require "bundler/setup"
Bundler.require :development

require "active_id"
require "activeid"
require_relative "../spec/support/0_logger"
require_relative "../spec/support/1_db_connection"

Expand Down
2 changes: 1 addition & 1 deletion examples/storing_uuids_as_strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "bundler/setup"
Bundler.require :development

require "active_id"
require "activeid"
require_relative "../spec/support/0_logger"
require_relative "../spec/support/1_db_connection"

Expand Down
2 changes: 1 addition & 1 deletion examples/storing_uuids_natively.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
require "bundler/setup"
Bundler.require :development

require "active_id"
require "activeid"
require_relative "../spec/support/0_logger"
require_relative "../spec/support/1_db_connection"

Expand Down
2 changes: 1 addition & 1 deletion examples/time_based_uuids.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require "bundler/setup"
Bundler.require :development

require "active_id"
require "activeid"
require_relative "../spec/support/0_logger"
require_relative "../spec/support/1_db_connection"

Expand Down
6 changes: 3 additions & 3 deletions examples/using_migrations.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Active UUID features a convenience #uuid method, which may be used to create
# a binary column in database migration. Since it involves monkey patching,
# "active_id/all" must be loaded.
# "activeid/all" must be loaded.

ENV["DB"] ||= "sqlite3"

require "bundler/setup"
Bundler.require :development

# Note "active_id/all", which registers new column definitions!
require "active_id/all"
# Note "activeid/all", which registers new column definitions!
require "activeid/all"

require_relative "../spec/support/0_logger"
require_relative "../spec/support/1_db_connection"
Expand Down
8 changes: 0 additions & 8 deletions gemfiles/Rails-5_0.gemfile

This file was deleted.

8 changes: 0 additions & 8 deletions gemfiles/Rails-5_1.gemfile

This file was deleted.

8 changes: 6 additions & 2 deletions gemfiles/Rails-5_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ gemspec path: "../"

gem "activerecord", "~> 5.2.0"

gem "codecov", require: false, group: :test
gem "simplecov", require: false, group: :test
group :test do
gem "codecov", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "simplecov", require: false
end
12 changes: 12 additions & 0 deletions gemfiles/Rails-6_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source "http://rubygems.org"

gemspec path: "../"

gem "activerecord", "~> 6.0.0"

group :test do
gem "codecov", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "simplecov", require: false
end
12 changes: 12 additions & 0 deletions gemfiles/Rails-6_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source "http://rubygems.org"

gemspec path: "../"

gem "activerecord", "~> 6.1.0"

group :test do
gem "codecov", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "simplecov", require: false
end
12 changes: 12 additions & 0 deletions gemfiles/Rails-7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source "http://rubygems.org"

gemspec path: "../"

gem "activerecord", "~> 7.0.0"

group :test do
gem "codecov", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "simplecov", require: false
end
8 changes: 6 additions & 2 deletions gemfiles/Rails-head.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ gemspec path: "../"

gem "activerecord", github: "rails/rails"

gem "codecov", require: false, group: :test
gem "simplecov", require: false, group: :test
group :test do
gem "codecov", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
gem "simplecov", require: false
end
12 changes: 0 additions & 12 deletions lib/active_id.rb

This file was deleted.

12 changes: 12 additions & 0 deletions lib/activeid.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require "activeid/version"
require "activeid/utils"
require "activeid/model"
require "activeid/type"
require "activeid/railtie" if defined?(Rails::Railtie)
require "pp"

module ActiveID
class << self
delegate :quote_as_binary, to: Utils
end
end
2 changes: 1 addition & 1 deletion lib/active_id/all.rb → lib/activeid/all.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require_relative "../active_id"
require_relative "../activeid"
require_relative "connection_patches"
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
require "active_record"
require "active_support/concern"
require "active_id/railtie" if defined?(Rails::Railtie)

module ActiveID
module ConnectionPatches
module ColumnMethods
def uuid(*args, **options)
args.each { |name| column(name, :uuid, options) }
args.each { |name| column(name, :uuid, **options) }
end
end

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/active_id/railtie.rb → lib/activeid/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "active_id"
require "activeid"
require "rails"

module ActiveID
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
Bundler.require :development

if ENV.fetch("NO_PATCHES", false)
require "active_id"
require "activeid"
else
require "active_id/all"
require "activeid/all"
end

Dir[File.expand_path("support/**/*.rb", __dir__)].sort.each { |f| require f }
Expand Down