spec/integration/associations_spec.rb in pg_search-2.1.3 vs spec/integration/associations_spec.rb in pg_search-2.1.4

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require "spec_helper" describe PgSearch do context "joining to another table" do context "without an :against" do @@ -17,11 +19,11 @@ model do include PgSearch belongs_to :another_model, :class_name => 'AssociatedModel' - pg_search_scope :with_another, :associated_against => {:another_model => :title} + pg_search_scope :with_another, :associated_against => { :another_model => :title } end end it "returns rows that match the query in the columns of the associated model only" do associated = AssociatedModel.create!(:title => 'abcdef') @@ -54,11 +56,11 @@ model do include PgSearch belongs_to :another_model, :class_name => 'AssociatedModel' - pg_search_scope :with_associated, :against => :title, :associated_against => {:another_model => :title} + pg_search_scope :with_associated, :against => :title, :associated_against => { :another_model => :title } end end it "returns rows that match the query in either its own columns or the columns of the associated model" do associated = AssociatedModel.create!(:title => 'abcdef') @@ -90,11 +92,11 @@ model do include PgSearch has_many :other_models, :class_name => 'AssociatedModelWithHasMany', :foreign_key => 'ModelWithHasMany_id' - pg_search_scope :with_associated, :against => [:title], :associated_against => {:other_models => :title} + pg_search_scope :with_associated, :against => [:title], :associated_against => { :other_models => :title } end end it "returns rows that match the query in either its own columns or the columns of the associated model" do included = [ @@ -170,11 +172,11 @@ belongs_to :model_of_second_type, :class_name => 'SecondAssociatedModel' pg_search_scope :with_associated, :against => :title, - :associated_against => {:models_of_first_type => :title, :model_of_second_type => :title} + :associated_against => { :models_of_first_type => :title, :model_of_second_type => :title } end end it "returns rows that match the query in either its own columns or the columns of the associated model" do matching_second = SecondAssociatedModel.create!(:title => "foo bar") @@ -229,11 +231,11 @@ has_many :thingamabobs, :class_name => 'DoublyAssociatedModel', :foreign_key => 'ModelWithDoubleAssociation_again_id' pg_search_scope :with_associated, :against => :title, - :associated_against => {:things => :title, :thingamabobs => :title} + :associated_against => { :things => :title, :thingamabobs => :title } end end it "returns rows that match the query in either its own columns or the columns of the associated model" do included = [ @@ -281,11 +283,11 @@ model do include PgSearch belongs_to :another_model, :class_name => 'AssociatedModel' - pg_search_scope :with_associated, :associated_against => {:another_model => %i[title author]} + pg_search_scope :with_associated, :associated_against => { :another_model => %i[title author] } end end it "should only do one join" do included = [ @@ -334,10 +336,10 @@ model do include PgSearch belongs_to :another_model, class_name: 'AssociatedModel' - pg_search_scope :with_associated, associated_against: {another_model: :number} + pg_search_scope :with_associated, associated_against: { another_model: :number } end end it "should cast the columns to text" do associated = AssociatedModel.create!(:number => 123)