Created
July 28, 2020 09:32
-
-
Save rept/23a9d775ea59f2d43510188c4d5d120a 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
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', '6.0.3' | |
gem 'pg' | |
GEMFILE | |
system 'bundle' | |
end | |
require 'bundler' | |
Bundler.setup(:default) | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'rails_test', default_timezone: 'UTC') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
enable_extension "hstore" | |
create_table :posts do |t| | |
t.datetime "datetimes", default: [], array: true | |
end | |
end | |
class Post < ActiveRecord::Base | |
# removing this will make it work | |
self.default_timezone = 'UTC' | |
end | |
class BugTest < MiniTest::Unit::TestCase | |
def test_stuff | |
time = Time.now | |
post = Post.create(datetimes: [time]) | |
post.reload | |
assert_equal [time], post.datetimes | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment