Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. # Activate the gem you are reporting the issue against.
  2. gem 'activerecord', '4.2.5'
  3. require 'active_record'
  4. require 'minitest/autorun'
  5. require 'logger'
  6.  
  7. # Ensure backward compatibility with Minitest 4
  8. Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
  9.  
  10. # This connection will do for database-independent bug reports.
  11. ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
  12. ActiveRecord::Base.logger = Logger.new(STDOUT)
  13.  
  14. ActiveRecord::Schema.define do
  15. create_table :users, force: true do |t|
  16. t.string :email
  17. end
  18. create_table :people, force: true do |t|
  19. t.string :email
  20. end
  21. end
  22.  
  23. module M
  24. def email=(value)
  25. puts "shot!"
  26. super
  27. end
  28. end
  29.  
  30. class User < ActiveRecord::Base
  31. include M
  32. end
  33.  
  34. class Parent < ActiveRecord::Base
  35. self.abstract_class = true
  36. include M
  37. end
  38.  
  39. class Person < Parent
  40. end
  41.  
  42. class BugTest < Minitest::Test
  43. def test_first_or_create
  44. user = User.where(email: 'email@email.com').first_or_create!
  45.  
  46. assert_equal 'email@email.com', user.email
  47. end
  48.  
  49. def test_first_or_create2
  50. user = Person.where(email: 'email@email.com').first_or_create!
  51.  
  52. assert_equal 'email@email.com', user.email
  53. end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement