diff options
| author | Washington Luiz <huoxito@gmail.com> | 2015-05-19 00:18:44 -0300 | 
|---|---|---|
| committer | Washington Luiz <huoxito@gmail.com> | 2015-05-28 01:49:34 -0300 | 
| commit | a01d164b948371c3405635713d9361f67d10a8bf (patch) | |
| tree | 19b4b48ba170f6d879bb3e089286bde1ed7cfa2f /activerecord/test/cases/adapters/postgresql/numbers_test.rb | |
| parent | d0a370ec93c7e1118f3f58effe2e64712d3492bd (diff) | |
| download | rails-a01d164b948371c3405635713d9361f67d10a8bf.tar.gz rails-a01d164b948371c3405635713d9361f67d10a8bf.tar.bz2 rails-a01d164b948371c3405635713d9361f67d10a8bf.zip | |
Properly append preload / includes args on Merger
Couldn't find other way to get the association name from a given class
other than looping through `reflect_on_all_associations` reflections ..
Noticed this one while looking at this example:
```ruby
class Product < ActiveRecord::Base
  has_many :variants
  has_many :translations
end
class Translation < ActiveRecord::Base
  belongs_to :product
end
class Variant < ActiveRecord::Base
  belongs_to :product
end
class BugTest < Minitest::Test
  def test_merge_stuff
    product = Product.create! name: 'huhu'
    variant = Variant.create! product_id: product.id
    Translation.create! locale: 'en', product_id: product.id
    product_relation = Product.all
                              .preload(:translations)
                              .joins(:translations)
                              .merge(Translation.where(locale: 'en'))
                              .where(name: 'huhu')
    assert_equal variant, Variant.joins(:product).merge(product_relation).first
  end
end
```
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/numbers_test.rb')
0 files changed, 0 insertions, 0 deletions
