blacklight-spotlight 0.12.1 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/spotlight/_exhibits_index.scss +16 -0
  3. data/app/assets/stylesheets/spotlight/_nestable.scss +10 -10
  4. data/app/controllers/spotlight/catalog_controller.rb +10 -7
  5. data/app/controllers/spotlight/concerns/catalog_search_context.rb +15 -2
  6. data/app/controllers/spotlight/exhibits_controller.rb +1 -0
  7. data/app/helpers/spotlight/application_helper.rb +1 -1
  8. data/app/models/concerns/spotlight/solr_document.rb +20 -20
  9. data/app/models/concerns/spotlight/user.rb +1 -0
  10. data/app/models/spotlight/blacklight_configuration.rb +10 -4
  11. data/app/models/spotlight/custom_field.rb +5 -1
  12. data/app/models/spotlight/exhibit.rb +1 -1
  13. data/app/models/spotlight/resource.rb +1 -1
  14. data/app/models/spotlight/search.rb +1 -1
  15. data/app/models/spotlight/solr_document_sidecar.rb +1 -1
  16. data/app/views/layouts/spotlight/spotlight.html.erb +1 -1
  17. data/app/views/spotlight/exhibits/_exhibit_card.html.erb +3 -0
  18. data/app/views/spotlight/exhibits/index.html.erb +40 -15
  19. data/config/locales/spotlight.en.yml +4 -1
  20. data/lib/spotlight/catalog.rb +14 -11
  21. data/lib/spotlight/catalog/access_controls_enforcement.rb +2 -1
  22. data/lib/spotlight/engine.rb +5 -0
  23. data/lib/spotlight/version.rb +1 -1
  24. data/spec/controllers/spotlight/about_pages_controller_spec.rb +1 -1
  25. data/spec/controllers/spotlight/appearances_controller_spec.rb +10 -8
  26. data/spec/controllers/spotlight/browse_controller_spec.rb +3 -3
  27. data/spec/controllers/spotlight/catalog_controller_spec.rb +88 -7
  28. data/spec/controllers/spotlight/confirmations_controller_spec.rb +7 -4
  29. data/spec/controllers/spotlight/contact_forms_controller_spec.rb +1 -1
  30. data/spec/controllers/spotlight/exhibits_controller_spec.rb +25 -21
  31. data/spec/controllers/spotlight/home_pages_controller_spec.rb +23 -24
  32. data/spec/controllers/spotlight/metadata_configurations_controller_spec.rb +17 -13
  33. data/spec/controllers/spotlight/resources/upload_controller_spec.rb +1 -1
  34. data/spec/controllers/spotlight/resources_controller_spec.rb +3 -3
  35. data/spec/controllers/spotlight/roles_controller_spec.rb +5 -3
  36. data/spec/controllers/spotlight/search_configurations_controller_spec.rb +10 -8
  37. data/spec/controllers/spotlight/searches_controller_spec.rb +12 -8
  38. data/spec/controllers/spotlight/solr_controller_spec.rb +34 -29
  39. data/spec/controllers/spotlight/versions_controller_spec.rb +2 -2
  40. data/spec/controllers/spotlight/view_configurations_controller_spec.rb +7 -5
  41. data/spec/helpers/spotlight/application_helper_spec.rb +1 -1
  42. data/spec/helpers/spotlight/pages_helper_spec.rb +2 -2
  43. data/spec/models/solr_document_spec.rb +5 -5
  44. data/spec/models/spotlight/custom_field_spec.rb +8 -9
  45. data/spec/models/spotlight/resources/open_graph_spec.rb +1 -1
  46. data/spec/models/spotlight/search_spec.rb +10 -0
  47. data/spec/models/spotlight/sitemap_spec.rb +1 -1
  48. data/spec/models/spotlight/solr_document/atomic_updates_spec.rb +1 -1
  49. data/spec/models/spotlight/solr_document/uploaded_resource_spec.rb +6 -6
  50. data/spec/views/spotlight/exhibits/index.html.erb_spec.rb +35 -6
  51. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_block.html.erb_spec.rb +1 -1
  52. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb_spec.rb +5 -1
  53. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb_spec.rb +1 -1
  54. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb_spec.rb +3 -3
  55. data/spec/views/spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb_spec.rb +5 -1
  56. metadata +2 -5
  57. data/app/views/shared/_flash_messages.html.erb +0 -7
  58. data/app/views/spotlight/exhibits/_exhibit_list.html.erb +0 -3
  59. data/db/migrate/20151210073829_create_spotlight_configuration.rb +0 -7
@@ -47,7 +47,7 @@ describe Spotlight::HomePagesController, type: :controller do
47
47
  end
48
48
  end
49
49
 
50
- describe 'Rendering home page' do
50
+ describe 'GET show' do
51
51
  it 'gets search results for display facets' do
52
52
  allow(controller).to receive_messages(search_results: [double, double])
53
53
  get :show, exhibit_id: exhibit
@@ -69,33 +69,32 @@ describe Spotlight::HomePagesController, type: :controller do
69
69
  expect(assigns).not_to have_key :response
70
70
  expect(assigns).not_to have_key :document_list
71
71
  end
72
- end
73
72
 
74
- describe 'when the exhibit is not published' do
75
- before do
76
- exhibit.published = false
77
- exhibit.save!
78
- end
79
-
80
- it 'redirects an anonymous user to the signin path' do
81
- get :show, exhibit_id: exhibit
82
- expect(response).to redirect_to(main_app.new_user_session_path)
83
- end
73
+ context 'when the exhibit is not published' do
74
+ before do
75
+ exhibit.update(published: false)
76
+ end
84
77
 
85
- it 'redirects an unauthorized user to the signin path' do
86
- user = FactoryGirl.create(:exhibit_curator)
87
- sign_in user
88
- expect do
78
+ it 'redirects an anonymous user to the signin path' do
89
79
  get :show, exhibit_id: exhibit
90
- end.to raise_error ActionController::RoutingError
91
- end
80
+ expect(response).to redirect_to(main_app.new_user_session_path)
81
+ end
92
82
 
93
- it 'redirects an authorized user to the signin path' do
94
- user = FactoryGirl.create(:exhibit_curator)
95
- FactoryGirl.create(:role, exhibit: exhibit, user: user)
96
- sign_in user
97
- get :show, exhibit_id: exhibit
98
- expect(response).to be_successful
83
+ it 'redirects an unauthorized user to the signin path' do
84
+ user = FactoryGirl.create(:exhibit_curator)
85
+ sign_in user
86
+ expect do
87
+ get :show, exhibit_id: exhibit
88
+ end.to raise_error ActionController::RoutingError
89
+ end
90
+
91
+ it 'redirects an authorized user to the signin path' do
92
+ user = FactoryGirl.create(:exhibit_curator)
93
+ FactoryGirl.create(:role, exhibit: exhibit, user: user)
94
+ sign_in user
95
+ get :show, exhibit_id: exhibit
96
+ expect(response).to be_successful
97
+ end
99
98
  end
100
99
  end
101
100
  end
@@ -8,28 +8,32 @@ describe Spotlight::MetadataConfigurationsController, type: :controller do
8
8
  sign_in FactoryGirl.create(:exhibit_visitor)
9
9
  end
10
10
 
11
- it 'denies access' do
12
- get :show, exhibit_id: exhibit
13
- expect(response).to redirect_to main_app.root_path
14
- expect(flash[:alert]).to be_present
11
+ describe 'GET show' do
12
+ it 'denies access' do
13
+ get :show, exhibit_id: exhibit
14
+ expect(response).to redirect_to main_app.root_path
15
+ expect(flash[:alert]).to be_present
16
+ end
15
17
  end
16
18
 
17
- it 'denies access' do
18
- get :edit, exhibit_id: exhibit
19
- expect(response).to redirect_to main_app.root_path
20
- expect(flash[:alert]).to be_present
19
+ describe 'GET edit' do
20
+ it 'denies access' do
21
+ get :edit, exhibit_id: exhibit
22
+ expect(response).to redirect_to main_app.root_path
23
+ expect(flash[:alert]).to be_present
24
+ end
21
25
  end
22
26
  end
23
27
 
24
28
  describe 'when not logged in' do
25
- describe '#update' do
29
+ describe 'PATCH update' do
26
30
  it 'denies access' do
27
31
  patch :update, exhibit_id: exhibit
28
32
  expect(response).to redirect_to main_app.new_user_session_path
29
33
  end
30
34
  end
31
35
 
32
- describe '#edit' do
36
+ describe 'GET edit' do
33
37
  it 'denies access' do
34
38
  get :edit, exhibit_id: exhibit
35
39
  expect(response).to redirect_to main_app.new_user_session_path
@@ -41,7 +45,7 @@ describe Spotlight::MetadataConfigurationsController, type: :controller do
41
45
  let(:user) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
42
46
  before { sign_in user }
43
47
 
44
- describe '#edit' do
48
+ describe 'GET edit' do
45
49
  it 'is successful' do
46
50
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
47
51
  expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
@@ -51,7 +55,7 @@ describe Spotlight::MetadataConfigurationsController, type: :controller do
51
55
  end
52
56
  end
53
57
 
54
- describe '#show' do
58
+ describe 'GET show' do
55
59
  it 'is successful' do
56
60
  get :show, exhibit_id: exhibit, format: 'json'
57
61
  expect(response).to be_successful
@@ -59,7 +63,7 @@ describe Spotlight::MetadataConfigurationsController, type: :controller do
59
63
  end
60
64
  end
61
65
 
62
- describe '#update' do
66
+ describe 'PATCH update' do
63
67
  it 'updates metadata fields' do
64
68
  blacklight_config = Blacklight::Configuration.new
65
69
  blacklight_config.add_index_field %w(a b c d e f)
@@ -6,7 +6,7 @@ describe Spotlight::Resources::UploadController, type: :controller do
6
6
 
7
7
  describe 'when not logged in' do
8
8
  describe 'POST create' do
9
- it 'does not be allowed' do
9
+ it 'is not allowed' do
10
10
  post :create, exhibit_id: exhibit
11
11
  expect(response).to redirect_to main_app.new_user_session_path
12
12
  end
@@ -6,21 +6,21 @@ describe Spotlight::ResourcesController, type: :controller do
6
6
 
7
7
  describe 'when not logged in' do
8
8
  describe 'GET new' do
9
- it 'does not be allowed' do
9
+ it 'is not allowed' do
10
10
  get :new, exhibit_id: exhibit
11
11
  expect(response).to redirect_to main_app.new_user_session_path
12
12
  end
13
13
  end
14
14
 
15
15
  describe 'POST create' do
16
- it 'does not be allowed' do
16
+ it 'is not allowed' do
17
17
  post :create, exhibit_id: exhibit
18
18
  expect(response).to redirect_to main_app.new_user_session_path
19
19
  end
20
20
  end
21
21
 
22
22
  describe 'POST reindex_all' do
23
- it 'does not be allowed' do
23
+ it 'is not allowed' do
24
24
  post :reindex_all, exhibit_id: exhibit
25
25
  expect(response).to redirect_to main_app.new_user_session_path
26
26
  end
@@ -6,9 +6,11 @@ describe Spotlight::RolesController, type: :controller do
6
6
 
7
7
  describe 'when user does not have access' do
8
8
  before { sign_in FactoryGirl.create(:exhibit_visitor) }
9
- it 'does not allow index' do
10
- get :index, exhibit_id: exhibit
11
- expect(response).to redirect_to main_app.root_path
9
+ describe 'GET index' do
10
+ it 'denies access' do
11
+ get :index, exhibit_id: exhibit
12
+ expect(response).to redirect_to main_app.root_path
13
+ end
12
14
  end
13
15
  end
14
16
 
@@ -8,22 +8,24 @@ describe Spotlight::SearchConfigurationsController, type: :controller do
8
8
  sign_in FactoryGirl.create(:exhibit_visitor)
9
9
  end
10
10
 
11
- it 'denies access' do
12
- get :edit, exhibit_id: exhibit
13
- expect(response).to redirect_to main_app.root_path
14
- expect(flash[:alert]).to be_present
11
+ describe 'GET edit' do
12
+ it 'denies access' do
13
+ get :edit, exhibit_id: exhibit
14
+ expect(response).to redirect_to main_app.root_path
15
+ expect(flash[:alert]).to be_present
16
+ end
15
17
  end
16
18
  end
17
19
 
18
20
  describe 'when not logged in' do
19
- describe '#update' do
21
+ describe 'PATCH update' do
20
22
  it 'denies access' do
21
23
  patch :update, exhibit_id: exhibit
22
24
  expect(response).to redirect_to main_app.new_user_session_path
23
25
  end
24
26
  end
25
27
 
26
- describe '#edit' do
28
+ describe 'GET edit' do
27
29
  it 'denies access' do
28
30
  get :edit, exhibit_id: exhibit
29
31
  expect(response).to redirect_to main_app.new_user_session_path
@@ -35,7 +37,7 @@ describe Spotlight::SearchConfigurationsController, type: :controller do
35
37
  let(:user) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
36
38
  before { sign_in user }
37
39
 
38
- describe '#edit' do
40
+ describe 'GET edit' do
39
41
  it 'is successful' do
40
42
  expect(controller).to receive(:add_breadcrumb).with('Home', exhibit)
41
43
  expect(controller).to receive(:add_breadcrumb).with('Configuration', exhibit_dashboard_path(exhibit))
@@ -52,7 +54,7 @@ describe Spotlight::SearchConfigurationsController, type: :controller do
52
54
  end
53
55
  end
54
56
 
55
- describe '#update' do
57
+ describe 'PATCH update' do
56
58
  it 'updates facet fields' do
