diff --git a/app/authorities/holding_location_authority.rb b/app/authorities/holding_location_authority.rb new file mode 100644 index 000000000..082965d48 --- /dev/null +++ b/app/authorities/holding_location_authority.rb @@ -0,0 +1,17 @@ +class HoldingLocationAuthority + include Qa::Authorities::WebServiceBase + + def all + get_json(url).each { |loc| loc['id'] = loc['url'].sub(/\.json$/, '') } + end + + def find(id) + (all.select { |obj| obj['id'] == id } || []).first + end + + private + + def url + Plum.config['locations_url'] + end +end diff --git a/app/forms/curation_concerns/curation_concerns_form.rb b/app/forms/curation_concerns/curation_concerns_form.rb index 53d542043..04dd60571 100644 --- a/app/forms/curation_concerns/curation_concerns_form.rb +++ b/app/forms/curation_concerns/curation_concerns_form.rb @@ -1,6 +1,6 @@ module CurationConcerns class CurationConcernsForm < CurationConcerns::Forms::WorkForm - self.terms += [:access_policy, :rights_statement, :rights_note, :source_metadata_identifier, :portion_note, :description, :state, :workflow_note, :collection_ids] + self.terms += [:access_policy, :holding_location, :rights_statement, :rights_note, :source_metadata_identifier, :portion_note, :description, :state, :workflow_note, :collection_ids] def notable_rights_statement? RightsStatementService.notable?(model.rights_statement) diff --git a/app/models/concerns/common_metadata.rb b/app/models/concerns/common_metadata.rb index 447dac3cb..f283fd8ad 100644 --- a/app/models/concerns/common_metadata.rb +++ b/app/models/concerns/common_metadata.rb @@ -29,6 +29,9 @@ module CommonMetadata property :workflow_note, predicate: ::RDF::Vocab::MODS.note do |index| index.as :stored_searchable, :symbol end + property :holding_location, predicate: ::RDF::Vocab::Bibframe.heldBy, multiple: false do |index| + index.as :stored_searchable + end # IIIF apply_schema IIIFBookSchema, ActiveFedora::SchemaIndexingStrategy.new( diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index c6831c97f..a66953d88 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -73,4 +73,8 @@ def rights_statement def rights_note self[Solrizer.solr_name('rights_note')] end + + def holding_location + self[Solrizer.solr_name('holding_location')] + end end diff --git a/app/presenters/curation_concerns_show_presenter.rb b/app/presenters/curation_concerns_show_presenter.rb index 63ca7ced5..4f0545863 100644 --- a/app/presenters/curation_concerns_show_presenter.rb +++ b/app/presenters/curation_concerns_show_presenter.rb @@ -24,6 +24,10 @@ def rights_statement RightsStatementRenderer.new(solr_document.rights_statement, solr_document.rights_note).render end + def holding_location + HoldingLocationRenderer.new(solr_document.holding_location).render + end + private def logical_order_factory diff --git a/app/renderers/holding_location_renderer.rb b/app/renderers/holding_location_renderer.rb new file mode 100644 index 000000000..b557d5d29 --- /dev/null +++ b/app/renderers/holding_location_renderer.rb @@ -0,0 +1,13 @@ +class HoldingLocationRenderer < CurationConcerns::AttributeRenderer + def initialize(value, options = {}) + super(:location, value, options) + end + + private + + def attribute_value_to_html(value) + loc = HoldingLocationService.find(value) + li_value %(#{loc.label}
Contact at #{loc.email}, + #{loc.phone}) + end +end diff --git a/app/services/holding_location_service.rb b/app/services/holding_location_service.rb new file mode 100644 index 000000000..4c9090875 --- /dev/null +++ b/app/services/holding_location_service.rb @@ -0,0 +1,30 @@ +module HoldingLocationService + mattr_accessor :authority + self.authority = HoldingLocationAuthority.new + + def self.select_options + authority.all.map { |element| [element['label'], element['id']] }.sort + end + + def self.find(id) + HoldingLocation.new(authority.find(id)) + end + + class HoldingLocation + def initialize(hash) + @holding_location = hash || {} + end + + def email + @holding_location['contact_email'] + end + + def label + @holding_location['label'] + end + + def phone + @holding_location['phone_number'] + end + end +end diff --git a/app/views/curation_concerns/base/_attributes.html.erb b/app/views/curation_concerns/base/_attributes.html.erb index a5cd5a1da..c744a63e0 100644 --- a/app/views/curation_concerns/base/_attributes.html.erb +++ b/app/views/curation_concerns/base/_attributes.html.erb @@ -25,6 +25,9 @@ <% if @presenter.respond_to? :rights_statement %> <%= @presenter.rights_statement %> <% end %> + <% if @presenter.respond_to? :holding_location %> + <%= @presenter.holding_location %> + <% end %> <%= @presenter.attribute_to_html(:identifier) %> <%= render partial: '/curation_concerns/base/collection_list' %> <% if can? :edit, @presenter.id %> diff --git a/app/views/curation_concerns/base/_form_access_policy.erb b/app/views/curation_concerns/base/_form_access_policy.erb index e2d443823..3a4570324 100644 --- a/app/views/curation_concerns/base/_form_access_policy.erb +++ b/app/views/curation_concerns/base/_form_access_policy.erb @@ -19,4 +19,10 @@ <%= f.input :rights_note, as: :text, label: 'Rights Note', input_html: { class: 'rights-note', readonly: !@form.notable_rights_statement? } %> + + <%= f.input :holding_location, + as: :select, + collection: HoldingLocationService.select_options, + input_html: { class: 'form-control' }, + label: 'Holding Location' %> diff --git a/config/config.yml b/config/config.yml index e1a3119a6..eb113e96d 100644 --- a/config/config.yml +++ b/config/config.yml @@ -1,4 +1,5 @@ defaults: &defaults + locations_url: https://bibdata.princeton.edu/locations/digital_locations.json notifier_email_address: plum@princeton.edu iiif_url: <%= ENV["PLUM_IIIF_URL"] || "http://192.168.99.100:5004" %> jp2_recipes: diff --git a/spec/authorities/holding_location_authority_spec.rb b/spec/authorities/holding_location_authority_spec.rb new file mode 100644 index 000000000..f505dfb5e --- /dev/null +++ b/spec/authorities/holding_location_authority_spec.rb @@ -0,0 +1,43 @@ +require 'rails_helper' + +RSpec.describe HoldingLocationAuthority do + subject { described_class.new } + let(:json) { + '[{ + "label":"Plasma Physics Library", + "phone_number":"609-243-3565", + "contact_email":"ppllib@princeton.edu", + "url":"https://bibdata.princeton.edu/locations/delivery_locations/1.json" + },{ + "label":"Architecture Library", + "phone_number":"609-258-3256", + "contact_email":"ues@princeton.edu", + "url":"https://bibdata.princeton.edu/locations/delivery_locations/3.json" + }]' + } + let(:id) { 'https://bibdata.princeton.edu/locations/delivery_locations/3' } + let(:obj) { + { + label: "Architecture Library", + phone_number: "609-258-3256", + contact_email: "ues@princeton.edu", + url: "https://bibdata.princeton.edu/locations/delivery_locations/3.json", + id: "https://bibdata.princeton.edu/locations/delivery_locations/3" + } + } + + before do + allow(RestClient).to receive(:get).and_return(json) + end + + context "with data" do + it "finds a holding location by id" do + expect(subject.find(id)).to eq(obj.stringify_keys) + end + + it "lists all of the holding locations" do + expect(subject.all.length).to eq(2) + expect(subject.all).to include(obj.stringify_keys) + end + end +end diff --git a/spec/cassettes/bibdata.yml b/spec/cassettes/bibdata.yml index d93f60f1b..b9439e3c6 100644 --- a/spec/cassettes/bibdata.yml +++ b/spec/cassettes/bibdata.yml @@ -48,7 +48,102 @@ http_interactions: - application/xml; charset=utf-8 body: encoding: ASCII-8BIT - string: "00671cam a22002171 45002028405820521s1952 pau 000 0 eng 52060048 //r96 (OCoLC)ocm03384782CHP2843TSDLCDLCPULBS70.M3M5220.47Miner, Dorothy Eugenia.The Giant Bible of Mainz;500th anniversary, April fourth, fourteen fifty-two, April fourth, nineteen fifty-two.[Philadelphia,Fake Publisher1952]31 p.21 cm.Seal of the Library of Congress on t.p.Giant Bible of Mainz.SA1ND3355.A1M3519981222rcppj1ND3355.A1M35tr fr satr fr saxrcpxgRCPXG-6025540Adler Ref 1250" + string: "00671cam a22002171 + \ 45002028405820521s1952 pau 000 0 eng 52060048 //r96 (OCoLC)ocm03384782CHP2843TSDLCDLCPULBS70.M3M5220.47Miner, Dorothy Eugenia.The Giant Bible of Mainz;500th anniversary, April fourth, fourteen fifty-two, April fourth, + nineteen fifty-two.[Philadelphia,Fake Publisher1952]31 p.21 cm.Seal of the Library of Congress + on t.p.Giant Bible of Mainz.SA1ND3355.A1M3519981222rcppj1ND3355.A1M35tr + fr satr fr saxrcpxgRCPXG-6025540Adler Ref 1250" http_version: recorded_at: Fri, 04 Sep 2015 14:20:14 GMT +- request: + method: get + uri: https://bibdata.princeton.edu/locations/digital_locations.json + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 28 Jan 2016 16:54:26 GMT + Server: + - Apache/2.4.7 (Ubuntu) + Access-Control-Allow-Origin: + - "*" + Access-Control-Request-Method: + - GET + Access-Control-Allow-Headers: + - Origin, Content-Type, Accept, Authorization, Token + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 2572efe8-8e5b-4abb-aaef-3427c19445c0 + X-Runtime: + - '0.061688' + X-Powered-By: + - Phusion Passenger 4.0.59 + Etag: + - W/"f06a9680ced1a46b023d86ab673cdf8a" + Status: + - 200 OK + Transfer-Encoding: + - chunked + Content-Type: + - application/json; charset=utf-8 + body: + encoding: UTF-8 + string: '[{"label":"Plasma Physics Library","address":"Forrestal Campus Princeton, + NJ 08544","phone_number":"609-243-3565","contact_email":"ppllib@princeton.edu","gfa_pickup":"PQ","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/1.json","library":{"label":"Harold + P. Furth Plasma Physics Library","code":"plasma"}},{"label":"Architecture + Library","address":"School of Architecture Building, Second Floor Princeton, + NJ 08544","phone_number":"609-258-3256","contact_email":"ues@princeton.edu","gfa_pickup":"PW","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/3.json","library":{"label":"Architecture + Library","code":"architecture"}},{"label":"East Asian Library","address":"Frist + Campus Center, Room 317 Princeton, NJ 08544","phone_number":"609-258-3182","contact_email":"gestcirc@princeton.edu","gfa_pickup":"PL","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/4.json","library":{"label":"East + Asian Library","code":"eastasian"}},{"label":"Engineering Library","address":"Friend + Center for Engineering Education Princeton, NJ 08544","phone_number":"609-258-3200","contact_email":"englib@princeton.edu","gfa_pickup":"PT","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/5.json","library":{"label":"Engineering + Library","code":"engineering"}},{"label":"Marquand Library of Art and Archaeology","address":"McCormick + Hall Princeton, NJ 08544","phone_number":"609-258-5863","contact_email":"marquand@princeton.edu","gfa_pickup":"PJ","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/7.json","library":{"label":"Marquand + Library","code":"marquand"}},{"label":"Mendel Music Library","address":"Woolworth + Center Princeton, NJ 08544","phone_number":"609-258-3230","contact_email":"muslib@princeton.edu","gfa_pickup":"PK","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/8.json","library":{"label":"Mendel + Music Library","code":"mendel"}},{"label":"Stokes Library","address":"Wallace + Hall, Lower Level Princeton, NJ 08544","phone_number":"609-258-5455","contact_email":"piaprlib@princeton.edu","gfa_pickup":"PM","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/10.json","library":{"label":"Stokes + Library","code":"stokes"}},{"label":"Lewis Library","address":"Washington + Road and Ivy Lane Princeton, NJ 08544","phone_number":"609-258-6004","contact_email":"lewislib@princeton.edu","gfa_pickup":"PN","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/14.json","library":{"label":"Lewis + Library","code":"lewis"}},{"label":"Firestone Library","address":"One Washington + Rd. Princeton, NJ 08544","phone_number":"609-258-1470","contact_email":"fstcirc@princeton.edu","gfa_pickup":"PA","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/15.json","library":{"label":"Firestone + Library","code":"firestone"}}]' + http_version: + recorded_at: Thu, 28 Jan 2016 16:54:26 GMT recorded_with: VCR 2.9.3 diff --git a/spec/cassettes/ezid.yml b/spec/cassettes/ezid.yml index 48cf4e770..d90098f9b 100644 --- a/spec/cassettes/ezid.yml +++ b/spec/cassettes/ezid.yml @@ -37,4 +37,72 @@ http_interactions: string: 'success: ark:/99999/fk4445wg45' http_version: recorded_at: Thu, 29 Oct 2015 17:49:02 GMT +- request: + method: get + uri: https://bibdata.princeton.edu/locations/digital_locations.json + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 28 Jan 2016 16:56:59 GMT + Server: + - Apache/2.4.7 (Ubuntu) + Access-Control-Allow-Origin: + - "*" + Access-Control-Request-Method: + - GET + Access-Control-Allow-Headers: + - Origin, Content-Type, Accept, Authorization, Token + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - 285d8ed4-d396-4a56-8aee-1fe1b3215e0a + X-Runtime: + - '0.046994' + X-Powered-By: + - Phusion Passenger 4.0.59 + Etag: + - W/"f06a9680ced1a46b023d86ab673cdf8a" + Status: + - 200 OK + Transfer-Encoding: + - chunked + Content-Type: + - application/json; charset=utf-8 + body: + encoding: UTF-8 + string: '[{"label":"Plasma Physics Library","address":"Forrestal Campus Princeton, + NJ 08544","phone_number":"609-243-3565","contact_email":"ppllib@princeton.edu","gfa_pickup":"PQ","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/1.json","library":{"label":"Harold + P. Furth Plasma Physics Library","code":"plasma"}},{"label":"Architecture + Library","address":"School of Architecture Building, Second Floor Princeton, + NJ 08544","phone_number":"609-258-3256","contact_email":"ues@princeton.edu","gfa_pickup":"PW","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/3.json","library":{"label":"Architecture + Library","code":"architecture"}},{"label":"East Asian Library","address":"Frist + Campus Center, Room 317 Princeton, NJ 08544","phone_number":"609-258-3182","contact_email":"gestcirc@princeton.edu","gfa_pickup":"PL","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/4.json","library":{"label":"East + Asian Library","code":"eastasian"}},{"label":"Engineering Library","address":"Friend + Center for Engineering Education Princeton, NJ 08544","phone_number":"609-258-3200","contact_email":"englib@princeton.edu","gfa_pickup":"PT","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/5.json","library":{"label":"Engineering + Library","code":"engineering"}},{"label":"Marquand Library of Art and Archaeology","address":"McCormick + Hall Princeton, NJ 08544","phone_number":"609-258-5863","contact_email":"marquand@princeton.edu","gfa_pickup":"PJ","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/7.json","library":{"label":"Marquand + Library","code":"marquand"}},{"label":"Mendel Music Library","address":"Woolworth + Center Princeton, NJ 08544","phone_number":"609-258-3230","contact_email":"muslib@princeton.edu","gfa_pickup":"PK","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/8.json","library":{"label":"Mendel + Music Library","code":"mendel"}},{"label":"Stokes Library","address":"Wallace + Hall, Lower Level Princeton, NJ 08544","phone_number":"609-258-5455","contact_email":"piaprlib@princeton.edu","gfa_pickup":"PM","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/10.json","library":{"label":"Stokes + Library","code":"stokes"}},{"label":"Lewis Library","address":"Washington + Road and Ivy Lane Princeton, NJ 08544","phone_number":"609-258-6004","contact_email":"lewislib@princeton.edu","gfa_pickup":"PN","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/14.json","library":{"label":"Lewis + Library","code":"lewis"}},{"label":"Firestone Library","address":"One Washington + Rd. Princeton, NJ 08544","phone_number":"609-258-1470","contact_email":"fstcirc@princeton.edu","gfa_pickup":"PA","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/15.json","library":{"label":"Firestone + Library","code":"firestone"}}]' + http_version: + recorded_at: Thu, 28 Jan 2016 16:56:59 GMT recorded_with: VCR 2.9.3 diff --git a/spec/cassettes/locations.yml b/spec/cassettes/locations.yml new file mode 100644 index 000000000..f873fc416 --- /dev/null +++ b/spec/cassettes/locations.yml @@ -0,0 +1,71 @@ +--- +http_interactions: +- request: + method: get + uri: https://bibdata.princeton.edu/locations/digital_locations.json + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 28 Jan 2016 16:57:01 GMT + Server: + - Apache/2.4.7 (Ubuntu) + Access-Control-Allow-Origin: + - "*" + Access-Control-Request-Method: + - GET + Access-Control-Allow-Headers: + - Origin, Content-Type, Accept, Authorization, Token + Cache-Control: + - max-age=0, private, must-revalidate + X-Request-Id: + - f7db0ded-f36b-430c-9d0f-f1bff25c962c + X-Runtime: + - '0.054184' + X-Powered-By: + - Phusion Passenger 4.0.59 + Etag: + - W/"f06a9680ced1a46b023d86ab673cdf8a" + Status: + - 200 OK + Transfer-Encoding: + - chunked + Content-Type: + - application/json; charset=utf-8 + body: + encoding: UTF-8 + string: '[{"label":"Plasma Physics Library","address":"Forrestal Campus Princeton, + NJ 08544","phone_number":"609-243-3565","contact_email":"ppllib@princeton.edu","gfa_pickup":"PQ","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/1.json","library":{"label":"Harold + P. Furth Plasma Physics Library","code":"plasma"}},{"label":"Architecture + Library","address":"School of Architecture Building, Second Floor Princeton, + NJ 08544","phone_number":"609-258-3256","contact_email":"ues@princeton.edu","gfa_pickup":"PW","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/3.json","library":{"label":"Architecture + Library","code":"architecture"}},{"label":"East Asian Library","address":"Frist + Campus Center, Room 317 Princeton, NJ 08544","phone_number":"609-258-3182","contact_email":"gestcirc@princeton.edu","gfa_pickup":"PL","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/4.json","library":{"label":"East + Asian Library","code":"eastasian"}},{"label":"Engineering Library","address":"Friend + Center for Engineering Education Princeton, NJ 08544","phone_number":"609-258-3200","contact_email":"englib@princeton.edu","gfa_pickup":"PT","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/5.json","library":{"label":"Engineering + Library","code":"engineering"}},{"label":"Marquand Library of Art and Archaeology","address":"McCormick + Hall Princeton, NJ 08544","phone_number":"609-258-5863","contact_email":"marquand@princeton.edu","gfa_pickup":"PJ","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/7.json","library":{"label":"Marquand + Library","code":"marquand"}},{"label":"Mendel Music Library","address":"Woolworth + Center Princeton, NJ 08544","phone_number":"609-258-3230","contact_email":"muslib@princeton.edu","gfa_pickup":"PK","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/8.json","library":{"label":"Mendel + Music Library","code":"mendel"}},{"label":"Stokes Library","address":"Wallace + Hall, Lower Level Princeton, NJ 08544","phone_number":"609-258-5455","contact_email":"piaprlib@princeton.edu","gfa_pickup":"PM","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/10.json","library":{"label":"Stokes + Library","code":"stokes"}},{"label":"Lewis Library","address":"Washington + Road and Ivy Lane Princeton, NJ 08544","phone_number":"609-258-6004","contact_email":"lewislib@princeton.edu","gfa_pickup":"PN","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/14.json","library":{"label":"Lewis + Library","code":"lewis"}},{"label":"Firestone Library","address":"One Washington + Rd. Princeton, NJ 08544","phone_number":"609-258-1470","contact_email":"fstcirc@princeton.edu","gfa_pickup":"PA","staff_only":false,"pickup_location":true,"digital_location":true,"url":"https://bibdata.princeton.edu/locations/delivery_locations/15.json","library":{"label":"Firestone + Library","code":"firestone"}}]' + http_version: + recorded_at: Thu, 28 Jan 2016 16:57:01 GMT +recorded_with: VCR 2.9.3 diff --git a/spec/features/edit_multi_volume_work_spec.rb b/spec/features/edit_multi_volume_work_spec.rb index 40b53551c..4267e4367 100644 --- a/spec/features/edit_multi_volume_work_spec.rb +++ b/spec/features/edit_multi_volume_work_spec.rb @@ -8,7 +8,7 @@ sign_in user end - scenario "Logged in user can follow link to edit multi-volume work" do + scenario "Logged in user can follow link to edit multi-volume work", vcr: { cassette_name: "locations" } do visit polymorphic_path [multi_volume_work] click_link 'Edit This Multi Volume Work' expect(page).to have_text('Manage Your Work') @@ -30,7 +30,7 @@ expect(page).to have_selector("span.label-info", "Metadata Review") end - scenario "User can create a new scanned resource attached to the multi-volume work" do + scenario "User can create a new scanned resource attached to the multi-volume work", vcr: { cassette_name: "locations" } do visit polymorphic_path [multi_volume_work] expect(page).to have_text('This Multi Volume Work has no scanned resources associated with it') diff --git a/spec/features/edit_scanned_resource_spec.rb b/spec/features/edit_scanned_resource_spec.rb index fa5cd0a8d..263bac800 100644 --- a/spec/features/edit_scanned_resource_spec.rb +++ b/spec/features/edit_scanned_resource_spec.rb @@ -11,7 +11,7 @@ ) end - context "an authorized user" do + context "an authorized user", vcr: { cassette_name: "locations" } do before(:each) do sign_in user end diff --git a/spec/features/new_scanned_resource_spec.rb b/spec/features/new_scanned_resource_spec.rb index 4ea552cdc..e65e754be 100644 --- a/spec/features/new_scanned_resource_spec.rb +++ b/spec/features/new_scanned_resource_spec.rb @@ -8,7 +8,7 @@ sign_in user end - scenario "Logged in user can create a new scanned resource" do + scenario "Logged in user can create a new scanned resource", vcr: { cassette_name: "locations" } do visit new_polymorphic_path [ScannedResource] expect(page).to_not have_selector("label.label-warning", "Pending") diff --git a/spec/models/collection.rb b/spec/models/collection_spec.rb similarity index 100% rename from spec/models/collection.rb rename to spec/models/collection_spec.rb diff --git a/spec/renderers/holding_location_renderer_spec.rb b/spec/renderers/holding_location_renderer_spec.rb new file mode 100644 index 000000000..fe88e59b2 --- /dev/null +++ b/spec/renderers/holding_location_renderer_spec.rb @@ -0,0 +1,27 @@ +require 'rails_helper' + +RSpec.describe HoldingLocationRenderer do + let(:uri) { 'http://rightsstatements.org/vocab/InC/1.0/' } + let(:obj) { + { + label: "Sample", + phone_number: "123-456-7890", + contact_email: "ex@example.org", + url: "https://bibdata.princeton.edu/locations/delivery_locations/1.json", + id: "https://bibdata.princeton.edu/locations/delivery_locations/1" + } + } + let(:rendered) { described_class.new(uri).render } + + before do + allow_any_instance_of(HoldingLocationAuthority).to receive(:find).and_return(obj.stringify_keys) + end + + context "with a rendered holding location" do + it "renders the location label and email/phone links" do + expect(rendered).to include('Sample') + expect(rendered).to include('ex@example.org') + expect(rendered).to include('123-456-7890') + end + end +end diff --git a/spec/requests/scanned_resources_request_spec.rb b/spec/requests/scanned_resources_request_spec.rb index c8cfe520f..01b76c259 100644 --- a/spec/requests/scanned_resources_request_spec.rb +++ b/spec/requests/scanned_resources_request_spec.rb @@ -8,7 +8,7 @@ login_as(user, scope: :user) end - it 'User creates a new scanned resource', vcr: { cassette_name: 'bibdata', allow_playback_repeats: true }do + it 'User creates a new scanned resource', vcr: { cassette_name: 'bibdata', allow_playback_repeats: true } do get '/concern/scanned_resources/new' expect(response).to render_template('curation_concerns/scanned_resources/new') diff --git a/spec/services/holding_location_service_spec.rb b/spec/services/holding_location_service_spec.rb new file mode 100644 index 000000000..7b938e2ea --- /dev/null +++ b/spec/services/holding_location_service_spec.rb @@ -0,0 +1,24 @@ +require 'rails_helper' + +RSpec.describe HoldingLocationService, vcr: { cassette_name: 'locations' } do + let(:uri) { 'https://bibdata.princeton.edu/locations/delivery_locations/3' } + let(:email) { 'ues@princeton.edu' } + let(:label) { 'Architecture Library' } + let(:phone) { '609-258-3256' } + + subject { described_class.find(uri) } + + context "rights statements" do + it "gets the email of a holding location" do + expect(subject.email).to eq(email) + end + + it "gets the label of a holding location" do + expect(subject.label).to eq(label) + end + + it "gets the phone number of a holding location" do + expect(subject.phone).to eq(phone) + end + end +end diff --git a/spec/services/rights_statement_service.rb b/spec/services/rights_statement_service_spec.rb similarity index 100% rename from spec/services/rights_statement_service.rb rename to spec/services/rights_statement_service_spec.rb diff --git a/spec/validators/exhibit_id_validator.rb b/spec/validators/exhibit_id_validator_spec.rb similarity index 100% rename from spec/validators/exhibit_id_validator.rb rename to spec/validators/exhibit_id_validator_spec.rb diff --git a/spec/validators/rights_statement_validator.rb b/spec/validators/rights_statement_validator_spec.rb similarity index 100% rename from spec/validators/rights_statement_validator.rb rename to spec/validators/rights_statement_validator_spec.rb