Created
April 26, 2018 18:34
-
-
Save utilum/bbe3e370e6a9518b17e7c61d81bccd43 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
# frozen_string_literal: true | |
begin | |
require "bundler/inline" | |
rescue LoadError => e | |
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" | |
raise e | |
end | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", github: "rails/rails" | |
gem "sqlite3" | |
end | |
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 :posts, force: true do |t| | |
t.string :column | |
t.string :ignored | |
end | |
end | |
class Post < ActiveRecord::Base | |
end | |
Post.create!(column: 'value', ignored: 'another value') | |
class Post < ActiveRecord::Base | |
self.ignored_columns = [:ignored] | |
end | |
class BugTest < Minitest::Test | |
def test_ignored | |
assert_equal ['ignored'], Post.ignored_columns | |
end | |
def test_attributes | |
expected_attributes = { | |
'id' => 1, | |
'column' => 'value', | |
} | |
assert_equal expected_attributes, Post.first.attributes | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment