Skip to content

Instantly share code, notes, and snippets.

@StefanH
Created February 20, 2012 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StefanH/1868608 to your computer and use it in GitHub Desktop.
Save StefanH/1868608 to your computer and use it in GitHub Desktop.
reproduces issue 3965 config.time_zone and datetime update
gem 'rails', '3.2.1'
require 'active_record'
# Print out what version we're running
puts "Active Record #{ActiveRecord::VERSION::STRING}"
ActiveRecord::Base.time_zone_aware_attributes = true
ActiveRecord::Base.default_timezone = :utc
Time.zone = 'Amsterdam'
# Connect to an in-memory sqlite3 database
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:'
)
# Create schema
ActiveRecord::Schema.define do
create_table :foos, :force => true do |t|
t.datetime :bar
end
end
# Create the a model
class Foo < ActiveRecord::Base
end
# reproduce bug
foo = Foo.create(:bar => "2012-02-20 10:00:00")
foo.bar = "2012-02-20 09:00:00"
# expected: true
puts foo.bar_changed?
foo.bar = "2012-02-20 10:00:00"
# expected: false
puts foo.bar_changed?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment