ruben_sunspot_rails 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +40 -0
- data/LICENSE +18 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +256 -0
- data/Rakefile +27 -0
- data/TODO +8 -0
- data/VERSION.yml +4 -0
- data/dev_tasks/gemspec.rake +33 -0
- data/dev_tasks/rdoc.rake +24 -0
- data/dev_tasks/release.rake +4 -0
- data/dev_tasks/todo.rake +4 -0
- data/generators/sunspot/sunspot_generator.rb +9 -0
- data/generators/sunspot/templates/sunspot.yml +18 -0
- data/install.rb +1 -0
- data/lib/sunspot/rails/adapters.rb +83 -0
- data/lib/sunspot/rails/configuration.rb +272 -0
- data/lib/sunspot/rails/request_lifecycle.rb +31 -0
- data/lib/sunspot/rails/searchable.rb +412 -0
- data/lib/sunspot/rails/server.rb +173 -0
- data/lib/sunspot/rails/solr_logging.rb +58 -0
- data/lib/sunspot/rails/spec_helper.rb +19 -0
- data/lib/sunspot/rails/stub_session_proxy.rb +88 -0
- data/lib/sunspot/rails/tasks.rb +61 -0
- data/lib/sunspot/rails/version.rb +5 -0
- data/lib/sunspot/rails.rb +58 -0
- data/rails/init.rb +7 -0
- data/spec/configuration_spec.rb +102 -0
- data/spec/mock_app/app/controllers/application.rb +10 -0
- data/spec/mock_app/app/controllers/application_controller.rb +10 -0
- data/spec/mock_app/app/controllers/posts_controller.rb +6 -0
- data/spec/mock_app/app/models/author.rb +8 -0
- data/spec/mock_app/app/models/blog.rb +12 -0
- data/spec/mock_app/app/models/location.rb +2 -0
- data/spec/mock_app/app/models/photo_post.rb +2 -0
- data/spec/mock_app/app/models/post.rb +10 -0
- data/spec/mock_app/app/models/post_with_auto.rb +10 -0
- data/spec/mock_app/config/boot.rb +110 -0
- data/spec/mock_app/config/database.yml +4 -0
- data/spec/mock_app/config/environment.rb +42 -0
- data/spec/mock_app/config/environments/development.rb +27 -0
- data/spec/mock_app/config/environments/test.rb +27 -0
- data/spec/mock_app/config/initializers/new_rails_defaults.rb +19 -0
- data/spec/mock_app/config/initializers/session_store.rb +15 -0
- data/spec/mock_app/config/routes.rb +43 -0
- data/spec/mock_app/config/sunspot.yml +19 -0
- data/spec/mock_app/db/schema.rb +27 -0
- data/spec/model_lifecycle_spec.rb +63 -0
- data/spec/model_spec.rb +409 -0
- data/spec/request_lifecycle_spec.rb +52 -0
- data/spec/schema.rb +27 -0
- data/spec/server_spec.rb +36 -0
- data/spec/session_spec.rb +24 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/stub_session_proxy_spec.rb +122 -0
- metadata +180 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
ENV['RAILS_ENV'] = 'test'
|
2
|
+
ENV['RAILS_ROOT'] ||= File.join(File.dirname(__FILE__), 'mock_app')
|
3
|
+
if rsolr_version = ENV['RSOLR_GEM_VERSION']
|
4
|
+
STDERR.puts("Forcing RSolr version #{rsolr_version}")
|
5
|
+
gem "rsolr", rsolr_version
|
6
|
+
end
|
7
|
+
|
8
|
+
if File.exist?(sunspot_lib = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'sunspot', 'lib')))
|
9
|
+
STDERR.puts("Using sunspot lib at #{sunspot_lib}")
|
10
|
+
$: << sunspot_lib
|
11
|
+
end
|
12
|
+
|
13
|
+
require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config', 'environment.rb'))
|
14
|
+
|
15
|
+
require 'spec'
|
16
|
+
require 'spec/rails'
|
17
|
+
require 'rake'
|
18
|
+
require 'ruby-debug' unless RUBY_VERSION > '1.9'
|
19
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'sunspot', 'rails', 'solr_logging')
|
20
|
+
|
21
|
+
def load_schema
|
22
|
+
stdout = $stdout
|
23
|
+
$stdout = StringIO.new # suppress output while building the schema
|
24
|
+
load File.join(ENV['RAILS_ROOT'], 'db', 'schema.rb')
|
25
|
+
$stdout = stdout
|
26
|
+
end
|
27
|
+
|
28
|
+
def silence_stderr(&block)
|
29
|
+
stderr = $stderr
|
30
|
+
$stderr = StringIO.new
|
31
|
+
yield
|
32
|
+
$stderr = stderr
|
33
|
+
end
|
34
|
+
|
35
|
+
Spec::Runner.configure do |config|
|
36
|
+
config.before(:each) do
|
37
|
+
load_schema
|
38
|
+
Sunspot.remove_all!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module Spec
|
43
|
+
module Mocks
|
44
|
+
module Methods
|
45
|
+
def should_respond_to_and_receive(*args, &block)
|
46
|
+
respond_to?(args.first).should ==(true)
|
47
|
+
should_receive(*args, &block)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'spec_helper')
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'sunspot', 'rails', 'spec_helper')
|
3
|
+
|
4
|
+
describe 'specs with Sunspot stubbed' do
|
5
|
+
disconnect_sunspot
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
@session = Sunspot.session.original_session
|
9
|
+
@post = Post.create!
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should not send index to session' do
|
13
|
+
@session.should_not_receive(:index)
|
14
|
+
@post.index
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should not send index! to session' do
|
18
|
+
@session.should_not_receive(:index!)
|
19
|
+
@post.index!
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should not send commit to session' do
|
23
|
+
@session.should_not_receive(:commit)
|
24
|
+
Sunspot.commit
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should not send remove to session' do
|
28
|
+
@session.should_not_receive(:remove)
|
29
|
+
@post.remove_from_index
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should not send remove! to session' do
|
33
|
+
@session.should_not_receive(:remove)
|
34
|
+
@post.remove_from_index!
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should not send remove_by_id to session' do
|
38
|
+
@session.should_not_receive(:remove_by_id)
|
39
|
+
Sunspot.remove_by_id(Post, 1)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should not send remove_by_id! to session' do
|
43
|
+
@session.should_not_receive(:remove_by_id!)
|
44
|
+
Sunspot.remove_by_id!(Post, 1)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should not send remove_all to session' do
|
48
|
+
@session.should_not_receive(:remove_all)
|
49
|
+
Post.remove_all_from_index
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should not send remove_all! to session' do
|
53
|
+
@session.should_not_receive(:remove_all!)
|
54
|
+
Post.remove_all_from_index!
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should return false for dirty?' do
|
58
|
+
@session.should_not_receive(:dirty?)
|
59
|
+
Sunspot.dirty?.should == false
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should not send commit_if_dirty to session' do
|
63
|
+
@session.should_not_receive(:commit_if_dirty)
|
64
|
+
Sunspot.commit_if_dirty
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should return false for delete_dirty?' do
|
68
|
+
@session.should_not_receive(:delete_dirty?)
|
69
|
+
Sunspot.delete_dirty?.should == false
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should not send commit_if_delete_dirty to session' do
|
73
|
+
@session.should_not_receive(:commit_if_delete_dirty)
|
74
|
+
Sunspot.commit_if_delete_dirty
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should not execute a search when #search called' do
|
78
|
+
@session.should_not_receive(:search)
|
79
|
+
Post.search
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should not execute a search when #search called' do
|
83
|
+
@session.should_not_receive(:search)
|
84
|
+
Post.search
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should not execute a search when #search called with parameters' do
|
88
|
+
@session.should_not_receive(:search)
|
89
|
+
Post.search(:include => :blog, :select => 'id, title')
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should return a new search' do
|
93
|
+
@session.should_not_receive(:new_search)
|
94
|
+
Sunspot.new_search(Post).should respond_to(:execute)
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'stub search' do
|
98
|
+
before :each do
|
99
|
+
@search = Post.search
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should return empty results' do
|
103
|
+
@search.results.should == []
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should return empty hits' do
|
107
|
+
@search.hits.should == []
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should return zero total' do
|
111
|
+
@search.total.should == 0
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should return nil for a given facet' do
|
115
|
+
@search.facet(:category_id).should be_nil
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should return nil for a given dynamic facet' do
|
119
|
+
@search.dynamic_facet(:custom).should be_nil
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruben_sunspot_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 1.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Mat Brown
|
14
|
+
- Peer Allan
|
15
|
+
- Michael Moen
|
16
|
+
- Benjamin Krause
|
17
|
+
- Adam Salter
|
18
|
+
- Brandon Keepers
|
19
|
+
- Paul Canavese
|
20
|
+
- John Eberly
|
21
|
+
- Gert Thiel
|
22
|
+
autorequire:
|
23
|
+
bindir: bin
|
24
|
+
cert_chain: []
|
25
|
+
|
26
|
+
date: 2010-12-14 00:00:00 +01:00
|
27
|
+
default_executable:
|
28
|
+
dependencies:
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: ruben-sunspot
|
31
|
+
prerelease: false
|
32
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - "="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
hash: 19
|
38
|
+
segments:
|
39
|
+
- 1
|
40
|
+
- 1
|
41
|
+
- 0
|
42
|
+
version: 1.1.0
|
43
|
+
type: :runtime
|
44
|
+
version_requirements: *id001
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: rspec
|
47
|
+
prerelease: false
|
48
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 11
|
54
|
+
segments:
|
55
|
+
- 1
|
56
|
+
- 2
|
57
|
+
version: "1.2"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id002
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rspec-rails
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
hash: 11
|
69
|
+
segments:
|
70
|
+
- 1
|
71
|
+
- 2
|
72
|
+
version: "1.2"
|
73
|
+
type: :development
|
74
|
+
version_requirements: *id003
|
75
|
+
description: |
|
76
|
+
Sunspot::Rails is an extension to the Sunspot library for Solr search.
|
77
|
+
Sunspot::Rails adds integration between Sunspot and ActiveRecord, including
|
78
|
+
defining search and indexing related methods on ActiveRecord models themselves,
|
79
|
+
running a Sunspot-compatible Solr instance for development and test
|
80
|
+
environments, and automatically commit Solr index changes at the end of each
|
81
|
+
Rails request.
|
82
|
+
|
83
|
+
email: mat@patch.com
|
84
|
+
executables: []
|
85
|
+
|
86
|
+
extensions: []
|
87
|
+
|
88
|
+
extra_rdoc_files: []
|
89
|
+
|
90
|
+
files:
|
91
|
+
- History.txt
|
92
|
+
- LICENSE
|
93
|
+
- MIT-LICENSE
|
94
|
+
- Rakefile
|
95
|
+
- README.rdoc
|
96
|
+
- TODO
|
97
|
+
- VERSION.yml
|
98
|
+
- lib/sunspot/rails/adapters.rb
|
99
|
+
- lib/sunspot/rails/configuration.rb
|
100
|
+
- lib/sunspot/rails/request_lifecycle.rb
|
101
|
+
- lib/sunspot/rails/searchable.rb
|
102
|
+
- lib/sunspot/rails/server.rb
|
103
|
+
- lib/sunspot/rails/solr_logging.rb
|
104
|
+
- lib/sunspot/rails/spec_helper.rb
|
105
|
+
- lib/sunspot/rails/stub_session_proxy.rb
|
106
|
+
- lib/sunspot/rails/tasks.rb
|
107
|
+
- lib/sunspot/rails/version.rb
|
108
|
+
- lib/sunspot/rails.rb
|
109
|
+
- dev_tasks/gemspec.rake
|
110
|
+
- dev_tasks/rdoc.rake
|
111
|
+
- dev_tasks/release.rake
|
112
|
+
- dev_tasks/todo.rake
|
113
|
+
- generators/sunspot/sunspot_generator.rb
|
114
|
+
- generators/sunspot/templates/sunspot.yml
|
115
|
+
- install.rb
|
116
|
+
- rails/init.rb
|
117
|
+
- spec/configuration_spec.rb
|
118
|
+
- spec/model_lifecycle_spec.rb
|
119
|
+
- spec/model_spec.rb
|
120
|
+
- spec/request_lifecycle_spec.rb
|
121
|
+
- spec/schema.rb
|
122
|
+
- spec/server_spec.rb
|
123
|
+
- spec/session_spec.rb
|
124
|
+
- spec/spec_helper.rb
|
125
|
+
- spec/stub_session_proxy_spec.rb
|
126
|
+
- spec/mock_app/app/controllers/application.rb
|
127
|
+
- spec/mock_app/app/controllers/application_controller.rb
|
128
|
+
- spec/mock_app/app/controllers/posts_controller.rb
|
129
|
+
- spec/mock_app/app/models/author.rb
|
130
|
+
- spec/mock_app/app/models/blog.rb
|
131
|
+
- spec/mock_app/app/models/location.rb
|
132
|
+
- spec/mock_app/app/models/photo_post.rb
|
133
|
+
- spec/mock_app/app/models/post.rb
|
134
|
+
- spec/mock_app/app/models/post_with_auto.rb
|
135
|
+
- spec/mock_app/db/schema.rb
|
136
|
+
- spec/mock_app/config/boot.rb
|
137
|
+
- spec/mock_app/config/database.yml
|
138
|
+
- spec/mock_app/config/environment.rb
|
139
|
+
- spec/mock_app/config/environments/development.rb
|
140
|
+
- spec/mock_app/config/environments/test.rb
|
141
|
+
- spec/mock_app/config/initializers/new_rails_defaults.rb
|
142
|
+
- spec/mock_app/config/initializers/session_store.rb
|
143
|
+
- spec/mock_app/config/routes.rb
|
144
|
+
- spec/mock_app/config/sunspot.yml
|
145
|
+
has_rdoc: true
|
146
|
+
homepage: http://github.com/outoftime/sunspot_rails
|
147
|
+
licenses: []
|
148
|
+
|
149
|
+
post_install_message:
|
150
|
+
rdoc_options: []
|
151
|
+
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
hash: 3
|
160
|
+
segments:
|
161
|
+
- 0
|
162
|
+
version: "0"
|
163
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
164
|
+
none: false
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
hash: 3
|
169
|
+
segments:
|
170
|
+
- 0
|
171
|
+
version: "0"
|
172
|
+
requirements: []
|
173
|
+
|
174
|
+
rubyforge_project: sunspot
|
175
|
+
rubygems_version: 1.3.7
|
176
|
+
signing_key:
|
177
|
+
specification_version: 3
|
178
|
+
summary: Rails integration for the Sunspot Solr search library
|
179
|
+
test_files: []
|
180
|
+
|