Skip to content

Commit

Permalink
Merge pull request #653 from sul-dlss/blank-featured-item-id
Browse files Browse the repository at this point in the history
Don't lookup featured items for searches if the featured_item_id is an ...
  • Loading branch information
cbeer committed Apr 19, 2014
2 parents 800e4cc + 0078ac7 commit 0fe6a4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/spotlight/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Spotlight::Search < ActiveRecord::Base
include Spotlight::Catalog::AccessControlsEnforcement

def featured_item
if self.featured_item_id
if self.featured_item_id.present?
@featured_item ||= get_solr_response_for_doc_id(self.featured_item_id).last
end
end
Expand Down
9 changes: 9 additions & 0 deletions spec/models/spotlight/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
expect(subject.featured_image).to eq "https://stacks.stanford.edu/image/dq287tq6352/dq287tq6352_05_0001_thumb"
end

it "should handle blank and nil featured_image_ids" do
subject.stub(:featured_item_id).and_return("")
subject.save
expect(subject.featured_item).to be_nil
subject.stub(:featured_item_id).and_return(nil)
subject.save
expect(subject.featured_item).to be_nil
end

it "should #default_featured_iamge should not thrown an error when no images are present" do
subject.stub(images: nil)
expect(subject.default_featured_item_id).to be_nil
Expand Down

0 comments on commit 0fe6a4b

Please sign in to comment.