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
@@ -73,15 +73,14 @@ describe Spotlight::CustomField, type: :model do
73
73
 
74
74
  describe '#solr_field' do
75
75
  let(:exhibit) { FactoryGirl.create(:exhibit) }
76
-
77
- before do
78
- subject.configuration['label'] = 'xyz'
79
- subject.exhibit = exhibit
80
- subject.save
76
+ let(:custom_field) do
77
+ described_class.create(exhibit: exhibit, configuration: { 'label' => 'xyz' })
81
78
  end
82
79
 
80
+ subject { custom_field.solr_field }
81
+
83
82
  it 'is auto-generated from the field label' do
84
- expect(subject.solr_field).to eq "exhibit_#{exhibit.to_param}_xyz_tesim"
83
+ expect(subject).to eq "exhibit_#{exhibit.to_param}_xyz_tesim"
85
84
  end
86
85
 
87
86
  context 'with a solr field prefix configured' do
@@ -90,17 +89,17 @@ describe Spotlight::CustomField, type: :model do
90
89
  end
91
90
 
92
91
  it 'uses the solr field prefix' do
93
- expect(subject.solr_field).to eq "prefix_exhibit_#{exhibit.to_param}_xyz_tesim"
92
+ expect(subject).to eq "prefix_exhibit_#{exhibit.to_param}_xyz_tesim"
94
93
  end
95
94
  end
96
95
 
97
96
  context 'for a legacy solr field name' do
98
97
  before do
99
- subject.field = "exhibit_#{exhibit.to_param}_xyz_tesim"
98
+ custom_field.field = "exhibit_#{exhibit.to_param}_xyz_tesim"
100
99
  end
101
100
 
102
101
  it 'returns the original field name' do
103
- expect(subject.solr_field).to eq "exhibit_#{exhibit.to_param}_xyz_tesim"
102
+ expect(subject).to eq "exhibit_#{exhibit.to_param}_xyz_tesim"
104
103
  end
105
104
  end
106
105
  end
@@ -6,7 +6,7 @@ describe Spotlight::Resources::OpenGraph, type: :model do
6
6
  include Spotlight::Resources::OpenGraph
7
7
  end
8
8
 
9
- let(:exhibit) { double(solr_data: {}) }
9
+ let(:exhibit) { double(solr_data: {}, blacklight_config: Blacklight::Configuration.new) }
10
10
 
11
11
  subject { TestResource.new url: 'info:url' }
12
12
 
@@ -99,4 +99,14 @@ describe Spotlight::Search, type: :model do
99
99
  end
100
100
  end
101
101
  end
102
+
103
+ describe '#repository' do
104
+ let(:search) { FactoryGirl.create(:search) }
105
+ before do
106
+ allow(search).to receive(:blacklight_config).and_return blacklight_config
107
+ end
108
+ it 'returns an exhibit specific config' do
109
+ expect(search.send(:repository).blacklight_config).to eql blacklight_config
110
+ end
111
+ end
102
112
  end
@@ -89,7 +89,7 @@ describe Spotlight::Sitemap do
89
89
  end
90
90
 
91
91
  describe '#add_resources' do
92
- let(:document) { ::SolrDocument.new(id: 'a') }
92
+ let(:document) { blacklight_config.document_model.new(id: 'a') }
93
93
 
94
94
  before do
95
95
  allow(exhibit).to receive(:solr_documents).and_return([document])
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Spotlight::SolrDocument::AtomicUpdates, type: :model do
4
4
  let(:blacklight_solr) { double }
5
5
  subject do
6
- ::SolrDocument.new.extend(described_class)
6
+ SolrDocument.new.extend(described_class)
7
7
  end
8
8
 
9
9
  before do
@@ -2,16 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  describe Spotlight::SolrDocument::UploadedResource, type: :model do
4
4
  let(:valid_resource) do
5
- ::SolrDocument.new(id: '123',
6
- full_image_url_ssm: ['http://example.com/png.png'],
7
- spotlight_full_image_height_ssm: ['1400'],
8
- spotlight_full_image_width_ssm: ['1000'],
9
- spotlight_resource_type_ssim: ['spotlight/resources/uploads'])
5
+ SolrDocument.new(id: '123',
6
+ full_image_url_ssm: ['http://example.com/png.png'],
7
+ spotlight_full_image_height_ssm: ['1400'],
8
+ spotlight_full_image_width_ssm: ['1000'],
9
+ spotlight_resource_type_ssim: ['spotlight/resources/uploads'])
10
10
  end
11
11
 
12
12
  describe 'SolrDocument.use_extension' do
13
13
  it 'does not include the uploaded resource extension when the spotlight resource type is not correct' do
14
- expect(::SolrDocument.new(id: '123', spotlight_resource_type_ssim: ['not-correct'])).to_not be_a_kind_of(described_class)
14
+ expect(SolrDocument.new(id: '123', spotlight_resource_type_ssim: ['not-correct'])).to_not be_a_kind_of(described_class)
15
15
  end
16
16
  it 'includes the uploaded resource extension when the correct fields are present with the correct data' do
17
17
  expect(valid_resource).to be_a_kind_of(described_class)
@@ -8,7 +8,7 @@ module Spotlight
8
8
 
9
9
  before do
10
10
  assign(:exhibits, exhibits)
11
- allow(view).to receive_messages(exhibit_path: '/', current_ability: ability)
11
+ allow(view).to receive_messages(exhibit_path: '/', current_user: user, current_ability: ability)
12
12
  end
13
13
 
14
14
  context 'with published exhibits' do
@@ -29,24 +29,53 @@ module Spotlight
29
29
  expect(rendered).not_to include 'Private exhibits'
30
30
  end
31
31
 
32
- context 'with an authorized user' do
32
+ it 'does not include the tab bar' do
33
+ render
34
+
35
+ expect(rendered).not_to have_selector '.nav-tabs'
36
+ end
37
+
38
+ context 'with an exhibit admin' do
39
+ let(:user) { FactoryGirl.create(:exhibit_admin) }
40
+
41
+ it 'includes a tab with the exhibits curated by the user' do
42
+ render
43
+
44
+ expect(rendered).to have_selector '.nav-tabs'
45
+ expect(rendered).to have_link 'Your exhibits'
46
+ expect(rendered).to have_text user.exhibits.first.title
47
+ end
48
+
49
+ it 'does not include a tab for unpublished exhibits' do
50
+ render
51
+
52
+ expect(rendered).to have_selector '.nav-tabs'
53
+ expect(rendered).not_to have_link 'Unpublished exhibits'
54
+ end
55
+ end
56
+
57
+ context 'with a site admin' do
33
58
  let(:user) { FactoryGirl.create(:site_admin) }
34
59
 
35
- it 'includes a list of unpublished exhibits' do
60
+ before do
61
+ allow(view).to receive_messages(can?: true, new_exhibit_path: '/exhibits/new')
62
+ end
63
+
64
+ it 'includes a tab with unpublished exhibits' do
36
65
  render
37
66
 
38
- expect(rendered).to include 'Private exhibits'
67
+ expect(rendered).to have_selector '.nav-tabs'
68
+ expect(rendered).to have_link 'Unpublished exhibits'
39
69
  expect(rendered).to have_text exhibit_c.title
40
70
  end
41
71
  end
42
72
  end
43
73
 
44
74
  context 'with an authorized user' do
45
- let(:current_user) { double }
75
+ let(:user) { FactoryGirl.build(:site_admin) }
46
76
 
47
77
  before do
48
78
  allow(view).to receive_messages(can?: true,
49
- current_user: current_user,
50
79
  new_exhibit_path: '/exhibits/new')
51
80
  end
52
81
 
@@ -6,7 +6,7 @@ describe 'spotlight/sir_trevor/blocks/_solr_documents_block.html.erb', type: :vi
6
6
  let(:block) do
7
7
  SirTrevorRails::Blocks::SolrDocumentsBlock.new({ type: 'block', data: { title: 'Some title', text: 'Some text', 'text-align' => 'right' } }, page)
8
8
  end
9
- let(:doc) { ::SolrDocument.new(id: 1) }
9
+ let(:doc) { blacklight_config.document_model.new(id: 1) }
10
10
  let(:blacklight_config) do
11
11
  Blacklight::Configuration.new do |config|
12
12
  config.view.embed.partials = %w(a b c)
@@ -7,7 +7,11 @@ describe 'spotlight/sir_trevor/blocks/_solr_documents_carousel_block.html.erb',
7
7
  end
8
8
 
9
9
  before do
10
- allow(block).to receive(:each_document).and_return([[{}, ::SolrDocument.new(id: 1)], [{}, ::SolrDocument.new(id: 2)], [{}, ::SolrDocument.new(id: 3)]])
10
+ allow(block).to receive(:each_document).and_return([
11
+ [{}, SolrDocument.new(id: 1)],
12
+ [{}, SolrDocument.new(id: 2)],
13
+ [{}, SolrDocument.new(id: 3)]
14
+ ])
11
15
  allow(block).to receive_messages(documents?: true)
12
16
  allow(view).to receive_messages(solr_documents_carousel_block: block)
13
17
  allow(view).to receive_messages(has_thumbnail?: true, render_thumbnail_tag: 'thumb')
@@ -6,7 +6,7 @@ describe 'spotlight/sir_trevor/blocks/_solr_documents_embed_block.html.erb', typ
6
6
  let(:block) do
7
7
  SirTrevorRails::Blocks::SolrDocumentsEmbedBlock.new({ type: 'block', data: { title: 'Some title', text: 'Some text', 'text-align' => 'right' } }, page)
8
8
  end
9
- let(:doc) { ::SolrDocument.new(id: 1) }
9
+ let(:doc) { blacklight_config.document_model.new(id: 1) }
10
10
  let(:blacklight_config) do
11
11
  Blacklight::Configuration.new do |config|
12
12
  config.view.embed.partials = %w(a b c)
@@ -7,9 +7,9 @@ describe 'spotlight/sir_trevor/blocks/_solr_documents_features_block.html.erb',
7
7
  end
8
8
 
9
9
  before do
10
- doc1 = [{}, ::SolrDocument.new(id: 1, x: 'a' * 100)]
11
- doc2 = [{}, ::SolrDocument.new(id: 2)]
12
- doc3 = [{}, ::SolrDocument.new(id: 3)]
10
+ doc1 = [{}, SolrDocument.new(id: 1, x: 'a' * 100)]
11
+ doc2 = [{}, SolrDocument.new(id: 2)]
12
+ doc3 = [{}, SolrDocument.new(id: 3)]
13
13
  allow(block).to receive(:each_document).and_return([doc1, doc2, doc3])
14
14
  allow(block).to receive_messages(documents?: true)
15
15
  allow(view).to receive_messages(solr_documents_features_block: block)
@@ -8,7 +8,11 @@ describe 'spotlight/sir_trevor/blocks/_solr_documents_grid_block.html.erb', type
8
8
  end
9
9
 
10
10
  before do
11
- allow(block).to receive(:each_document).and_return([[{}, ::SolrDocument.new(id: 1)], [{}, ::SolrDocument.new(id: 2)], [{}, ::SolrDocument.new(id: 3)]])
11
+ allow(block).to receive(:each_document).and_return([
12
+ [{}, SolrDocument.new(id: 1)],
13
+ [{}, SolrDocument.new(id: 2)],
14
+ [{}, SolrDocument.new(id: 3)]
15
+ ])
12
16
  end
13
17
 
14
18
  before do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-spotlight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-12-11 00:00:00.000000000 Z
14
+ date: 2015-12-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -918,7 +918,6 @@ files:
918
918
  - app/views/shared/_exhibit_masthead.html.erb
919
919
  - app/views/shared/_exhibit_masthead_and_navbar.html.erb
920
920
  - app/views/shared/_exhibit_navbar.html.erb
921
- - app/views/shared/_flash_messages.html.erb
922
921
  - app/views/shared/_footer.html.erb
923
922
  - app/views/shared/_header_navbar.html.erb
924
923
  - app/views/shared/_home_sidebar.html.erb
@@ -975,7 +974,6 @@ files:
975
974
  - app/views/spotlight/exhibits/_contact.html.erb
976
975
  - app/views/spotlight/exhibits/_delete.html.erb
977
976
  - app/views/spotlight/exhibits/_exhibit_card.html.erb
978
- - app/views/spotlight/exhibits/_exhibit_list.html.erb
979
977
  - app/views/spotlight/exhibits/_export.html.erb
980
978
  - app/views/spotlight/exhibits/_form.html.erb
981
979
  - app/views/spotlight/exhibits/_import.html.erb
@@ -1098,7 +1096,6 @@ files:
1098
1096
  - db/migrate/20151124101123_remove_default_from_spotlight_exhibit.rb
1099
1097
  - db/migrate/20151124105543_update_custom_field_names.rb
1100
1098
  - db/migrate/20151208085432_add_weight_to_exhibits.rb
1101
- - db/migrate/20151210073829_create_spotlight_configuration.rb
1102
1099
  - lib/blacklight/spotlight.rb
1103
1100
  - lib/generators/spotlight/install_generator.rb
1104
1101
  - lib/generators/spotlight/templates/catalog_controller.rb
@@ -1,7 +0,0 @@
1
- <div class="row">
2
- <div class="col-md-12">
3
- <div id="main-flashes">
4
- <%= render :partial=>'/flash_msg' %>
5
- </div>
6
- </div>
7
- </div>
@@ -1,3 +0,0 @@
1
- <li>
2
- <%= link_to exhibit.title, exhibit %>
3
- </li>
@@ -1,7 +0,0 @@
1
- class CreateSpotlightConfiguration < ActiveRecord::Migration
2
- def change
3
- create_table :spotlight_configurations do |t|
4
- t.references :masthead
5
- end
6
- end
7
- end