Skip to content

Commit

Permalink
Merge pull request #1213 from sul-dlss/availability-fix
Browse files Browse the repository at this point in the history
Few related fixes for availability
  • Loading branch information
ndushay committed Feb 26, 2016
2 parents 635680b + 85c8cf6 commit 1111eaa
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 8 deletions.
4 changes: 3 additions & 1 deletion app/assets/javascripts/jquery.live-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
if ( live_data.due_date ) {
current_location.append(' Due ' + live_data.due_date);
}
if ( live_data.due_date && target.hasClass('unknown') ) {

if ( live_data.due_date && (target.hasClass('unknown') || target.hasClass('page')) ) {
target.removeClass('unknown');
target.removeClass('page');
target.addClass('unavailable');
status_text.text(''); // The due date/current location acts as the status text at this point
if (target.attr('title')) {
Expand Down
3 changes: 3 additions & 0 deletions lib/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,9 @@ module Constants
HIDE_DUE_DATE_CURRENT_LOCS = [
'ART-AT-ENG',
'IC-DISPLAY',
'LOST-ASSUM',
'LOST-CLAIM',
'LOST-PAID',
'NEWBOOKS',
'SEE-LOAN'
]
Expand Down
2 changes: 1 addition & 1 deletion lib/holdings/noncirc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def location_is_default_noncirc?
end

def type_is_default_noncirc?
["REF", "NONCIRC", "LIBUSEONLY"].include?(@callnumber.type)
%w(LIBUSEONLY NH-INHOUSE NONCIRC REF).include?(@callnumber.type)
end

def sanitized_library
Expand Down
4 changes: 2 additions & 2 deletions lib/holdings/status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def initialize(callnumber)

def availability_class
case
when unavailable?
'unavailable'
when noncirc_page?
'noncirc_page'
when noncirc?
Expand All @@ -21,8 +23,6 @@ def availability_class
'page'
when available?
'available'
when unavailable?
'unavailable'
when unknown?
'unknown'
else
Expand Down
2 changes: 1 addition & 1 deletion lib/holdings/unavailable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def unavailable_current_location?

def current_location_ends_with_loan?
@callnumber.current_location.try(:code) &&
@callnumber.current_location.code != "SEE-LOAN" &&
@callnumber.current_location.code != 'SPE-LOAN' &&
@callnumber.current_location.code.ends_with?("-LOAN")
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/holdings/noncirc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
let(:noncirc_types) {
[OpenStruct.new(type: 'REF'),
OpenStruct.new(type: 'NONCIRC'),
OpenStruct.new(type: 'LIBUSEONLY')
OpenStruct.new(type: 'LIBUSEONLY'),
OpenStruct.new(type: 'NH-INHOUSE')
]
}
let(:circ_type) { OpenStruct.new(type: "SOMETHING") }
Expand Down
21 changes: 21 additions & 0 deletions spec/lib/holdings/status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@
expect(status.availability_class).to eq 'unknown'
end
end

describe 'precedence' do
subject { Holdings::Status.new(callnumber) }

describe 'unavailable' do
let(:callnumber) do
double(
'Call number',
library: 'SAL3',
home_location: 'STACKS',
current_location: double('Location', code: 'LOST-ASSUM'),
type: 'STACKS'
)
end

it 'takes precedence over things like page' do
expect(subject.availability_class).to eq 'unavailable'
end
end
end

describe '#as_json' do
let(:as_json) { status.as_json }
it 'should return a json hash with the availability class and status text' do
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/holdings/unavailable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
it "should handle identify -LOAN properly as unavailable" do
expect(Holdings::Status::Unavailable.new(OpenStruct.new(current_location: Holdings::Location.new("SOMETHING-LOAN")))).to be_unavailable
end
it "should not identify SEE-LOAN as unavailable" do
expect(Holdings::Status::Unavailable.new(OpenStruct.new(current_location: Holdings::Location.new("SEE-LOAN")))).to_not be_unavailable
it "should not identify SPE-LOAN as unavailable" do
expect(Holdings::Status::Unavailable.new(OpenStruct.new(current_location: Holdings::Location.new("SPE-LOAN")))).to_not be_unavailable
end
end
end

0 comments on commit 1111eaa

Please sign in to comment.