Skip to content

Instantly share code, notes, and snippets.

View bquorning's full-sized avatar

Benjamin Quorning bquorning

View GitHub Profile
@bquorning
bquorning / flatten.rb
Created February 19, 2018 20:53
Did Ruby 2.5 introduce a new bug, or fix an old bug? The implicit `flatten` -> `to_ary` -> `respond_to_missing` call has changed.
class A
def respond_to?(method, include_all = false)
::Kernel.puts "respond_to?(#{method.inspect}, #{include_all.inspect})"
end
end
class B
def respond_to_missing?(method, include_all = false)
::Kernel.puts "respond_to_missing?(#{method.inspect}, #{include_all.inspect})"
end
# Run this script with `ruby rspec-rails-json-controller-params.rb`
# It will spawn two processes: one using Minitest, one using RSpec.
if ARGV.empty?
puts `ruby #{__FILE__} test`
puts `ruby #{__FILE__} spec`
exit
end
require "bundler/inline"
@bquorning
bquorning / store-issue-rails-4.rb
Last active July 4, 2016 12:06
An instance of ActionController::Parameters stored in a column as YAML with Rails 4, cannot be read with Rails 5.
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'
# Activate the gem you are reporting the issue against.
@bquorning
bquorning / hash-with-ivars.rb
Last active July 4, 2016 11:21
Models using `store` to serialize a `Hash` in the form of `ActionController::Parameters` in Rails 4 cannot read that same column in Rails 5.
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'
# Activate the gem you are reporting the issue against.
@bquorning
bquorning / gist.rb
Last active April 20, 2016 15:17
ActiveRecord trying to save readonly records on has_many_through assignment. It looks like the bug was introduced by https://github.com/rails/rails/commit/d849f42b4ecf687ed5350f5a2402fb795aa33aac, and it should probably check `if !record.readonly?` and not just remove the condition.
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '5.0.0.beta3'
gem 'sqlite3'
end
require 'active_record'
require 'minitest/autorun'
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'
# Activate the gem you are reporting the issue against.
@bquorning
bquorning / action_controller_gem.rb
Last active March 20, 2016 10:45
Run with `rspec action_controller_gem.rb`. Fails as it is, but works with https://github.com/rspec/rspec-rails/pull/1568 applied.
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'
gem 'rails', '5.0.0.beta3'
@bquorning
bquorning / active_record_master.rb
Last active March 7, 2016 13:53
Eager loaded belongs_to associations are always readonly
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'
gem 'rails', github: 'rails/rails'
#!/bin/sh
STAGED=$(git diff --cached --name-only --diff-filter=ACM | grep -e '\.rb$' -e '\.rake$' -e '\.ru$' -e Capfile -e 'Gemfile$')
if [ "$STAGED" ]; then
./bin/rubocop -- $STAGED
fi
@bquorning
bquorning / gist:460ad070893cbe498df5
Last active August 29, 2015 14:16
Uniqueness validation bug in Rails 4.1.10.rc1
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '4.1.10.rc1'
gem 'sqlite3'
GEMFILE
system 'bundle'
end