Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Activate the gem you are reporting the issue against.
- gem 'activerecord', '4.2.5'
- require 'active_record'
- require 'minitest/autorun'
- require 'logger'
- # Ensure backward compatibility with Minitest 4
- Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
- # 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 :users, force: true do |t|
- t.string :email
- end
- create_table :people, force: true do |t|
- t.string :email
- end
- end
- module M
- def email=(value)
- puts "shot!"
- super
- end
- end
- class User < ActiveRecord::Base
- include M
- end
- class Parent < ActiveRecord::Base
- self.abstract_class = true
- include M
- end
- class Person < Parent
- end
- class BugTest < Minitest::Test
- def test_first_or_create
- user = User.where(email: 'email@email.com').first_or_create!
- assert_equal 'email@email.com', user.email
- end
- def test_first_or_create2
- user = Person.where(email: 'email@email.com').first_or_create!
- assert_equal 'email@email.com', user.email
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement