From 62e9daeefecb6cebf05b26ff1b1bfcf97b04be77 Mon Sep 17 00:00:00 2001 From: Ryan Orlando Date: Thu, 26 Oct 2023 14:53:19 -0400 Subject: [PATCH] Remove depreciated Hyrax::SolrQueryBuilderService from tests --- .../my/find_works_search_builder_spec.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/spec/search_builders/hyrax/my/find_works_search_builder_spec.rb b/spec/search_builders/hyrax/my/find_works_search_builder_spec.rb index 252bbccf49..fdf83182fc 100644 --- a/spec/search_builders/hyrax/my/find_works_search_builder_spec.rb +++ b/spec/search_builders/hyrax/my/find_works_search_builder_spec.rb @@ -30,7 +30,7 @@ it "is successful" do subject - expect(solr_params[:fq]).to eq ["-" + Hyrax::SolrQueryBuilderService.construct_query_for_ids([work.id])] + expect(solr_params[:fq]).to eq ["-" + Hyrax::SolrQueryService.new.with_ids(ids: [work.id]).build] end end @@ -38,10 +38,27 @@ subject { builder.show_only_works_not_child(solr_params) } it "is successful" do + subject + ids = Hyrax::SolrService.query("{!field f=id}#{work.id}", fl: "member_ids_ssim").flat_map { |x| x.fetch("member_ids_ssim", []) } + expect(solr_params[:fq]).to eq ["-" + Hyrax::SolrQueryService.new.with_ids(ids: [ids]).build] + end + + it "is successful old way" do subject ids = Hyrax::SolrService.query("{!field f=id}#{work.id}", fl: "member_ids_ssim").flat_map { |x| x.fetch("member_ids_ssim", []) } expect(solr_params[:fq]).to eq ["-" + Hyrax::SolrQueryBuilderService.construct_query_for_ids([ids])] end + + it "is successful new same code way" do + subject + ids = Hyrax::SolrService.query("{!field f=id}#{work.id}", fl: "member_ids_ssim").flat_map { |x| x.fetch("member_ids_ssim", []) } + ids = [ids] + ids = ids.reject(&:blank?) + if ids.empty? + ids = "id:NEVER_USE_THIS_ID" + end + expect(solr_params[:fq]).to eq ["-" + Hyrax::SolrQueryService.new.with_ids(ids: ids).build] + end end describe "#show_only_works_not_parent" do