Last active
April 25, 2018 20:10
-
-
Save axlekb/6dfbfa45dd5e6137cb172e9cb37f4909 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
gem "bundler", "< 1.16" | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "pg", "<1.0" | |
#gem "rails", "5.1.4" # success! | |
gem "rails", "5.2.0" # fails! | |
end | |
require "active_record" | |
require "minitest/autorun" | |
require "logger" | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
ActiveRecord::Base.establish_connection( | |
adapter: "postgresql", | |
database: "rails_test", | |
username: "user", | |
password: "", | |
host: 'localhost' | |
) | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :payments, force: true do |t| | |
t.money :cash | |
end | |
end | |
class Payment < ActiveRecord::Base | |
validates :cash, numericality: true, unless: :new_record? | |
end | |
class BugTest < Minitest::Test | |
def test_numeric_validation | |
payment = Payment.create!(cash: 2.0) | |
payment.reload | |
assert payment.cash == 2.0 | |
assert payment.valid? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found a syntax error -
https://gist.github.com/axlekb/6dfbfa45dd5e6137cb172e9cb37f4909#file-bug_test-rb-L51
Should be
Payment.create!(cash: 2.0)