Skip to content

Instantly share code, notes, and snippets.

@senny
Created August 19, 2014 09:54
Show Gist options
  • Save senny/77106bc1fc684c62e74b to your computer and use it in GitHub Desktop.
Save senny/77106bc1fc684c62e74b to your computer and use it in GitHub Desktop.
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', database: 'test123')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
execute <<-SQL
CREATE OR REPLACE VIEW example_views AS
SELECT 1 AS id, text 'example' AS name
SQL
end
class ExampleView < ActiveRecord::Base; end
class BugTest < Minitest::Test
def test_association_stuff
p ExampleView.first.attributes
p ExampleView.column_names
p ExampleView.first.attribute_names
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment