kithe 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,12 +5,12 @@ describe Kithe::Indexable, type: :model do
5
5
  @solr_url = "http://localhost:8983/solr/collection1"
6
6
  @solr_update_url = "#{@solr_url}/update/json?softCommit=true"
7
7
 
8
- @original_solr_url = Kithe::Indexable.settings.solr_url
9
- Kithe::Indexable.settings.solr_url =@solr_url
8
+ @original_solr_url = Kithe.indexable_settings.solr_url
9
+ Kithe.indexable_settings.solr_url =@solr_url
10
10
  end
11
11
 
12
12
  after do
13
- Kithe::Indexable.settings.solr_url = @original_solr_url
13
+ Kithe.indexable_settings.solr_url = @original_solr_url
14
14
  end
15
15
 
16
16
  temporary_class("TestWork") do
@@ -101,10 +101,10 @@ describe Kithe::Indexable, type: :model do
101
101
 
102
102
  describe "with global disable_callbacks" do
103
103
  around do |example|
104
- original = Kithe::Indexable.settings.disable_callbacks
105
- Kithe::Indexable.settings.disable_callbacks = true
104
+ original = Kithe.indexable_settings.disable_callbacks
105
+ Kithe.indexable_settings.disable_callbacks = true
106
106
  example.run
107
- Kithe::Indexable.settings.disable_callbacks = original
107
+ Kithe.indexable_settings.disable_callbacks = original
108
108
  end
109
109
 
110
110
  it "does not index" do
@@ -125,7 +125,7 @@ describe Kithe::Indexable, type: :model do
125
125
  thread_settings = nil
126
126
  it "batches solr updates" do
127
127
  stub_request(:post, @solr_update_url)
128
- expect(Kithe::Indexable.settings.writer_class_name.constantize).to receive(:new).and_call_original
128
+ expect(Kithe.indexable_settings.writer_class_name.constantize).to receive(:new).and_call_original
129
129
 
130
130
  Kithe::Indexable.index_with(batching: true) do
131
131
  TestWork.create!(title: "test1")
@@ -142,7 +142,7 @@ describe Kithe::Indexable, type: :model do
142
142
  end
143
143
 
144
144
  it "creates no writer if no updates happen" do
145
- expect(Kithe::Indexable.settings.writer_class_name.constantize).not_to receive(:new)
145
+ expect(Kithe.indexable_settings.writer_class_name.constantize).not_to receive(:new)
146
146
  Kithe::Indexable.index_with(batching: true) do
147
147
  end
148
148
  end
@@ -150,7 +150,7 @@ describe Kithe::Indexable, type: :model do
150
150
  it "respects non-default on_finish" do
151
151
  stub_request(:post, @solr_update_url)
152
152
  stub_request(:get, "#{@solr_url}/update/json?commit=true")
153
- expect(Kithe::Indexable.settings.writer_class_name.constantize).to receive(:new).and_call_original
153
+ expect(Kithe.indexable_settings.writer_class_name.constantize).to receive(:new).and_call_original
154
154
 
155
155
  Kithe::Indexable.index_with(batching: true, on_finish: ->(w){ w.flush; w.commit(commit: true) }) do
156
156
  TestWork.create!(title: "test1")
@@ -148,4 +148,36 @@ describe "Indexer end-to-end" do
148
148
  indexer.process_record(work)
149
149
  }.to raise_error(NameError)
150
150
  end
151
+
152
+ describe "custom solr_id_value_attribute" do
153
+ around do |example|
154
+ original = Kithe.indexable_settings.solr_id_value_attribute
155
+ Kithe.indexable_settings.solr_id_value_attribute = :friendlier_id
156
+ example.run
157
+ Kithe.indexable_settings.solr_id_value_attribute = original
158
+ end
159
+
160
+ it "indexes specified attribute to id" do
161
+ result = indexer.map_record(work)
162
+ expect(result).to include(
163
+ "id" => [work.friendlier_id]
164
+ )
165
+ end
166
+ end
167
+
168
+ describe "custom model_name_solr_field" do
169
+ around do |example|
170
+ original = Kithe.indexable_settings.model_name_solr_field
171
+ Kithe.indexable_settings.model_name_solr_field = "my_model_name"
172
+ example.run
173
+ Kithe.indexable_settings.model_name_solr_field = original
174
+ end
175
+
176
+ it "indexes specified attribute to id" do
177
+ result = indexer.map_record(work)
178
+ expect(result).to include(
179
+ "my_model_name" => ["TestWork"]
180
+ )
181
+ end
182
+ end
151
183
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kithe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Rochkind
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-15 00:00:00.000000000 Z
11
+ date: 2019-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -332,7 +332,10 @@ files:
332
332
  - db/migrate/20190109192252_contains_association.rb
333
333
  - db/migrate/20190404144551_kithe_model_type.rb
334
334
  - lib/kithe.rb
335
+ - lib/kithe/blacklight_tools/bulk_loading_search_service.rb
336
+ - lib/kithe/blacklight_tools/search_service_bulk_load.rb
335
337
  - lib/kithe/engine.rb
338
+ - lib/kithe/indexable_settings.rb
336
339
  - lib/kithe/version.rb
337
340
  - lib/shrine/plugins/kithe_accept_remote_url.rb
338
341
  - lib/shrine/plugins/kithe_multi_cache.rb
@@ -422,12 +425,10 @@ files:
422
425
  - spec/shrine/kithe_storage_location_spec.rb
423
426
  - spec/simple_form_enhancements/repeatable_input_generator_spec.rb
424
427
  - spec/spec_helper.rb
425
- - spec/test_repro_attempt.rb
426
428
  - spec/test_support/audio/README.md
427
429
  - spec/test_support/audio/ice_cubes.mp3
428
430
  - spec/test_support/images/1x1_pixel.jpg
429
431
  - spec/test_support/images/2x2_pixel.jpg
430
- - spec/test_support/images/otherphoto.jpg
431
432
  - spec/test_support/images/photo_800x586.jpg
432
433
  - spec/test_support/shrine_spec_support.rb
433
434
  - spec/test_support/temporary_class_for_specs.rb
@@ -540,12 +541,10 @@ test_files:
540
541
  - spec/shrine/kithe_storage_location_spec.rb
541
542
  - spec/simple_form_enhancements/repeatable_input_generator_spec.rb
542
543
  - spec/spec_helper.rb
543
- - spec/test_repro_attempt.rb
544
544
  - spec/test_support/audio/ice_cubes.mp3
545
545
  - spec/test_support/audio/README.md
546
546
  - spec/test_support/images/1x1_pixel.jpg
547
547
  - spec/test_support/images/2x2_pixel.jpg
548
- - spec/test_support/images/otherphoto.jpg
549
548
  - spec/test_support/images/photo_800x586.jpg
550
549
  - spec/test_support/shrine_spec_support.rb
551
550
  - spec/test_support/temporary_class_for_specs.rb
@@ -1,16 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe "yes", queue_adapter: :test do
4
- it "fails" do
5
- asset = Kithe::Model.new(title: "foo", type: "Kithe::Model")
6
- asset.file_attacher.assign(StringIO.new("data"))
7
- asset.save
8
-
9
- asset.promote
10
-
11
- #expect(asset.stored?).to be(true)
12
- expect(asset.file_attacher.stored?).to be(true)
13
- expect(asset.file.exists?).to be(true)
14
- expect(asset.file.metadata.keys).to include("filename", "size", "mime_type", "width", "height", "md5", "sha1", "sha512")
15
- end
16
- end