Last active
July 10, 2016 12:12
-
-
Save aranair/5401990f6c4f22aa2fe958db2c3bcf92 to your computer and use it in GitHub Desktop.
Test cases for https://github.com/rails/rails/issues/25595
This file contains hidden or 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
| require 'minitest/autorun' | |
| require 'rack/test' | |
| require 'active_record' | |
| require 'logger' | |
| # ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: '25595') | |
| # ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: '25595') | |
| # ActiveRecord::Base.establish_connection(adapter: 'mysql2', database: 'test', user: 'root', password: '') | |
| ActiveRecord::Base.logger = Logger.new(STDOUT) | |
| ActiveRecord::Schema.define do | |
| create_table :tickets, force: true do |t| | |
| t.integer "priority" | |
| t.string "name" | |
| t.boolean "bool" | |
| end | |
| end | |
| class Ticket < ActiveRecord::Base | |
| enum priority: [:high, :middle, :low] | |
| end | |
| class BugTest < Minitest::Test | |
| include Rack::Test::Methods | |
| def test_returns_success | |
| Ticket.create!(priority: :high, name: 'test', bool: false) | |
| Ticket.create!(priority: :high, name: 'test', bool: true) | |
| assert_equal({ true => 1, false => 1}, Ticket.group(:bool).count(:name)) | |
| assert_equal({0 => 2}, Ticket.group(:priority).count) | |
| assert_equal('high', Ticket.first.priority) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment