Created
February 23, 2019 01:16
-
-
Save StefanoDeVuono/1c237faf723ae4ffa65a9aa08c97048e to your computer and use it in GitHub Desktop.
This file contains 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" } | |
# Activate the gem you are reporting the issue against. | |
gem "activerecord", "4.2.11" | |
gem 'pg', '~> 0.18.2' | |
end | |
require "active_record" | |
require "minitest/autorun" | |
require "logger" | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: "postgresql", database: "postgres") | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
enable_extension "uuid-ossp" | |
create_table :test_cases, force: true do |t| | |
t.uuid 'uuid', default: "uuid_generate_v1()", null: false | |
t.integer 'number', default: 42, null: false | |
end | |
end | |
class TestCase < ActiveRecord::Base | |
end | |
class BugTest < Minitest::Test | |
def test_schema_load | |
TestCase.reset_column_information | |
columns = {} | |
TestCase.columns.each { |col| columns[col.name] = col} | |
assert_equal "42", columns['number'].default | |
refute columns['number'].null | |
assert_equal "uuid_generate_v1()", columns['uuid'].default_function | |
refute columns['uuid'].null | |
end | |
def teardown | |
ActiveRecord::Base.connection.execute 'DROP TABLE test_cases;' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment