Skip to content

Instantly share code, notes, and snippets.

View bquorning's full-sized avatar

Benjamin Quorning bquorning

View GitHub Profile
@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'
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'
@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 / 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.
# 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 / 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