Created
January 21, 2019 23:27
-
-
Save Edouard-chin/e8a7dd6be3358c05c570ea33c5ec3c84 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 | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", github: "rails/rails" | |
gem "sqlite3" | |
end | |
require "active_record" | |
require "minitest/autorun" | |
require "logger" | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :posts, force: true do |t| | |
t.decimal :integer | |
end | |
end | |
class Post < ActiveRecord::Base | |
attribute :total_price, :decimal | |
validates :total_price, numericality: { only_integer: true } | |
end | |
class BugTest < Minitest::Test | |
def test_dup_record | |
post = Post.new(total_price: 4) | |
second_post = post.dup | |
assert post.save! | |
assert second_post.valid? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment