Skip to content

Commit

Permalink
Merge pull request #617 from juanmanuelramallo/ruby-3-support-migrati…
Browse files Browse the repository at this point in the history
…on-extension

Ruby 3 support
  • Loading branch information
semmons99 authored Feb 27, 2021
2 parents cac3e2b + 9cd0042 commit 36d4ea6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.6', '2.7']
ruby-version: ['2.6', '2.7', '3.0']
mongodb-version: ['4.4']
sqlite-version: ['3.0']

Expand Down
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ namespace :spec do
framework, version = file_name.split(/(\d+)/)
major, minor = version.split(//)

# Ruby 3 exclusions
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
# Rails 5 does not support ruby-3.0.0 https://github.com/rails/rails/issues/40938#issuecomment-751569171
# Mongoid gem does not yet support ruby-3.0.0 https://github.com/mongodb/mongoid#compatibility
next if framework == 'mongoid' || (framework == 'rails' && version == "5")
end

frameworks_versions[framework] ||= []
frameworks_versions[framework] << file_name

Expand Down
4 changes: 2 additions & 2 deletions lib/money-rails/active_model/validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ def add_error!(record, attr, details)
attr_name = attr.to_s.tr('.', '_').humanize
attr_name = record.class.human_attribute_name(attr, default: attr_name)

record.errors.add(attr, :invalid_currency, {
record.errors.add(attr, :invalid_currency,
thousands: details.thousands_separator,
decimal: details.decimal_mark,
currency: details.abs_raw_value,
attribute: attr_name
})
)
end

def value_has_too_many_decimal_points(details)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module SchemaStatements
def add_monetize(table_name, accessor, options={})
[:amount, :currency].each do |attribute|
column_present, *opts = OptionsExtractor.extract attribute, table_name, accessor, options
add_column(*opts) if column_present
constraints = opts.pop
add_column(*opts, **constraints) if column_present
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module Table
def monetize(accessor, options={})
[:amount, :currency].each do |attribute|
column_present, _, *opts = OptionsExtractor.extract attribute, :no_table, accessor, options
column(*opts) if column_present
constraints = opts.pop
column(*opts, **constraints) if column_present
end
end

Expand Down
10 changes: 5 additions & 5 deletions spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

Expand Down

0 comments on commit 36d4ea6

Please sign in to comment.