Skip to content

Instantly share code, notes, and snippets.

@kuldeepaggarwal
Created October 28, 2014 16:03
Show Gist options
  • Save kuldeepaggarwal/bf7cd27ab0dee9835659 to your computer and use it in GitHub Desktop.
Save kuldeepaggarwal/bf7cd27ab0dee9835659 to your computer and use it in GitHub Desktop.
Issue 17415
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '4.1.6'
gem 'pg', '~> 0.17.1'
gem 'minitest'
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',
encoding: 'utf8',
database: 'kd_test',
username: 'username',
password: 'password',
host: 'localhost')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :tasks, force: true do |t|
t.boolean :counselor
end
end
class Task < ActiveRecord::Base
end
class BugTest < MiniTest::Test
def test_timestamp_array
c = Task.create counselor: false
puts c.inspect
assert !Task.find(1).counselor
assert !Task.find(1).counselor?
end
end
# OutPut:
-- create_table(:tasks, {:force=>true})
D, [2014-10-28T21:28:01.923655 #30697] DEBUG -- : (9.3ms) DROP TABLE "tasks"
D, [2014-10-28T21:28:01.928628 #30697] DEBUG -- : (4.7ms) CREATE TABLE "tasks" ("id" serial primary key, "counselor" boolean)
-> 0.0352s
Run options: --seed 14118
# Running:
D, [2014-10-28T21:28:01.958982 #30697] DEBUG -- : (0.3ms) BEGIN
D, [2014-10-28T21:28:01.980679 #30697] DEBUG -- : SQL (0.6ms) INSERT INTO "tasks" ("counselor") VALUES ($1) RETURNING "id" [["counselor", "f"]]
D, [2014-10-28T21:28:01.981266 #30697] DEBUG -- : (0.3ms) COMMIT
#<Task id: 1, counselor: false>
D, [2014-10-28T21:28:01.983705 #30697] DEBUG -- : Task Load (0.5ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = $1 LIMIT 1 [["id", 1]]
D, [2014-10-28T21:28:01.986042 #30697] DEBUG -- : Task Load (0.5ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."id" = $1 LIMIT 1 [["id", 1]]
.
Finished in 0.039028s, 25.6226 runs/s, 51.2453 assertions/s.
1 runs, 2 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