Last active
November 29, 2016 20:11
-
-
Save max-reznichenko/31b31d335f8fe80853cf049584970725 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
require "rails/all" | |
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 :roles, force: true do |t| | |
t.string :name | |
t.datetime "created_at", null: false | |
t.datetime "updated_at", null: false | |
end | |
end | |
class TestApp < Rails::Application | |
config.root = File.dirname(__FILE__) | |
secrets.secret_token = "secret_token" | |
secrets.secret_key_base = "secret_key_base" | |
config.logger = Logger.new($stdout) | |
Rails.logger = config.logger | |
config.time_zone = 'Brasilia' | |
config.active_record.default_timezone = 'Brasilia' | |
end | |
class Role < ActiveRecord::Base | |
end | |
class BugTest < Minitest::Test | |
def test_26892_utc | |
Role.default_timezone = 'utc' | |
Role.create!(name: name) | |
result = ActiveRecord::Base.connection.execute("select * from roles where id = 1") | |
data = result.first | |
assert data.keys.include?('created_at') | |
assert data.keys.include?('updated_at') | |
role = Role.last | |
refute_nil role.created_at | |
refute_nil role.updated_at | |
end | |
def test_26892_brasilia | |
assert ActiveSupport::TimeZone::MAPPING.include?('Brasilia') | |
Role.default_timezone = 'Brasilia' | |
Role.create!(name: name) | |
result = ActiveRecord::Base.connection.execute("select * from roles where id = 1") | |
data = result.first | |
assert data.keys.include?('created_at') | |
assert data.keys.include?('updated_at') | |
role = Role.last | |
refute_nil role.created_at | |
refute_nil role.updated_at | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment