Skip to content

Commit

Permalink
refactor access condition getting
Browse files Browse the repository at this point in the history
  • Loading branch information
CEdwardsBlasikiewicz committed Jun 28, 2024
1 parent c125665 commit 20ad6ee
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 29 deletions.
2 changes: 1 addition & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ class CatalogController < ApplicationController
config.add_summary_field "language", field: "language_ssim"
config.add_summary_field "prefercite", field: "prefercite_html_tesm", helper_method: :render_html_tags
config.add_summary_field "availability", field: "availability_status", accessor: :availability_status
config.add_summary_field "accessconditions", field: "access_conditions", accessor: :access_conditions
config.add_summary_field "accessconditions", field: "access_conditions_ssim"
config.add_summary_field "cult_sens_adv_notice",
label: I18n.t("ead_notes.cultural_sens_adv_notice"),
helper_method: :render_html_tags,
Expand Down
12 changes: 0 additions & 12 deletions app/services/catalogue_services_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ def get_item_ids(instance_id:)
[item_id, holding_id]
end

def get_access_conditions(instance_id:, holdings_id:)
all_holdings = get_holdings(instance_id: instance_id)

# find holdings record
holding = all_holdings.find { |h| h["id"] == holdings_id }

# find item record
item = holding["notes"].find { |i| i["holdingsNoteType"] == "Restriction" }

item ? item["note"] : nil
end

def related_docs(pid:)
conn = setup_connection

Expand Down
16 changes: 0 additions & 16 deletions spec/services/catalogue_services_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,6 @@
end
end

describe "#get_access_conditions" do
before do
cat_response = IO.read("spec/files/catalogue_services/08aed703-3648-54d0-80ef-fddb3c635731.json")
WebMock.stub_request(:get, /catservices.test\/catalogue-services\/folio\/instance\/08aed703-3648-54d0-80ef-fddb3c635731/)
.to_return(status: 200, body: cat_response, headers: {"Content-Type" => "application/json"})
end

it "returns the record's item id and holding id" do
expect(service.get_item_ids(instance_id: "08aed703-3648-54d0-80ef-fddb3c635731")).to eq %w[d6c97d9e-dfe6-5faa-9f0b-020b2bddbf8c 7460acfb-72b9-5dba-9089-603921fb47c7]
end

it "returns the record's access condition notes or nil" do
expect(service.get_access_conditions(instance_id: "08aed703-3648-54d0-80ef-fddb3c635731", holdings_id: "d6c97d9e-dfe6-5faa-9f0b-020b2bddbf8c")).to be_nil
end
end

describe "#related_docs" do
context "when there are related records" do
before do
Expand Down

0 comments on commit 20ad6ee

Please sign in to comment.