blacklight-spotlight 0.19.0 → 0.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/app/helpers/spotlight/title_helper.rb +1 -1
- data/lib/generators/spotlight/install_generator.rb +1 -1
- data/lib/spotlight/version.rb +1 -2
- data/spec/controllers/spotlight/resources/csv_upload_controller_spec.rb +0 -1
- data/spec/controllers/spotlight/resources/upload_controller_spec.rb +0 -1
- data/spec/features/javascript/blocks/featured_browse_categories_block_spec.rb +0 -1
- data/spec/features/javascript/blocks/featured_pages_block_spec.rb +0 -1
- data/spec/features/javascript/blocks/search_result_block_spec.rb +0 -1
- data/spec/features/javascript/blocks/solr_documents_block_spec.rb +0 -1
- data/spec/features/javascript/blocks/uploaded_items_block_spec.rb +0 -1
- data/spec/helpers/spotlight/application_helper_spec.rb +4 -11
- data/spec/helpers/spotlight/browse_helper_spec.rb +0 -1
- data/spec/helpers/spotlight/crud_link_helpers_spec.rb +124 -127
- data/spec/helpers/spotlight/jcrop_helper_spec.rb +0 -1
- data/spec/helpers/spotlight/navbar_helper_spec.rb +16 -19
- data/spec/helpers/spotlight/pages_helper_spec.rb +74 -76
- data/spec/helpers/spotlight/roles_helper_spec.rb +0 -1
- data/spec/helpers/spotlight/search_configurations_helper_spec.rb +0 -2
- data/spec/helpers/spotlight/title_helper_spec.rb +0 -1
- data/spec/models/sir_trevor_rails/blocks/browse_block_spec.rb +0 -1
- data/spec/models/sir_trevor_rails/blocks/solr_documents_block_spec.rb +0 -1
- data/spec/models/sir_trevor_rails/blocks/textable_spec.rb +0 -1
- data/spec/models/spotlight/analytics/ga_spec.rb +0 -1
- data/spec/models/spotlight/resources/open_graph_spec.rb +0 -1
- data/spec/models/spotlight/resources/upload_spec.rb +0 -1
- data/spec/models/spotlight/resources/web_spec.rb +0 -1
- data/spec/models/spotlight/solr_document/atomic_updates_spec.rb +0 -1
- data/spec/models/spotlight/solr_document/spotlight_images_spec.rb +0 -1
- data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +0 -1
- data/spec/routing/spotlight/exhibit_catalog_spec.rb +5 -8
- data/spec/test_app_templates/catalog_controller.rb +1 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -1
- data/spec/views/spotlight/about_pages/_empty.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/about_pages/_sidebar.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/about_pages/index.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/browse/_search.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/browse/_sort_and_per_page.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/browse/index.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/browse/show.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/catalog/_edit_default.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/catalog/admin.html.erb_spec.rb +31 -35
- data/spec/views/spotlight/catalog/edit.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/contacts/edit.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/dashboards/_analytics.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/dashboards/analytics.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/exhibits/_exhibit_card_front.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/exhibits/edit.html.erb_spec.rb +19 -21
- data/spec/views/spotlight/exhibits/index.html.erb_spec.rb +95 -99
- data/spec/views/spotlight/feature_pages/_empty.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/feature_pages/_sidebar.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/home_pages/_empty.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/home_pages/_sidebar.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/metadata_configurations/_metadata_field.html.erb_spec.rb +19 -23
- data/spec/views/spotlight/metadata_configurations/edit.html.erb_spec.rb +16 -20
- data/spec/views/spotlight/pages/edit.html.erb_spec.rb +43 -47
- data/spec/views/spotlight/pages/index.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/pages/new.html.erb_spec.rb +12 -16
- data/spec/views/spotlight/pages/show.html.erb_spec.rb +66 -61
- data/spec/views/spotlight/resources/_external_resources_form.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/resources/new.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/roles/index.html.erb_spec.rb +20 -25
- data/spec/views/spotlight/search_configurations/_facet_metadata.html.erb_spec.rb +20 -24
- data/spec/views/spotlight/search_configurations/_search_fields.html.erb_spec.rb +31 -45
- data/spec/views/spotlight/search_configurations/_sort.html.erb_spec.rb +19 -24
- data/spec/views/spotlight/searches/_search.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/searches/edit.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/searches/index.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/sir_trevor/blocks/_browse_block.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/sir_trevor/blocks/_iframe_block.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/sir_trevor/blocks/_rule_block.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb +0 -1
- data/spec/views/spotlight/sites/edit_exhibits.html.erb_spec.rb +18 -24
- data/spec/views/spotlight/tags/index.html.erb_spec.rb +0 -1
- metadata +180 -181
- data/lib/generators/spotlight/templates/jetty.rake +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fcd8fc066ada25ea481ac2794e080804013a3dd
|
4
|
+
data.tar.gz: b915e2ddab7b609f7359cca735298a04433fd5a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a905461d224104c93c8d6d215088e50e5c450e2abe82ca0db2d13e7c16f2e6abf0fad2eb41bb6cb4af872a1a130ab40fdf63e044645eeb46a1c2c7c0f58047e
|
7
|
+
data.tar.gz: bad97d38c3b0ddf5917e688068d64d6a6d22bfa5fbd6d4b2e96f8993250e008dea0900d6cec5a92ad843c35f509a4a41b3339356370125229475b18ffc1bf3fb
|
data/README.md
CHANGED
@@ -73,7 +73,6 @@ Our `$ rake ci` and `$ rake spotlight:server` tasks utilize Solr and the testing
|
|
73
73
|
## More Information for Developers
|
74
74
|
|
75
75
|
* [Contributing to Spotlight](https://github.com/projectblacklight/spotlight/wiki/Contributing-to-Spotlight)
|
76
|
-
* [Testing](https://github.com/projectblacklight/spotlight/wiki/Testing)
|
77
76
|
|
78
77
|
## Tests
|
79
78
|
|
@@ -17,7 +17,7 @@ module Spotlight
|
|
17
17
|
|
18
18
|
# rubocop:disable Style/AccessorMethodName
|
19
19
|
def set_html_page_title(title = nil)
|
20
|
-
@page_title = strip_tags(t(:'spotlight.html_title', title: title || t(:'.title', default: :'.header'), application_name: application_name))
|
20
|
+
@page_title = strip_tags(t(:'spotlight.html_title', title: title || t(:'.title', default: :'.header'), application_name: application_name)).html_safe
|
21
21
|
end
|
22
22
|
# rubocop:enable Style/AccessorMethodName
|
23
23
|
end
|
data/lib/spotlight/version.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
describe Spotlight::ApplicationHelper, type: :helper do
|
3
2
|
describe '#application_name' do
|
4
3
|
let(:site) { Spotlight::Site.instance }
|
@@ -77,6 +76,7 @@ describe Spotlight::ApplicationHelper, type: :helper do
|
|
77
76
|
end
|
78
77
|
end
|
79
78
|
end
|
79
|
+
|
80
80
|
describe 'render_document_class' do
|
81
81
|
let(:current_exhibit) { FactoryGirl.create(:exhibit) }
|
82
82
|
let(:document) { SolrDocument.new(some_field: 'Some data') }
|
@@ -133,13 +133,8 @@ describe Spotlight::ApplicationHelper, type: :helper do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
describe '#uploaded_field_label' do
|
136
|
-
let
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
let :blacklight_config do
|
141
|
-
Blacklight::Configuration.new
|
142
|
-
end
|
136
|
+
let(:field) { OpenStruct.new field_name: 'x' }
|
137
|
+
let(:blacklight_config) { Blacklight::Configuration.new }
|
143
138
|
|
144
139
|
before do
|
145
140
|
allow(helper).to receive_messages(blacklight_config: blacklight_config)
|
@@ -157,9 +152,7 @@ describe Spotlight::ApplicationHelper, type: :helper do
|
|
157
152
|
end
|
158
153
|
|
159
154
|
describe '#available_view_fields' do
|
160
|
-
let
|
161
|
-
Blacklight::Configuration.new
|
162
|
-
end
|
155
|
+
let(:blacklight_config) { Blacklight::Configuration.new }
|
163
156
|
|
164
157
|
before do
|
165
158
|
allow(helper).to receive_message_chain(:current_exhibit, :blacklight_configuration, default_blacklight_config: blacklight_config)
|
@@ -1,132 +1,129 @@
|
|
1
|
+
describe Spotlight::CrudLinkHelpers, type: :helper do
|
2
|
+
let(:exhibit) { FactoryGirl.create(:exhibit) }
|
3
|
+
let(:some_model) { Spotlight::FeaturePage.create! exhibit: exhibit }
|
4
|
+
describe '#cancel_link' do
|
5
|
+
it 'is a model-specific cancel link' do
|
6
|
+
expect(helper).to receive(:action_default_value).with(:my_model, :cancel).and_return 'Cancel'
|
7
|
+
expect(helper.cancel_link(:my_model, '#')).to have_link 'Cancel', href: '#'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#exhibit_view_link' do
|
12
|
+
before do
|
13
|
+
allow(helper).to receive_messages action_default_value: 'View'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'is a model-specific view link' do
|
17
|
+
expect(helper).to receive(:action_default_value).with(some_model, :view).and_return 'View'
|
18
|
+
expect(helper.exhibit_view_link(some_model)).to have_link 'View', href: spotlight.exhibit_feature_page_path(some_model.exhibit, some_model)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'accepts an explicit link' do
|
22
|
+
expect(helper.exhibit_view_link(some_model, '#')).to have_link 'View', href: '#'
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'accepts link_to options' do
|
26
|
+
expect(helper.exhibit_view_link(some_model, '#', class: 'btn')).to have_selector 'a.btn'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#exhibit_create_link' do
|
31
|
+
let(:some_model) { Spotlight::FeaturePage.new }
|
32
|
+
before do
|
33
|
+
allow(helper).to receive_messages(current_exhibit: exhibit)
|
34
|
+
allow(helper).to receive_messages action_default_value: 'Create'
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'is a model-specific view link' do
|
38
|
+
expect(helper).to receive(:action_default_value).with(some_model).and_return 'Create'
|
39
|
+
expect(helper.exhibit_create_link(some_model)).to have_link 'Create', href: spotlight.new_exhibit_feature_page_path(exhibit)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'accepts an explicit link' do
|
43
|
+
expect(helper.exhibit_create_link(some_model, '#')).to have_link 'Create', href: '#'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'accepts link_to options' do
|
47
|
+
expect(helper.exhibit_create_link(some_model, '#', class: 'btn')).to have_selector 'a.btn'
|
48
|
+
end
|
49
|
+
end
|
1
50
|
|
2
|
-
|
3
|
-
describe CrudLinkHelpers, type: :helper do
|
4
|
-
let(:exhibit) { FactoryGirl.create(:exhibit) }
|
51
|
+
describe '#exhibit_edit_link' do
|
5
52
|
let(:some_model) { Spotlight::FeaturePage.create! exhibit: exhibit }
|
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
|
-
expect(helper).to receive(:action_default_value).with(some_model, :destroy).and_return 'Delete'
|
81
|
-
expect(helper.exhibit_delete_link(some_model)).to have_link 'Delete', href: spotlight.exhibit_feature_page_path(some_model.exhibit, some_model)
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'accepts an explicit link' do
|
85
|
-
expect(helper.exhibit_delete_link(some_model, '#')).to have_link 'Delete', href: '#'
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'accepts link_to options' do
|
89
|
-
expect(helper.exhibit_delete_link(some_model, '#', class: 'btn')).to have_selector 'a.btn'
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe '#action_label' do
|
94
|
-
it 'returns the label for an action on a model' do
|
95
|
-
some_model = double
|
96
|
-
expect(helper).to receive(:action_default_value).with(some_model, :action).and_return 'xyz'
|
97
|
-
expect(helper.action_label(some_model, :action)).to eq 'xyz'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#action_default_value' do
|
102
|
-
it 'attempts i18n lookups for models' do
|
103
|
-
expect(I18n).to receive(:t).with(:'helpers.action.spotlight/feature_page.edit',
|
104
|
-
model: some_model.class.model_name.human,
|
105
|
-
default: [:'helpers.action.edit', 'Edit Feature page'])
|
106
|
-
expect(helper.send(:action_default_value, some_model))
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'attempts i18n lookups for unpersisted models' do
|
110
|
-
some_model = Spotlight::FeaturePage.new
|
111
|
-
expect(I18n).to receive(:t).with(:'helpers.action.spotlight/feature_page.create',
|
112
|
-
model: some_model.class.model_name.human,
|
113
|
-
default: [:'helpers.action.create', 'Create Feature page'])
|
114
|
-
expect(helper.send(:action_default_value, some_model))
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'attempts i18n lookups for models with an explicit action' do
|
118
|
-
expect(I18n).to receive(:t).with(:'helpers.action.spotlight/feature_page.custom_action',
|
119
|
-
model: some_model.class.model_name.human,
|
120
|
-
default: [:'helpers.action.custom_action', 'Custom action Feature page'])
|
121
|
-
expect(helper.send(:action_default_value, some_model, :custom_action))
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'attempts i18n lookups for symbols' do
|
125
|
-
expect(I18n).to receive(:t).with(:'helpers.action.my_thing.custom_action',
|
126
|
-
model: :my_thing,
|
127
|
-
default: [:'helpers.action.custom_action', 'Custom action my_thing'])
|
128
|
-
expect(helper.send(:action_default_value, :my_thing, :custom_action))
|
129
|
-
end
|
53
|
+
before do
|
54
|
+
allow(helper).to receive_messages(current_exhibit: exhibit)
|
55
|
+
allow(helper).to receive_messages action_default_value: 'Edit'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'is a model-specific edit link' do
|
59
|
+
expect(helper).to receive(:action_default_value).with(some_model).and_return 'Edit'
|
60
|
+
expect(helper.exhibit_edit_link(some_model)).to have_link 'Edit', href: spotlight.edit_exhibit_feature_page_path(exhibit, some_model)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'accepts an explicit link' do
|
64
|
+
expect(helper.exhibit_edit_link(some_model, '#')).to have_link 'Edit', href: '#'
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'accepts link_to options' do
|
68
|
+
expect(helper.exhibit_edit_link(some_model, '#', class: 'btn')).to have_selector 'a.btn'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#exhibit_delete_link' do
|
73
|
+
before do
|
74
|
+
allow(helper).to receive_messages action_default_value: 'Delete'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'is a model-specific view link' do
|
78
|
+
expect(helper).to receive(:action_default_value).with(some_model, :destroy).and_return 'Delete'
|
79
|
+
expect(helper.exhibit_delete_link(some_model)).to have_link 'Delete', href: spotlight.exhibit_feature_page_path(some_model.exhibit, some_model)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'accepts an explicit link' do
|
83
|
+
expect(helper.exhibit_delete_link(some_model, '#')).to have_link 'Delete', href: '#'
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'accepts link_to options' do
|
87
|
+
expect(helper.exhibit_delete_link(some_model, '#', class: 'btn')).to have_selector 'a.btn'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#action_label' do
|
92
|
+
it 'returns the label for an action on a model' do
|
93
|
+
some_model = double
|
94
|
+
expect(helper).to receive(:action_default_value).with(some_model, :action).and_return 'xyz'
|
95
|
+
expect(helper.action_label(some_model, :action)).to eq 'xyz'
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#action_default_value' do
|
100
|
+
it 'attempts i18n lookups for models' do
|
101
|
+
expect(I18n).to receive(:t).with(:'helpers.action.spotlight/feature_page.edit',
|
102
|
+
model: some_model.class.model_name.human,
|
103
|
+
default: [:'helpers.action.edit', 'Edit Feature page'])
|
104
|
+
expect(helper.send(:action_default_value, some_model))
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'attempts i18n lookups for unpersisted models' do
|
108
|
+
some_model = Spotlight::FeaturePage.new
|
109
|
+
expect(I18n).to receive(:t).with(:'helpers.action.spotlight/feature_page.create',
|
110
|
+
model: some_model.class.model_name.human,
|
111
|
+
default: [:'helpers.action.create', 'Create Feature page'])
|
112
|
+
expect(helper.send(:action_default_value, some_model))
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'attempts i18n lookups for models with an explicit action' do
|
116
|
+
expect(I18n).to receive(:t).with(:'helpers.action.spotlight/feature_page.custom_action',
|
117
|
+
model: some_model.class.model_name.human,
|
118
|
+
default: [:'helpers.action.custom_action', 'Custom action Feature page'])
|
119
|
+
expect(helper.send(:action_default_value, some_model, :custom_action))
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'attempts i18n lookups for symbols' do
|
123
|
+
expect(I18n).to receive(:t).with(:'helpers.action.my_thing.custom_action',
|
124
|
+
model: :my_thing,
|
125
|
+
default: [:'helpers.action.custom_action', 'Custom action my_thing'])
|
126
|
+
expect(helper.send(:action_default_value, :my_thing, :custom_action))
|
130
127
|
end
|
131
128
|
end
|
132
129
|
end
|
@@ -1,22 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
allow(helper).to receive_messages(exhibit_masthead?: false)
|
18
|
-
expect(helper.should_render_spotlight_search_bar?).to be_falsey
|
19
|
-
end
|
1
|
+
describe Spotlight::NavbarHelper, type: :helper do
|
2
|
+
describe '#should_render_search_bar?' do
|
3
|
+
before do
|
4
|
+
allow(helper).to receive_messages(current_exhibit: nil)
|
5
|
+
allow(helper).to receive_messages(exhibit_masthead?: true)
|
6
|
+
end
|
7
|
+
it 'returns false when there is no exhibit context' do
|
8
|
+
expect(helper.should_render_spotlight_search_bar?).to be_falsey
|
9
|
+
end
|
10
|
+
it 'returns true if searchable' do
|
11
|
+
allow(helper).to receive_messages(current_exhibit: double(searchable?: true))
|
12
|
+
expect(helper.should_render_spotlight_search_bar?).to be_truthy
|
13
|
+
end
|
14
|
+
it 'returns false if currently under an "Exhibity" browse category' do
|
15
|
+
allow(helper).to receive_messages(exhibit_masthead?: false)
|
16
|
+
expect(helper.should_render_spotlight_search_bar?).to be_falsey
|
20
17
|
end
|
21
18
|
end
|
22
19
|
end
|
@@ -1,95 +1,93 @@
|
|
1
|
+
describe Spotlight::PagesHelper, type: :helper do
|
2
|
+
let(:blacklight_config) { Blacklight::Configuration.new { |config| config.show.title_field = :abc } }
|
3
|
+
let(:titled_document) { blacklight_config.document_model.new(abc: 'value') }
|
4
|
+
let(:untitled_document) { blacklight_config.document_model.new(id: '1234') }
|
5
|
+
let!(:current_exhibit) { FactoryGirl.create(:exhibit) }
|
6
|
+
let!(:home_page) { current_exhibit.home_page }
|
7
|
+
let!(:search) { FactoryGirl.create(:search, exhibit: current_exhibit, query_params: { 'q' => 'query' }, published: true) }
|
1
8
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
let(:titled_document) { blacklight_config.document_model.new(abc: 'value') }
|
6
|
-
let(:untitled_document) { blacklight_config.document_model.new(id: '1234') }
|
7
|
-
let!(:current_exhibit) { FactoryGirl.create(:exhibit) }
|
8
|
-
let!(:home_page) { current_exhibit.home_page }
|
9
|
-
let!(:search) { FactoryGirl.create(:search, exhibit: current_exhibit, query_params: { 'q' => 'query' }, published: true) }
|
9
|
+
before(:each) do
|
10
|
+
allow(helper).to receive_messages(blacklight_config: blacklight_config)
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
describe 'available_index_fields' do
|
14
|
+
before do
|
15
|
+
blacklight_config.index.title_field = :title_field
|
16
|
+
blacklight_config.add_index_field 'x', label: 'X'
|
13
17
|
end
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
blacklight_config.add_index_field 'x', label: 'X'
|
19
|
-
end
|
19
|
+
it 'lists the configured index fields' do
|
20
|
+
expect(helper.available_index_fields).to include key: 'x', label: 'X'
|
21
|
+
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
it 'adds the title field if necessary' do
|
24
|
+
expect(helper.available_index_fields).to include key: :title_field, label: 'Title'
|
25
|
+
end
|
26
|
+
end
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
describe 'disable_save_pages_button?' do
|
29
|
+
it 'returns true if there are no pages and we are on the about pages page' do
|
30
|
+
expect(helper).to receive(:page_collection_name).and_return('about_pages')
|
31
|
+
assign(:pages, [])
|
32
|
+
expect(helper.disable_save_pages_button?).to be_truthy
|
33
|
+
end
|
34
|
+
it 'returns false if there are about pages' do
|
35
|
+
expect(helper).to receive(:page_collection_name).and_return('about_pages')
|
36
|
+
assign(:pages, [{}])
|
37
|
+
expect(helper.disable_save_pages_button?).to be_falsey
|
38
|
+
end
|
39
|
+
it 'returns false if on the feature pages page' do
|
40
|
+
expect(helper).to receive(:page_collection_name).and_return('feature_pages')
|
41
|
+
assign(:pages, [])
|
42
|
+
expect(helper.disable_save_pages_button?).to be_falsey
|
28
43
|
end
|
44
|
+
end
|
29
45
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
expect(helper.disable_save_pages_button?).to be_truthy
|
35
|
-
end
|
36
|
-
it 'returns false if there are about pages' do
|
37
|
-
expect(helper).to receive(:page_collection_name).and_return('about_pages')
|
38
|
-
assign(:pages, [{}])
|
39
|
-
expect(helper.disable_save_pages_button?).to be_falsey
|
40
|
-
end
|
41
|
-
it 'returns false if on the feature pages page' do
|
42
|
-
expect(helper).to receive(:page_collection_name).and_return('feature_pages')
|
43
|
-
assign(:pages, [])
|
44
|
-
expect(helper.disable_save_pages_button?).to be_falsey
|
45
|
-
end
|
46
|
+
describe 'get_search_widget_search_results' do
|
47
|
+
let(:good) do
|
48
|
+
content = { type: 'xyz', data: { 'item' => { search.slug => { id: search.slug, display: 'true' } } } }
|
49
|
+
SirTrevorRails::Blocks::SearchResultsBlock.new(content, home_page)
|
46
50
|
end
|
47
|
-
describe 'get_search_widget_search_results' do
|
48
|
-
let(:good) do
|
49
|
-
content = { type: 'xyz', data: { 'item' => { search.slug => { id: search.slug, display: 'true' } } } }
|
50
|
-
SirTrevorRails::Blocks::SearchResultsBlock.new(content, home_page)
|
51
|
-
end
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
let(:bad) do
|
53
|
+
content = { type: 'xyz', data: { 'item' => { 'garbage' => { id: 'missing', display: 'true' } } } }
|
54
|
+
SirTrevorRails::Blocks::SearchResultsBlock.new(content, home_page)
|
55
|
+
end
|
57
56
|
|
58
|
-
|
57
|
+
let(:search_result) { [double('response'), double('documents')] }
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
it 'returns the results for a given search browse category' do
|
60
|
+
expect(helper).to receive(:search_results).with('q' => 'query').and_return(search_result)
|
61
|
+
expect(helper.get_search_widget_search_results(good)).to eq search_result
|
62
|
+
end
|
63
|
+
it "returns an empty array when requesting a search that doesn't exist" do
|
64
|
+
expect(helper.get_search_widget_search_results(bad)).to be_empty
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'nestable helpers' do
|
69
|
+
describe 'nestable data attributes' do
|
70
|
+
it 'returns the appropriate attributes for feature pages' do
|
71
|
+
expect(helper.nestable_data_attributes('feature_pages')).to eq "data-max-depth='2' data-expand-btn-HTML='' data-collapse-btn-HTML=''"
|
72
|
+
end
|
73
|
+
it 'returns the appropriate attributes for about pages' do
|
74
|
+
expect(helper.nestable_data_attributes('about_pages')).to eq "data-max-depth='1'"
|
63
75
|
end
|
64
|
-
it
|
65
|
-
expect(helper.
|
76
|
+
it 'returns a blank string if the type is not valid' do
|
77
|
+
expect(helper.nestable_data_attributes('something_else')).to eq ''
|
66
78
|
end
|
67
79
|
end
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
it 'returns a blank string if the type is not valid' do
|
78
|
-
expect(helper.nestable_data_attributes('something_else')).to eq ''
|
79
|
-
end
|
80
|
+
describe 'nestable data attributes hash' do
|
81
|
+
it 'returns the appropriate hash for feature pages' do
|
82
|
+
expect(helper.nestable_data_attributes_hash('feature_pages')).to eq('data-max-depth' => '2',
|
83
|
+
'data-expand-btn-HTML' => '',
|
84
|
+
'data-collapse-btn-HTML' => '')
|
85
|
+
end
|
86
|
+
it 'returns the appropriate hash for about pages' do
|
87
|
+
expect(helper.nestable_data_attributes_hash('about_pages')).to eq 'data-max-depth' => '1'
|
80
88
|
end
|
81
|
-
|
82
|
-
|
83
|
-
expect(helper.nestable_data_attributes_hash('feature_pages')).to eq('data-max-depth' => '2',
|
84
|
-
'data-expand-btn-HTML' => '',
|
85
|
-
'data-collapse-btn-HTML' => '')
|
86
|
-
end
|
87
|
-
it 'returns the appropriate hash for about pages' do
|
88
|
-
expect(helper.nestable_data_attributes_hash('about_pages')).to eq 'data-max-depth' => '1'
|
89
|
-
end
|
90
|
-
it 'returns an empty hash if the type is not valid' do
|
91
|
-
expect(helper.nestable_data_attributes_hash('something_else')).to eq({})
|
92
|
-
end
|
89
|
+
it 'returns an empty hash if the type is not valid' do
|
90
|
+
expect(helper.nestable_data_attributes_hash('something_else')).to eq({})
|
93
91
|
end
|
94
92
|
end
|
95
93
|
end
|