Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove depreciated Hyrax::SolrQueryBuilderService from tests #6396

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion spec/search_builders/hyrax/my/find_works_search_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,46 @@

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

describe "#show_only_works_not_child" do
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])]
expect(ids.reject(&:blank?).empty?).to eq(false)
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]
expect(ids.to_s).to eq("false")

# rubocop:disable Style/IfUnlessModifier
if ids.reject(&:blank?).empty?
expect(ids.to_s).to eq("false")
end
if Hyrax::SolrQueryBuilderService.construct_query_for_ids([ids]) == "id:NEVER_USE_THIS_ID"
# if this is true that means he orininal test is bad.
expect(true).to eq(false)
end
expect(solr_params[:fq]).to eq ["-" + Hyrax::SolrQueryService.new.with_ids(ids: ids).build]
end
it "is successful the real test" 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 ["-" + "id:NEVER_USE_THIS_ID"]
end
end

Expand Down