Created
January 4, 2015 10:29
-
-
Save prathamesh-sonpatki/e76270335ef0246ace59 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
# https://github.com/rails/rails/issues/18273 | |
# Activate the gem you are reporting the issue against. | |
gem 'activerecord', '4.2.0' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
# Ensure backward compatibility with Minitest 4 | |
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test) | |
# This connection will do for database-independent bug reports. | |
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'ar_test_postgres') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :posts, force: true do |t| | |
t.string :bar | |
end | |
end | |
class Post < ActiveRecord::Base | |
def change_bar | |
attribute_will_change!(:bar) | |
self.bar = "bar" | |
end | |
def barbar | |
self.bar = "barbar" | |
end | |
end | |
class BugTest < Minitest::Test | |
def test_association_stuff | |
post = Post.create! | |
post.change_bar | |
post.barbar | |
post.save! | |
assert_equal 'barbar', post.bar | |
end | |
end | |
# $ ruby issue-18273.rb | |
# -- create_table(:posts, {:force=>true}) | |
# D, [2015-01-04T15:57:45.355569 #75381] DEBUG -- : (3.4ms) DROP TABLE "posts" | |
# D, [2015-01-04T15:57:45.361558 #75381] DEBUG -- : (5.7ms) CREATE TABLE "posts" ("id" serial primary key, "bar" character varying) | |
# -> 0.0294s | |
# Run options: --seed 25999 | |
# # Running: | |
# D, [2015-01-04T15:57:45.409134 #75381] DEBUG -- : (0.1ms) BEGIN | |
# D, [2015-01-04T15:57:45.412621 #75381] DEBUG -- : SQL (0.7ms) INSERT INTO "posts" DEFAULT VALUES RETURNING "id" | |
# D, [2015-01-04T15:57:45.413375 #75381] DEBUG -- : (0.3ms) COMMIT | |
# D, [2015-01-04T15:57:45.413674 #75381] DEBUG -- : (0.1ms) BEGIN | |
# D, [2015-01-04T15:57:45.418277 #75381] DEBUG -- : SQL (0.3ms) UPDATE "posts" SET "bar" = $1 WHERE "posts"."id" = $2 [["bar", "barbar"], ["id", 1]] | |
# D, [2015-01-04T15:57:45.418717 #75381] DEBUG -- : (0.3ms) COMMIT | |
# . | |
# Finished in 0.019245s, 51.9615 runs/s, 51.9615 assertions/s. | |
# 1 runs, 1 assertions, 0 failures, 0 errors, 0 skips |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment