-
Notifications
You must be signed in to change notification settings - Fork 1
/
blacklight_config_spec.rb
105 lines (93 loc) · 3.41 KB
/
blacklight_config_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
require 'rails_helper'
RSpec.describe BlacklightConfig do
subject { BlacklightConfig.new(resource, default_config) }
let(:resource) { GenericAsset }
let(:default_config) { CatalogController.blacklight_config }
describe "#default_configuration" do
it "should not error" do
expect{subject.default_configuration}.not_to raise_error
end
it "should be the CatalogController's config" do
expect(subject.default_configuration).to eq default_config
end
end
describe "#set=" do
let(:set) { instance_double(GenericSet, :id => "myset") }
it "should set a show route" do
subject.set = set
expect(subject.configuration.show.route).to eq({:controller => "sets", :set_id => "myset"})
end
end
describe "#configuration" do
subject { BlacklightConfig.new(resource, default_config).configuration }
describe "#index.title_field" do
it "should be title" do
expect(subject.index.title_field).to eq Solrizer.solr_name('title', :symbol)
end
end
describe "#search_fields" do
it "should have all the search fields" do
expect(subject.search_fields.keys).to eq [
"all_fields",
"title",
"description",
"creator",
"lcsubject",
"date",
"institution"
]
end
end
describe "#default_solr_params" do
it "should be right" do
expect(subject.default_solr_params).to eq ({
:qt => 'search',
:rows => 10,
:hl => true,
:"hl.fl" => "full_text_tsimv",
:"hl.useFastVectorHighlighter" => true
})
end
end
describe "#index.display_type_field" do
it "should be has_model" do
expect(subject.index.display_type_field).to eq Solrizer.solr_name('has_model', :symbol)
end
end
it "should be a Blacklight::Configuration" do
expect(subject).to be_instance_of Blacklight::Configuration
end
it "should have a show field config for each field" do
keys = subject.show_fields.values.map(&:key)
labels = subject.show_fields.values.map(&:label)
expect(keys).to include "title_ssim"
expect(labels).to include "Title"
expect(keys).to include "alternative_ssim"
expect(labels).to include "Alternative"
expect(keys).to include *GenericAsset.properties.keys.map{|x| "#{x}_ssim"}
end
it "should have facets for all the facet fields" do
FacetField.create(:key => "title")
FacetField.create(:key => "test", :label => "Power Rangers")
keys = subject.facet_fields.values.map(&:key)
labels = subject.facet_fields.values.map(&:label)
expect(keys).to include "title_ssim"
expect(labels).to include "Title"
expect(keys).to include "test_ssim"
expect(labels).to include "Power Rangers"
end
it "should have a tool config for edit" do
expect(subject.show.document_actions[:edit_record].partial).to eq "edit_action"
end
it "should only have bookmark and edit as document actions" do
expect(subject.show.document_actions.keys).to contain_exactly :bookmark, :edit_record
end
it "should have an edit action for index" do
expect(subject.index.document_actions[:edit_record].partial).to eq "edit_action"
end
it "should configure OEmbed" do
expect(subject.show.oembed_field).to eq :oembed_ssim
expect(subject.show.partials).to include :oembed
end
end
end