From 6f1c1807833cdf5b119853bebff8dc87476743cb Mon Sep 17 00:00:00 2001 From: sinsoku Date: Sun, 19 May 2019 02:22:47 +0900 Subject: [PATCH] Fix failing specs on local machine [fix #1023] Since the structure of Node returned by ActiveReocrd changed from 54de9b1, the spec execution failed. refs: https://github.com/rails/rails/commit/54de9b1e4f5823bf22001be60efcb996ce6d260b --- lib/ransack/adapters/active_record/context.rb | 2 ++ spec/ransack/search_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ransack/adapters/active_record/context.rb b/lib/ransack/adapters/active_record/context.rb index a01d284bb..7ac4e93b9 100644 --- a/lib/ransack/adapters/active_record/context.rb +++ b/lib/ransack/adapters/active_record/context.rb @@ -186,6 +186,8 @@ def extract_correlated_key(join_root) correlated_key = correlated_key.left.left elsif correlated_key.is_a? Arel::Nodes::Equality correlated_key = correlated_key.left + elsif correlated_key.is_a? Arel::Nodes::Grouping + correlated_key = join_root.right.expr.right.left else correlated_key end diff --git a/spec/ransack/search_spec.rb b/spec/ransack/search_spec.rb index b4d0b3bdd..c19a6f158 100644 --- a/spec/ransack/search_spec.rb +++ b/spec/ransack/search_spec.rb @@ -238,9 +238,9 @@ module Ransack real_query = remove_quotes_and_backticks(s.to_sql) expect(real_query) - .to include "LEFT OUTER JOIN articles ON articles.person_id = people.id" + .to match(%r{LEFT OUTER JOIN articles ON (\('default_scope' = 'default_scope'\) AND )?articles.person_id = people.id}) expect(real_query) - .to include "LEFT OUTER JOIN articles articles_people ON articles_people.person_id = parents_people.id" + .to match(%r{LEFT OUTER JOIN articles articles_people ON (\('default_scope' = 'default_scope'\) AND )?articles_people.person_id = parents_people.id}) expect(real_query) .to include "people.name = 'person_name_query'" expect(real_query)