Skip to content

Commit

Permalink
specs for catalog/_field.json.jbuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
ebenenglish committed Dec 21, 2020
1 parent 1478df8 commit 996bf76
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 63 deletions.
29 changes: 29 additions & 0 deletions spec/views/catalog/_field.json.jbuilder_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe 'catalog/_field.json.jbuilder', api: true do
let(:field_name) { 'genre_basic_ssim' }
let(:blacklight_config) do
Blacklight::Configuration.new.configure do |config|
config.add_index_field field_name
end
end
let(:field_config) { blacklight_config.index_fields[field_name] }
let(:document) { SolrDocument.find('bpl-dev:h702q6403') }

let(:field_presenter) { CommonwealthVlrEngine::JsonFieldPresenter.new({}, document, field_config) }
let(:hash) do
render template: 'catalog/_field.json.jbuilder', format: :json
JSON.parse(rendered).with_indifferent_access
end

before :each do
allow(view).to receive(:field_name).and_return(field_name)
allow(view).to receive(:field_presenter).and_return(field_presenter)
end

it 'returns the raw field value' do
expect(hash[field_name]).to eq ['Photographs']
end
end
35 changes: 0 additions & 35 deletions spec/views/catalog/index.json.jbuilder_spec.rb

This file was deleted.

28 changes: 0 additions & 28 deletions spec/views/catalog/show.json.jbuilder_spec.rb

This file was deleted.

0 comments on commit 996bf76

Please sign in to comment.