57
59
  patch :update, exhibit_id: exhibit, blacklight_configuration: {
58
60
  facet_fields: { 'genre_ssim' => { enabled: '1', label: 'Label' } }
@@ -13,16 +13,20 @@ describe Spotlight::SearchesController, type: :controller do
13
13
  sign_in FactoryGirl.create(:exhibit_visitor)
14
14
  end
15
15
 
16
- it 'raises an error' do
17
- post :create, exhibit_id: exhibit
18
- expect(response).to redirect_to main_app.root_path
19
- expect(flash[:alert]).to be_present
16
+ describe 'POST create' do
17
+ it 'denies access' do
18
+ post :create, exhibit_id: exhibit
19
+ expect(response).to redirect_to main_app.root_path
20
+ expect(flash[:alert]).to be_present
21
+ end
20
22
  end
21
23
 
22
- it 'raises an error' do
23
- get :index, exhibit_id: exhibit
24
- expect(response).to redirect_to main_app.root_path
25
- expect(flash[:alert]).to be_present
24
+ describe 'GET index' do
25
+ it 'denies access' do
26
+ get :index, exhibit_id: exhibit
27
+ expect(response).to redirect_to main_app.root_path
28
+ expect(flash[:alert]).to be_present
29
+ end
26
30
  end
27
31
  end
28
32
 
@@ -6,9 +6,12 @@ describe Spotlight::SolrController, type: :controller do
6
6
 
7
7
  describe 'when user does not have access' do
8
8
  before { sign_in FactoryGirl.create(:exhibit_visitor) }
9
- it 'does not allow update' do
10
- post :update, exhibit_id: exhibit
11
- expect(response).to redirect_to main_app.root_path
9
+
10
+ describe 'POST update' do
11
+ it 'does not allow update' do
12
+ post :update, exhibit_id: exhibit
13
+ expect(response).to redirect_to main_app.root_path
14
+ end
12
15
  end
13
16
  end
14
17
 
@@ -21,42 +24,44 @@ describe Spotlight::SolrController, type: :controller do
21
24
  expect(controller).to receive(:blacklight_solr).and_return(solr)
22
25
  end
23
26
 
24
- it 'passes through the request data' do
25
- doc = {}
26
- expect(solr).to receive(:update) do |arr|
27
- doc = arr.first
28
- end
29
-
30
- post :update, { a: 1 }.to_json, content_type: :json, exhibit_id: exhibit
27
+ describe 'POST update' do
28
+ it 'passes through the request data' do
29
+ doc = {}
30
+ expect(solr).to receive(:update) do |arr|
31
+ doc = arr.first
32
+ end
31
33
 
32
- expect(response).to be_successful
33
- expect(doc).to include 'a' => 1
34
- end
34
+ post :update, { a: 1 }.to_json, content_type: :json, exhibit_id: exhibit
35
35
 
36
- it 'enriches the request with exhibit solr data' do
37
- doc = {}
38
- expect(solr).to receive(:update) do |arr|
39
- doc = arr.first
36
+ expect(response).to be_successful
37
+ expect(doc).to include 'a' => 1
40
38
  end
41
39
 
42
- post :update, { a: 1 }.to_json, content_type: :json, exhibit_id: exhibit
40
+ it 'enriches the request with exhibit solr data' do
41
+ doc = {}
42
+ expect(solr).to receive(:update) do |arr|
43
+ doc = arr.first
44
+ end
43
45
 
44
- expect(response).to be_successful
45
- expect(doc).to include exhibit.solr_data
46
- end
46
+ post :update, { a: 1 }.to_json, content_type: :json, exhibit_id: exhibit
47
47
 
48
- it 'enriches the request with sidecar data' do
49
- doc = {}
50
- expect(solr).to receive(:update) do |arr|
51
- doc = arr.first
48
+ expect(response).to be_successful
49
+ expect(doc).to include exhibit.solr_data
52
50
  end
53
51
 
54
- allow_any_instance_of(SolrDocument).to receive(:to_solr).and_return(b: 1)
52
+ it 'enriches the request with sidecar data' do
53
+ doc = {}
54
+ expect(solr).to receive(:update) do |arr|
55
+ doc = arr.first
56
+ end
55
57
 
56
- post :update, { a: 1 }.to_json, content_type: :json, exhibit_id: exhibit
58
+ allow_any_instance_of(SolrDocument).to receive(:to_solr).and_return(b: 1)
57
59
 
58
- expect(response).to be_successful
59
- expect(doc).to include b: 1
60
+ post :update, { a: 1 }.to_json, content_type: :json, exhibit_id: exhibit
61
+
62
+ expect(response).to be_successful
63
+ expect(doc).to include b: 1
64
+ end
60
65
  end
61
66
  end
62
67
  end
@@ -5,7 +5,7 @@ describe Spotlight::VersionsController, type: :controller do
5
5
 
6
6
  describe 'when not logged in' do
7
7
  describe 'POST revert' do
8
- it 'does not be allowed' do
8
+ it 'is not allowed' do
9
9
  post :revert, id: 1
10
10
  expect(response).to redirect_to main_app.new_user_session_path
11
11
  end
@@ -21,7 +21,7 @@ describe Spotlight::VersionsController, type: :controller do
21
21
  end
22
22
 
23
23
  describe 'POST revert' do
24
- it 'does not be allowed' do
24
+ it 'is not allowed' do
25
25
  post :revert, id: page.versions.last
26
26
  expect(response).to redirect_to main_app.root_path
27
27
  expect(flash[:alert]).to be_present
@@ -8,10 +8,12 @@ describe Spotlight::ViewConfigurationsController, type: :controller do
8
8
  sign_in FactoryGirl.create(:exhibit_visitor)
9
9
  end
10
10
 
11
- it 'denies access' do
12
- get :show, exhibit_id: exhibit
13
- expect(response).to redirect_to main_app.root_path
14
- expect(flash[:alert]).to be_present
11
+ describe 'GET show' do
12
+ it 'denies access' do
13
+ get :show, exhibit_id: exhibit
14
+ expect(response).to redirect_to main_app.root_path
15
+ expect(flash[:alert]).to be_present
16
+ end
15
17
  end
16
18
  end
17
19
 
@@ -19,7 +21,7 @@ describe Spotlight::ViewConfigurationsController, type: :controller do
19
21
  let(:user) { FactoryGirl.create(:exhibit_admin, exhibit: exhibit) }
20
22
  before { sign_in user }
21
23
 
22
- describe '#show' do
24
+ describe 'GET show' do
23
25
  it 'is successful' do
24
26
  get :show, exhibit_id: exhibit, format: 'json'
25
27
  expect(response).to be_successful
@@ -25,7 +25,7 @@ describe Spotlight::ApplicationHelper, type: :helper do
25
25
  end
26
26
 
27
27
  it 'is a url for a search with the given tag facet' do
28
- allow(Spotlight::SolrDocument).to receive_messages(solr_field_for_tagger: :exhibit_tags)
28
+ allow(SolrDocument).to receive_messages(solr_field_for_tagger: :exhibit_tags)
29
29
  expected = spotlight.exhibit_catalog_index_path(exhibit_id: helper.current_exhibit, f: { exhibit_tags: ['tag_value'] })
30
30
  expect(helper.url_to_tag_facet 'tag_value').to eq expected
31
31
  end
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  module Spotlight
4
4
  describe PagesHelper, type: :helper do
5
5
  let(:blacklight_config) { Blacklight::Configuration.new { |config| config.show.title_field = :abc } }
6
- let(:titled_document) { ::SolrDocument.new(abc: 'value') }
7
- let(:untitled_document) { ::SolrDocument.new(id: '1234') }
6
+ let(:titled_document) { blacklight_config.document_model.new(abc: 'value') }
7
+ let(:untitled_document) { blacklight_config.document_model.new(id: '1234') }
8
8
  let!(:current_exhibit) { FactoryGirl.create(:exhibit) }
9
9
  let!(:home_page) { current_exhibit.home_page }
10
10
  let!(:search) { FactoryGirl.create(:search, exhibit: current_exhibit, query_params: { 'q' => 'query' }, published: true) }
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SolrDocument, type: :model do
4
- subject { ::SolrDocument.new(id: 'abcd123') }
4
+ subject { described_class.new(id: 'abcd123') }
5
5
  its(:to_key) { should == ['abcd123'] }
6
6
  its(:persisted?) { should be_truthy }
7
7
  before do
@@ -23,21 +23,21 @@ describe SolrDocument, type: :model do
23
23
  end
24
24
 
25
25
  it 'has find' do
26
- expect(::SolrDocument.find('dq287tq6352')).to be_kind_of described_class
26
+ expect(described_class.find('dq287tq6352')).to be_kind_of described_class
27
27
  end
28
28
 
29
29
  it 'has ==' do
30
- expect(::SolrDocument.find('dq287tq6352')).to eq ::SolrDocument.find('dq287tq6352')
30
+ expect(described_class.find('dq287tq6352')).to eq described_class.find('dq287tq6352')
31
31
  end
32
32
 
33
33
  describe 'GlobalID' do
34
34
  let(:doc_id) { 'dq287tq6352' }
35
35
  it 'responds to #to_global_id' do
36
- expect(::SolrDocument.find(doc_id).to_global_id.to_s).to eq "gid://internal/SolrDocument/#{doc_id}"
36
+ expect(described_class.find(doc_id).to_global_id.to_s).to eq "gid://internal/SolrDocument/#{doc_id}"
37
37
  end
38
38
  it 'is able to locate SolrDocuments by their GlobalID' do
39
39
  expect(GlobalID::Locator.locate(
40
- ::SolrDocument.find(doc_id).to_global_id
40
+ described_class.find(doc_id).to_global_id
41
41
  )['id']).to eq doc_id
42
42
  end
43
43
  end