From 8158fa8b07d1b3b5623bee73b1d0540fd6726419 Mon Sep 17 00:00:00 2001 From: "Andrew S. Brown" Date: Tue, 9 Sep 2014 22:00:36 -0700 Subject: [PATCH] add spec for converting an AR model into an id --- .../adapters/active_record/relation_extensions_spec.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spec/squeel/adapters/active_record/relation_extensions_spec.rb b/spec/squeel/adapters/active_record/relation_extensions_spec.rb index 48de1d6..9e98cfb 100644 --- a/spec/squeel/adapters/active_record/relation_extensions_spec.rb +++ b/spec/squeel/adapters/active_record/relation_extensions_spec.rb @@ -717,6 +717,13 @@ module ActiveRecord Person.first.authored_article_comments.joins(:article).first.should eq Comment.first end + it 'does not break hash conditions that specify the table name' do + person = Comment.first.article.person + person.should be_present + Comment.joins(:article).where(articles: {person_id: person}).should be_present + Comment.joins(:article).where(articles: {person: person}).should be_present + end + it 'joins polymorphic belongs_to associations' do relation = Note.joins{notable(Article)} relation.to_sql.should match /#{Q}notes#{Q}.#{Q}notable_type#{Q} = 'Article'/