diff --git a/Gemfile b/Gemfile index 2a30020..c5d195b 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ else gem 'activerecord', ENV['AR'] end -git 'https://github.com/activerecord-hackery/ransack', branch: 'master' do +git 'https://github.com/gregmolnar/ransack', branch: 'fix-polymorphic-joins' do gem 'polyamorous' end diff --git a/spec/integration/__snapshots__/where_chain_spec.yaml b/spec/integration/__snapshots__/where_chain_spec.yaml index fe6ff39..3bb8f6e 100644 --- a/spec/integration/__snapshots__/where_chain_spec.yaml +++ b/spec/integration/__snapshots__/where_chain_spec.yaml @@ -94,3 +94,6 @@ FROM "posts" WHERE "posts"."author_id" = 42 "#where.has wheres an association using #!= 1 (Active Record: v5.2)": SELECT "posts".* FROM "posts" WHERE "posts"."author_id" != 42 +"#where.has wheres on polymorphic associations 1 (Active Record: v5.2)": SELECT "pictures".* + FROM "pictures" INNER JOIN "posts" ON "posts"."id" = "pictures"."imageable_id" AND + "pictures"."imageable_type" = 'Post' WHERE "posts"."title" LIKE 'meatloaf' diff --git a/spec/integration/joining_spec.rb b/spec/integration/joining_spec.rb index 3a2fd24..a53c2e4 100644 --- a/spec/integration/joining_spec.rb +++ b/spec/integration/joining_spec.rb @@ -122,20 +122,12 @@ describe 'polymorphism' do it 'inner joins' do - if ActiveRecord::VERSION::STRING >= '5.2.0' - pending "polyamorous's support for polymorphism is broken" - end - relation = Picture.joining { imageable.of(Post) } expect(relation).to match_sql_snapshot end it 'outer joins' do - if ActiveRecord::VERSION::STRING >= '5.2.0' - pending "polyamorous's support for polymorphism is broken" - end - relation = Picture.joining { imageable.of(Post).outer } expect(relation).to match_sql_snapshot @@ -164,10 +156,6 @@ end it 'handles polymorphism' do - if ActiveRecord::VERSION::STRING >= '5.2.0' - pending "polyamorous's support for polymorphism is broken" - end - relation = Picture.joining { imageable.of(Post).comments } expect(relation).to match_sql_snapshot diff --git a/spec/integration/where_chain_spec.rb b/spec/integration/where_chain_spec.rb index 3ba8344..679351f 100644 --- a/spec/integration/where_chain_spec.rb +++ b/spec/integration/where_chain_spec.rb @@ -70,15 +70,11 @@ end it 'wheres on polymorphic associations' do - if ActiveRecord::VERSION::STRING >= '5.2.0' - pending "polyamorous's support for polymorphism is broken" - end - relation = Picture.joining { imageable.of(Post) }.where.has { imageable.of(Post).title =~ 'meatloaf' } - expect(relation).to match_sql_snapshot + expect(relation).to match_sql_snapshot(variants: ['5.2']) end it 'wheres on polymorphic associations outer join' do