sunspot_rails 2.3.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c03385c874a558e6fdbf6390e452bfc5c87a09f8a6c3d5efae34854e7fdab3d5
4
- data.tar.gz: 472395a2311af2ef0323a5332c444275876958c4d2f8c6dacd50cee7fef0da56
3
+ metadata.gz: 63d24337902829c8c14a7ea0d9f081c7392b457e0604ff78887ed67037fcedc5
4
+ data.tar.gz: 77c235ecfc5bc55c4758abece0d0336bc0c541bf6461d5f134b7bec57eec3c88
5
5
  SHA512:
6
- metadata.gz: ccdf1424ba07fa9b7f9e2e6e0f4efc421f4da5aea49c3be1359616bb8727256fd72e7895ef0e294878d2e9f2c440661fbe97507b0219409eedb949c45cd2bf9d
7
- data.tar.gz: 84c1b362c773e4c4a47a4e662ab0c9ac1bc8afdd018da8c8c88d9f88092846a44e86755c93692e9fbbed550947c54c23545466092cc9cb50f858f650d784fe14
6
+ metadata.gz: a3a95a7312b3dd3b3402fee02ff137c85b357cf17c1babf7c98f5a37456515882d5e8978729d368b42fa67c4163d02704b7540f9878cd4dd9d09cde22f78f1b8
7
+ data.tar.gz: 3b031829d6bfac5ee89d7cc33ebc76375614e4ac21f9b1864b55d313a537d08a4ef96cd57d60cc41fabc5eca589a2e42052169172c77756adf382aac7e108dae
data/Appraisals CHANGED
@@ -3,6 +3,7 @@ ruby_version = Gem::Version.new(RUBY_VERSION)
3
3
  if ruby_version < Gem::Version.new('2.2.0')
4
4
  ['3.0.0', '3.1.0'].each do |rails_version|
5
5
  appraise "rails-#{rails_version}" do
6
+ gem 'bundler', '>= 1.3.0', '< 2.0'
6
7
  gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
7
8
  gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
8
9
  gem 'rails', "~> #{rails_version}"
@@ -15,6 +16,7 @@ end
15
16
 
16
17
  if ruby_version < Gem::Version.new('2.4.0')
17
18
  appraise 'rails-3.2.0' do
19
+ gem 'bundler', '>= 1.3.0', '< 2.0'
18
20
  gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
19
21
  gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
20
22
  gem 'rails', '~> 3.2.0'
@@ -26,10 +28,10 @@ if ruby_version < Gem::Version.new('2.4.0')
26
28
 
27
29
  ['4.0.0', '4.1.0'].each do |rails_version|
28
30
  appraise "rails-#{rails_version}" do
31
+ gem 'bundler', '>= 1.3.0', '< 2.0'
29
32
  gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
30
33
  gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
31
34
  gem 'rails', "~> #{rails_version}"
32
- gem 'protected_attributes'
33
35
  gem 'progress_bar', '~> 1.0.5', require: false
34
36
  gem 'rspec', '~> 3.4.0'
35
37
  gem 'rspec-rails', '~> 3.4.0'
@@ -37,23 +39,25 @@ if ruby_version < Gem::Version.new('2.4.0')
37
39
  end
38
40
  end
39
41
 
40
- appraise 'rails-4.2.0' do
41
- gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
42
- gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
43
- gem 'rails', '~> 4.2.0'
44
- gem 'protected_attributes'
45
- gem 'progress_bar', '~> 1.0.5', require: false
46
- gem 'rspec', '~> 3.4.0'
47
- gem 'rspec-rails', '~> 3.4.0'
42
+ if ruby_version < Gem::Version.new('2.5.0')
43
+ appraise 'rails-4.2.0' do
44
+ gem 'bundler', '>= 1.3.0', '< 2.0'
45
+ gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
46
+ gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
47
+ gem 'rails', '~> 4.2.0'
48
+ gem 'progress_bar', '~> 1.0.5', require: false
49
+ gem 'rspec', '~> 3.4.0'
50
+ gem 'rspec-rails', '~> 3.4.0'
51
+ end
48
52
  end
49
53
 
50
54
  if ruby_version >= Gem::Version.new('2.2.0')
51
- ['5.0.0', '5.1.0'].each do |rails_version|
55
+ ['5.0.0', '5.1.0', '5.2.0'].each do |rails_version|
52
56
  appraise "rails-#{rails_version}" do
53
57
  gem 'sunspot', path: File.expand_path('sunspot', ENV['SUNSPOT_LIB_HOME'])
54
58
  gem 'sunspot_solr', path: File.expand_path('sunspot_solr', ENV['SUNSPOT_LIB_HOME'])
55
59
  gem 'rails', "~> #{rails_version}"
56
- gem 'protected_attributes_continued'
60
+ gem 'sprockets', '~> 3.0'
57
61
  gem 'progress_bar', '~> 1.0.5', require: false
58
62
  end
59
63
  end
@@ -99,9 +99,15 @@ module Sunspot #:nodoc:
99
99
 
100
100
  unless options[:auto_remove] == false
101
101
  # after_commit { |searchable| searchable.remove_from_index }, :on => :destroy
102
- __send__ Sunspot::Rails.configuration.auto_remove_callback,
103
- proc { |searchable| searchable.remove_from_index },
104
- :on => :destroy
102
+ # Only add the on filter if the callback supports it
103
+ if Sunspot::Rails.configuration.auto_remove_callback =~ /save|destroy|create/
104
+ __send__ Sunspot::Rails.configuration.auto_remove_callback,
105
+ proc { |searchable| searchable.remove_from_index }
106
+ else
107
+ __send__ Sunspot::Rails.configuration.auto_remove_callback,
108
+ proc { |searchable| searchable.remove_from_index },
109
+ :on => :destroy
110
+ end
105
111
  end
106
112
  options[:include] = Util::Array(options[:include])
107
113
 
@@ -258,7 +264,7 @@ module Sunspot #:nodoc:
258
264
 
259
265
  if options[:batch_size].to_i > 0
260
266
  batch_counter = 0
261
- self.includes(options[:include]).find_in_batches(options.slice(:batch_size, :start)) do |records|
267
+ self.includes(options[:include]).find_in_batches(**options.slice(:batch_size, :start)) do |records|
262
268
 
263
269
  solr_benchmark(options[:batch_size], batch_counter += 1) do
264
270
  Sunspot.index(records.select(&:indexable?))
@@ -281,7 +287,7 @@ module Sunspot #:nodoc:
281
287
  #
282
288
  # ==== Updates (passed as a hash)
283
289
  #
284
- # updates should be specified as a hash, where key - is the object ID
290
+ # updates should be specified as a hash, where key - is the object or the object ID
285
291
  # and values is hash with property name/values to be updated.
286
292
  #
287
293
  # ==== Examples
@@ -297,6 +303,8 @@ module Sunspot #:nodoc:
297
303
  #
298
304
  # # update single property
299
305
  # Post.atomic_update(post1.id => {description: 'New post description'})
306
+ # Or
307
+ # Post.atomic_update(post1 => {description: 'New post description'})
300
308
  #
301
309
  # ==== Notice
302
310
  # all non-stored properties in Solr index will be lost after update.
@@ -447,7 +455,7 @@ module Sunspot #:nodoc:
447
455
  # you only need to pass hash with property changes
448
456
  #
449
457
  def solr_atomic_update(updates = {})
450
- Sunspot.atomic_update(self.class, self.id => updates)
458
+ Sunspot.atomic_update(self.class, self => updates)
451
459
  end
452
460
 
453
461
  #
@@ -455,7 +463,7 @@ module Sunspot #:nodoc:
455
463
  # See #solr_atomic_update
456
464
  #
457
465
  def solr_atomic_update!(updates = {})
458
- Sunspot.atomic_update!(self.class, self.id => updates)
466
+ Sunspot.atomic_update!(self.class, self => updates)
459
467
  end
460
468
 
461
469
  #
@@ -44,6 +44,10 @@ module Sunspot
44
44
  def optimize
45
45
  end
46
46
 
47
+ def config
48
+ Sunspot::Configuration.build
49
+ end
50
+
47
51
  def dirty?
48
52
  false
49
53
  end
@@ -104,7 +108,7 @@ module Sunspot
104
108
  []
105
109
  end
106
110
 
107
- def facet(name)
111
+ def facet(name, dynamic_name = nil)
108
112
  FacetStub.new
109
113
  end
110
114
 
@@ -123,6 +127,9 @@ module Sunspot
123
127
  def execute
124
128
  self
125
129
  end
130
+
131
+ def spellcheck_collation
132
+ end
126
133
  end
127
134
 
128
135
 
@@ -219,7 +226,7 @@ module Sunspot
219
226
  []
220
227
  end
221
228
 
222
- def facet(name)
229
+ def facet(name, dynamic_name = nil)
223
230
  FacetStub.new
224
231
  end
225
232
 
@@ -31,7 +31,6 @@ namespace :sunspot do
31
31
  # Load all the application's models. Models which invoke 'searchable' will register themselves
32
32
  # in Sunspot.searchable.
33
33
  Rails.application.eager_load!
34
- Rails::Engine.subclasses.each{|engine| engine.instance.eager_load!}
35
34
 
36
35
  if args[:models].present?
37
36
  # Choose a specific subset of models, if requested
@@ -2,8 +2,6 @@ class Author < ActiveRecord::Base
2
2
  self.table_name = :writers
3
3
  self.primary_key = :writer_id
4
4
 
5
- attr_accessible :name
6
-
7
5
  searchable do
8
6
  string :name
9
7
  end
@@ -2,8 +2,6 @@ class Blog < ActiveRecord::Base
2
2
  has_many :posts
3
3
  has_many :comments, :through => :posts
4
4
 
5
- attr_accessible :name, :subdomain
6
-
7
5
  searchable :include => { :posts => :author } do
8
6
  string :subdomain
9
7
  text :name
@@ -1,3 +1,2 @@
1
1
  class Location < ActiveRecord::Base
2
- attr_accessible :lat, :lng
3
2
  end
@@ -3,8 +3,6 @@ class Post < ActiveRecord::Base
3
3
  belongs_to :author
4
4
  has_many :comments
5
5
 
6
- attr_accessible :title, :type, :location_id, :body, :blog
7
-
8
6
  searchable :auto_index => false, :auto_remove => false do
9
7
  string :title
10
8
  text :body, :more_like_this => true
@@ -3,8 +3,6 @@ class PostWithAuto < ActiveRecord::Base
3
3
  'posts'
4
4
  end
5
5
 
6
- attr_accessible :title, :type, :location_id, :body, :blog
7
-
8
6
  searchable :ignore_attribute_changes_of => [ :updated_at ] do
9
7
  string :title
10
8
  text :body, :more_like_this => true
@@ -3,8 +3,6 @@ class PostWithDefaultScope < ActiveRecord::Base
3
3
  'posts'
4
4
  end
5
5
 
6
- attr_accessible :title, :type, :location_id, :body, :blog
7
-
8
6
  def self.default_scope
9
7
  order(:title)
10
8
  end
@@ -3,8 +3,6 @@ class PostWithOnlySomeAttributesTriggeringReindex < ActiveRecord::Base
3
3
  'posts'
4
4
  end
5
5
 
6
- attr_accessible :title, :type, :location_id, :body, :blog
7
-
8
6
  searchable :only_reindex_attribute_changes_of => [ :title, :body ] do
9
7
  string :title
10
8
  text :body, :more_like_this => true
@@ -4,6 +4,9 @@ require 'rails/all'
4
4
 
5
5
  Bundler.require(:default, Rails.env) if defined?(Bundler)
6
6
 
7
+ # Load the test engine
8
+ require File.expand_path('../../vendor/engines/test_engine/lib/test_engine', __FILE__)
9
+
7
10
  module RailsApp
8
11
  class Application < Rails::Application
9
12
  config.encoding = 'utf-8'
@@ -33,6 +33,9 @@ RailsApp::Application.configure do
33
33
  # like if you have constraints or database-specific column types
34
34
  # config.active_record.schema_format = :sql
35
35
 
36
+ # mute Rails 5.2 deprecation warning
37
+ config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3
38
+
36
39
  # Print deprecation notices to the stderr
37
40
  config.active_support.deprecation = :stderr
38
41
  end
@@ -2,6 +2,7 @@ test:
2
2
  solr:
3
3
  hostname: localhost
4
4
  port: 8983
5
+ update_format: <%= ENV.fetch('UPDATE_FORMAT', 'xml') %>
5
6
  auto_index_callback: after_save
6
7
  auto_remove_callback: after_destroy
7
8
  development:
@@ -0,0 +1,15 @@
1
+ # This model should not be used for any test other than the spec test that
2
+ # checks if all models are loaded. We don't want to pre-load this model in
3
+ # another test because we're checking to see if it will be auto-loaded by
4
+ # the reindex task
5
+ module TestEngine
6
+ class RakeTaskAutoLoadTestModel < ActiveRecord::Base
7
+ def self.table_name
8
+ 'posts'
9
+ end
10
+
11
+ searchable do
12
+ string :name
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module TestEngine
2
+ class Engine < ::Rails::Engine
3
+ engine_name 'sunspot_rails_test_engine'
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require_relative "test_engine/engine"
2
+
3
+ module TestEngine
4
+ end
@@ -11,8 +11,8 @@ describe 'sunspot namespace rake task' do
11
11
  it "should reindex all models if none are specified" do
12
12
  run_rake_task("sunspot:reindex", '', '', true)
13
13
 
14
- # This model should not be used by any other test and therefore should only be loaded by this test
15
- expect(Sunspot.searchable.collect(&:name)).to include('RakeTaskAutoLoadTestModel')
14
+ # This models should not be used by any other test and therefore should only be loaded by this test
15
+ expect(Sunspot.searchable.collect(&:name)).to include('RakeTaskAutoLoadTestModel', 'TestEngine::RakeTaskAutoLoadTestModel')
16
16
  end
17
17
 
18
18
  it "should accept a space delimited list of models to reindex" do
@@ -118,6 +118,10 @@ describe 'specs with Sunspot stubbed' do
118
118
  Sunspot.more_like_this(@post)
119
119
  end
120
120
 
121
+ it 'should not raise error when reindexing scope' do
122
+ expect{ Post.solr_index }.to_not raise_error
123
+ end
124
+
121
125
  describe 'stub search' do
122
126
  before :each do
123
127
  @search = Post.search
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  'Brian Atkinson', 'Tom Coleman', 'Matt Mitchell', 'Nathan Beyer', 'Kieran Topping', 'Nicolas Braem', 'Jeremy Ashkenas',
14
14
  'Dylan Vaughn', 'Brian Durand', 'Sam Granieri', 'Nick Zadrozny', 'Jason Ronallo']
15
15
  s.email = ["mat@patch.com"]
16
- s.homepage = 'http://github.com/outoftime/sunspot/tree/master/sunspot_rails'
16
+ s.homepage = 'http://github.com/sunspot/sunspot/tree/master/sunspot_rails'
17
17
  s.summary = 'Rails integration for the Sunspot Solr search library'
18
18
  s.license = 'MIT'
19
19
  s.description = <<-TEXT
@@ -25,22 +25,26 @@ Gem::Specification.new do |s|
25
25
  Rails request.
26
26
  TEXT
27
27
 
28
- s.rubyforge_project = "sunspot"
29
-
30
28
  s.files = `git ls-files`.split("\n")
31
29
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
32
30
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
33
31
  s.require_paths = ["lib"]
34
32
 
35
- s.add_dependency 'rails', '>= 3'
36
- s.add_dependency 'sunspot', Sunspot::VERSION
33
+ if RUBY_VERSION < '2.2'
34
+ s.add_dependency 'rails', '>= 3', '< 5'
35
+ else
36
+ s.add_dependency 'rails', '>= 3'
37
+ end
37
38
 
39
+ s.add_dependency 'sunspot', Sunspot::VERSION
40
+
38
41
  s.add_development_dependency 'appraisal', '2.2.0'
42
+ s.add_development_dependency 'bundler', '>= 1.3.0', '< 2.0' if RUBY_VERSION <= '2.0.0'
39
43
  s.add_development_dependency 'nokogiri', '< 1.7' if RUBY_VERSION <= '2.0.0'
40
44
  s.add_development_dependency 'rake', '< 12.3'
41
45
  s.add_development_dependency 'rspec', '~> 3.7'
42
46
  s.add_development_dependency 'rspec-rails', '~> 3.7'
43
- s.add_development_dependency 'sqlite3', '~> 1.3'
47
+ s.add_development_dependency 'sqlite3', '~> 1.3.0'
44
48
 
45
49
  s.rdoc_options << '--webcvs=http://github.com/outoftime/sunspot/tree/master/%s' <<
46
50
  '--title' << 'Sunspot-Rails - Rails integration for the Sunspot Solr search library - API Documentation' <<
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunspot_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Brown
@@ -23,10 +23,10 @@ authors:
23
23
  - Sam Granieri
24
24
  - Nick Zadrozny
25
25
  - Jason Ronallo
26
- autorequire:
26
+ autorequire:
27
27
  bindir: bin
28
28
  cert_chain: []
29
- date: 2018-04-08 00:00:00.000000000 Z
29
+ date: 2022-05-30 00:00:00.000000000 Z
30
30
  dependencies:
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: rails
@@ -48,14 +48,14 @@ dependencies:
48
48
  requirements:
49
49
  - - '='
50
50
  - !ruby/object:Gem::Version
51
- version: 2.3.0
51
+ version: 2.6.0
52
52
  type: :runtime
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
55
55
  requirements:
56
56
  - - '='
57
57
  - !ruby/object:Gem::Version
58
- version: 2.3.0
58
+ version: 2.6.0
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: appraisal
61
61
  requirement: !ruby/object:Gem::Requirement
@@ -118,14 +118,14 @@ dependencies:
118
118
  requirements:
119
119
  - - "~>"
120
120
  - !ruby/object:Gem::Version
121
- version: '1.3'
121
+ version: 1.3.0
122
122
  type: :development
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: '1.3'
128
+ version: 1.3.0
129
129
  description: |2
130
130
  Sunspot::Rails is an extension to the Sunspot library for Solr search.
131
131
  Sunspot::Rails adds integration between Sunspot and ActiveRecord, including
@@ -201,6 +201,9 @@ files:
201
201
  - spec/rails_app/config/routes.rb
202
202
  - spec/rails_app/config/sunspot.yml
203
203
  - spec/rails_app/db/schema.rb
204
+ - spec/rails_app/vendor/engines/test_engine/app/models/test_engine/rake_task_auto_load_test_model.rb
205
+ - spec/rails_app/vendor/engines/test_engine/lib/test_engine.rb
206
+ - spec/rails_app/vendor/engines/test_engine/lib/test_engine/engine.rb
204
207
  - spec/rake_task_spec.rb
205
208
  - spec/request_lifecycle_spec.rb
206
209
  - spec/schema.rb
@@ -212,11 +215,11 @@ files:
212
215
  - spec/spec_helper.rb
213
216
  - spec/stub_session_proxy_spec.rb
214
217
  - sunspot_rails.gemspec
215
- homepage: http://github.com/outoftime/sunspot/tree/master/sunspot_rails
218
+ homepage: http://github.com/sunspot/sunspot/tree/master/sunspot_rails
216
219
  licenses:
217
220
  - MIT
218
221
  metadata: {}
219
- post_install_message:
222
+ post_install_message:
220
223
  rdoc_options:
221
224
  - "--webcvs=http://github.com/outoftime/sunspot/tree/master/%s"
222
225
  - "--title"
@@ -236,9 +239,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
239
  - !ruby/object:Gem::Version
237
240
  version: '0'
238
241
  requirements: []
239
- rubyforge_project: sunspot
240
- rubygems_version: 2.7.6
241
- signing_key:
242
+ rubygems_version: 3.1.4
243
+ signing_key:
242
244
  specification_version: 4
243
245
  summary: Rails integration for the Sunspot Solr search library
244
246
  test_files:
@@ -268,6 +270,9 @@ test_files:
268
270
  - spec/rails_app/config/routes.rb
269
271
  - spec/rails_app/config/sunspot.yml
270
272
  - spec/rails_app/db/schema.rb
273
+ - spec/rails_app/vendor/engines/test_engine/app/models/test_engine/rake_task_auto_load_test_model.rb
274
+ - spec/rails_app/vendor/engines/test_engine/lib/test_engine.rb
275
+ - spec/rails_app/vendor/engines/test_engine/lib/test_engine/engine.rb
271
276
  - spec/rake_task_spec.rb
272
277
  - spec/request_lifecycle_spec.rb
273
278
  - spec/schema.rb